NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: Lera on December 13, 2018, 09:06:56 AM

Title: jne symbol 'exit' undefined
Post 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:

Quote
hellplayingwithstacks.asm:7: error: symbol `exit' undefined

The code:

Code: [Select]
global _start

section .text

_start:
mov rax, 1
call incRax
cmp rax, 2
jne exit
;;
;; Do something
;;

incRax:
inc rax
ret
Title: Re: jne symbol 'exit' undefined
Post by: Frank Kotler on December 14, 2018, 12:26:21 AM
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:

Code: [Select]
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


Title: Re: jne symbol 'exit' undefined
Post by: Lera on December 14, 2018, 02:39:16 AM
Obvious! (facepalm)

But, i have this problem.

Quote
Segmentation fault (core dumped)

Edit

Solved. I have forgotten syscall.