0

This code using nasm doesn't show nothing in a Linux terminal, previously I code another "hello world" example and these works and shows the text in terminal.

the code is for x86 (32 bits):

section .data
result db '0'

section .text
   global _start

_start:
mov eax, 2
mov ebx, 3

add eax, ebx

add eax, 48
mov [result], eax

mov eax, 4
mov eax, 1
mov ecx, result
mov edx, 1

int 0x80

mov eax, 1
mov ebx, 0
int 0x80

the commands:

nasm -f elf addsub.asm
ld -m elf_i386 -o addsub addsub.o

From a 64 bits machine (Intel), OS System is Debian. Compiling and linking doesn't return an error.

reymagnus
  • 137
  • 1
  • 14
  • `mov eax, 4` / `mov eax, 1`. Oops, that 2nd one was supposed to be EBX to set an output FD. If you use `strace ./a.out` or single-step with a debugger, you'll see you just made an `_exit` system call, because that's what EAX=1 / `int 0x80` does. – Peter Cordes Apr 02 '22 at 02:59

0 Answers0