I'm learning Assembly, and it would be nice for me to be able to output a number to the screen instead of just a string of text. I know how to print a character using mov eax, 1
, but that doesn't work with DWords.
I am using 64-bit Ubuntu.
Makefile:
all:
nasm -f elf64 asm.s -o asm.o
ld asm.o -o asm
rm asm.o
One easy way to print stuff would be just using printf
, you're asking how to print a dword, that's easy:
extern _printf
SECTION .data
msg: db "Printing a dword: %d",10,0
number: dd 123456789
SECTION .text
global start
start:
push dword [number]
push dword msg
call _printf
add esp, 8
mov eax, 0
ret