Why am I unable to print my number constant in NASM Assembly?
Learning NASM Assembly in 32-bit Ubuntu. I am somewhat confused:
In .bss, I reserve a byte for a variable:
num resb 1
Later I decided to give it a value of 5:
mov byte [num],5
And at some point print it out:
mov EAX,4
mov EBX,0
mov ECX,num
add ECX,'0' ; From decimal to ASCII
mov EDX,1
int 0x80
But it isn't printing anything.
I'm guessing that the problem is when I give num its value of 5. I
originally wanted to do this:
mov byte num,5
As I thought that num refers to a position in memory, and so mov would
copy 5 to such position. But I got an error saying
invalid combination of opcode and operands
So basically, why is the program not printing 5? And also, why was my
suggestion above invalid?
No comments:
Post a Comment