Hello!
I have just started learning assembly language, and I have decided to use the NASM assembler.
I made a small program, included below, that is supposed to take a number, add 5, and print out the final result. The program correctly prints the prompt, and takes a value, but then crashes. NASM makes no warning or error messages.
I would appreciate any help!
-tundra010
The code:
; This program is supposed to get a number, add 5 to it, and print out the final number.
[section .data]
prompt: db 'Enter a number: ',0
fmt: db '%d',0
[section .text]
global _main
extern _printf
extern _scanf
_main:
; Display message
push prompt
call _printf
add esp,4
; Get input
push dword[ecx]
push fmt
call _scanf
add esp,8
; Add 5 to ecx
mov ecx,5
; Print final value of ecx
push dword[ecx]
call _printf
add esp,4
; End program
mov eax,0
ret