NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: Lera on December 13, 2018, 09:06:56 AM
-
I'm learning assembly on this website:
https://0xax.github.io/asm_3/
At the hour of learning about "stack", I have this error when compiling:
hellplayingwithstacks.asm:7: error: symbol `exit' undefined
The code:
global _start
section .text
_start:
mov rax, 1
call incRax
cmp rax, 2
jne exit
;;
;; Do something
;;
incRax:
inc rax
ret
-
Hi Lera,
Welcome to the Forum.
The problem (of course) is that "exit" isn't defined anywhere. This is a problem in the example you're following. He does this all over the place! Probably supposed to be something like this:
global _start
section .text
_start:
mov rax, 1
call incRax
cmp rax, 2
jne exit
;;
;; Do something
;;
exit: ; the missing label
mov rax, 60 ; sys_exit number
; mov rdi, 0 ; exit code - zero usually indicates no error
mov rdi, -1 ; exit code - if this happens something is badly wrong!
syscall
incRax:
inc rax
ret
Lemme see if I can find Ray Toal's tutorial. You might have better luck with it.
http://cs.lmu.edu/~ray/notes/nasmtutorial/
Best,
Frank
-
Obvious! (facepalm)
But, i have this problem.
Segmentation fault (core dumped)
Edit
Solved. I have forgotten syscall.