i tried to read an array in an repetitive structure but it gives me an error , is there an alternative for the code bellow ?
.data
aux db 0
array db 0,1,2,3,4,5,6,7,8,9
.code
main:
print_array:
mov dl, array[aux]
mov ah, 02h
int 21h
inc aux
cmp aux, 9
je exit
jmp print_array
exit:
mov ah, 4ch
int 21h
end main
CodePudding user response:
The aux variable serves to index the array. You cannot use a memory based variable this way. Better use an address register for this purpose:
xor si, si
print_array:
mov dl, array[si]
mov ah, 02h
int 21h
inc si
cmp si, 9
jbe print_array
