0

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

2
  • 2
    You can iterate until you hit the $ 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.
    – Jester
    Commented May 13 at 14:01
  • Hello Jester. Thank you for the help. I will go ahead and try what you suggested. Do you have any documentation that can help me do what you suggested? I can't seem to find much resources with TASM
    – SkyZon.
    Commented May 13 at 15:20

0

Browse other questions tagged or ask your own question.