I'm using SASM editor for assembler. And I use PRINT_DEC from "io.inc" library to print. And here is the problem:
%include "io.inc"
section .text
global main
main:
mov eax, 0
mov ah, 1
PRINT_DEC 2, ah
xor eax, eax
ret
The ah register is 1 byte, but I print 2 bytes of it, it works ok, but I want to understand where does the extra byte get from
And when I put number 1 in al register like this:
main:
mov eax, 0
mov al, 1
mov ah, 1
PRINT_DEC 2, ah
xor eax, eax
ret
It prints 1 again. So the extra byte is not reading from al (the right byte of ah)
Then I tried to put number 1 in 16th bit of eax (left byte of ah) like this:
main:
mov eax, 0x100000
mov ah, 1
PRINT_DEC 2, ah
xor eax, eax
ret
It prints the number 1 again, the extra byte is not from left side either.
So the question is, where is that extra byte printing from.
P.S. It is my university homework, so I need to know exact answer with explanation :)