1

Can anyone please tell me what am I doing wrong? I am running ubuntu sub operating system, is it something to do with that? Here's my code:

section .data
section .text
    global _start
_start:
    mov eax, 1
    mov ebx, 0
    int 80h

And here is how I assemble it:

nasm -f elf64 -o exit.o exit.s

ld exit.o -o exit

It shows:

Segmentation fault (core dumped)
Pythenx
  • 72
  • 6
  • AFAIK linux uses syscall instead of int80 on 64 bit. Either way, it'd be easier and (somewhat more) portable if you'd call `exit` instead. – tkausl Feb 02 '20 at 12:57
  • While that is 32 bit code, it should work. Maybe your ubuntu is without 32 bit compatibility support (unlikely). – Jester Feb 02 '20 at 12:57
  • 3
    *sub operating system,* sounds like you're describing Windows with WSL. It's like Linux without CONFIG_IA32_EMULATION so it doesn't support the 32-bit `int 0x80` ABI. – Peter Cordes Feb 02 '20 at 13:07

0 Answers0