cowboysaif
cowboysaif

Reputation: 241

Properly convert an array to string in 8086 assembly

I have an array

INPUT 10 DUP(?)

after some operation, i need to print this array by mov ah,9. What things i need to do ?

Upvotes: 0

Views: 760

Answers (1)

Tony
Tony

Reputation: 1657

You have an empty array, or at least one with undefined contents.

You will need to fill it up with something to be able to print it.

To start with, you could try input db 'Testing','$', instead of input 10 dup(?). This will put the word "Testing" followed by a "$" into the memory location labelled by "input".

Then you will need to print what you have put in the array, using something like:

mov dx, offset input    # want BIOS call to point at the "input" location
                        # (with your "Testing" string in it)
mov ah, 9               # want BIOS call 9 (prints a string terminated by a $)
int 21h                 # run BIOS call

Once you have that working, you can worry about how you can fill up "input" from some other source, like input from the user (BIOS calls 1h or 0ah may be helpful to you). Adding a $ character to the end of the string will probably involve involve a mov [register] 24h or something similar (24h is the ascii code for "$").

As @harold said in the comments, 0ah and 0dh are characters that you put at the end of a string to make the next character print on the next line down.

Upvotes: 1

Related Questions