Author Topic: jne symbol 'exit' undefined  (Read 9800 times)

Offline Lera

  • Jr. Member
  • *
  • Posts: 2
jne symbol 'exit' undefined
« 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

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: jne symbol 'exit' undefined
« Reply #1 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



Offline Lera

  • Jr. Member
  • *
  • Posts: 2
Re: jne symbol 'exit' undefined
« Reply #2 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.
« Last Edit: December 14, 2018, 02:42:46 AM by Lera »