Because you've specified 1024 as the length which means the read
syscall is getting two bytes, the 31h
representing the character '1'
, and the 0ah
representing the newline.
If you only want one character, only ask for one character, not 1024.
And, if you try to get the full width into rbx
, ensure you clear out the upper bits afterwards, something like:
mov rbx, [num]
and rbx, 0ffh
Although a better solution is probably just to load up a byte with zero extension:
movzx rbx, byte [num]