I have a number stored in dl, and I need this to work for numbers up to three digits? Here is the working code for digits 0-9.
WriteNumber:
;; print out number in dl
push ax
push dx
add dl,"0"
mov ah,02h ; printing one char
int 21h
pop dx
pop ax
ret
For example, f开发者_开发技巧or two digits. I could take dl/10. And then print out the result and the rest as to different chars. But I got an error, because the number needs to be in AX register for the DIV.
I need to do this:
mov ax,dl
But that won't work?
I don't think you'll be able to do
mov ax,dl
since ax and dl are different sizes. You should be able to do
mov ax, dx
or from GJ:
movzx ax, dl
And then just reference dl and al if you want just the last byte.
I need to do this:
mov ax,dl
But that won't work?
mov
will work if the registers have the same size, both 8bit or 16bit or 32bit.
Example:
mov EAX, EDX
; or
mov AX, DX
; or
mov AL, DL
精彩评论