I have an array, fruitNames db "Apple$", "Mango$", "Orange$", "Kiwi$", "Watermelon$"
. I want to print every fruit name and display them using loops. Here is what i tried to do.
MOV CX, 5 ; NUMBER OF FRUITS TO PRINT
MOV SI, 0 ; POINT TO THE FIRST ELEMENT IN THE ARRAY
ArrayString:
LEA DX, fruitNames[SI]
MOV AH, 09H
INT 21H
CALL newLine
INC SI ; next index
LOOP ArrayString
However, the output came as:
Apple
pple
ple
le
e
Im aware that its accessing the char of the word apple and each time it iterates it goes on to the next char instead of word. How can i fix this
$
so you know where the next string starts. You can also pad the strings to a fixed length so you can move to the next one with a constant offset. You could also make a table of pointers.