NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: nobody on March 22, 2005, 07:14:14 AM
-
i tried echoing the tempx's values (tempx's values are acquired from 0x0a loaded to ah) but the display seem to be erratic. its says printer out of paper and i/o error sumthin like that.. although i didnt use 0x05 for AH. i think its about the string not being terminated by '$'
i tried echoing it using the standard lea cmd
mov ah,0x09
lea dx,[tempx] <-- x is a number
int 0x21
how can i display it without all the display or pc being erratic??
-
After int 21h/0Ah returns, the number of bytes actually entered is in [tempx + 1]...
mov ah, 0Ah
mov dx, tempx
int 21h
mov bl, [tempx + 1]
mov bh, 0
mov byte [tempx + 2 + bx], '$'
mov ah, 9
mov dx, tempx + 2
int 21h
I don't recall whether the "count" includes the terminating carriage-return or not - adjust the "[tempx + 2 + bx]" so it comes out right :)
You can use "lea dx, [tempx + 2]" instead of the "mov"... but it's longer... Could use "movzx" to get the byte-sized count into the word-sized register, instead of "mov bh, 0", too...
There are other ways to print a string besides int 21h/9, too. The "write to file" int 21h/40h expects the "count" in cx, instead of the silly $-terminated string (bx wants the file handle to write to - 1 is stdout, 2 is stderr). Or you could display it one character at a time, watching for the terminating CR that int 21h/0Ah puts there...
mov si, tempx + 2
top:
lodsb
cmp al, 13
jz done
int 29h
jmp short top
done:
Pretty inefficient to call the OS for every character like that, though... The int 21h/40h is probably the most flexible...
Best,
Frank
-
tnx frank.. im gonna try this to my code.. omg, u are so smart! youre a wiz!