Discuss Scratch

StackMasher
Scratcher
100+ posts

Why does my program not print anything (assembly/linux)

I'm trying to write a hello world program using linux system calls but nothing appears in the terminal (this is in nasm syntax btw)
section .data
str: db 11, 'Hello World'

section .text
global _start
_start:
; Print Hello World
mov eax, 1
mov rdi, 1
lea rsi, [str + 1]
mov rdx, [str]
syscall

; Exit
mov eax, 60
mov rdi, 0
syscall
StackMasher
Scratcher
100+ posts

Why does my program not print anything (assembly/linux)

It was because I loaded 8 bytes into rdx when I should have only loaded a byte
section .data
str: db 11, 'Hello World'

section .text
global _start
_start:
; Print Hello World
mov eax, 1
mov rdi, 1
lea rsi, [str + 1]
xor rdx, rdx ; here
mov dl, byte [str]
syscall

; Exit
mov eax, 60
mov rdi, 0
syscall
Works now

Powered by DjangoBB

Standard | Mobile