I'm not able to write a syscall in X86 ASM for Linux. I'm reading this "tutorial"
https://en.wikibooks.org/wiki/X86_Assembly/Interfacing_with_Linux
but i don't want to use the "hello world" in the .rodata section: i want to create it in the stack and then using it with the syscall. In C language it should be written as
#include <unistd.h>
int main() {
char string[12] = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '\0'};
write(1, string, 11);
return 0;
}
I'm not able to write it in ASM using int 0x80. Any suggestion?
I've tried it but the code is a mess. Here is my code:
.intel_syntax noprefix
.section .text
.global _start
_start:
push 4
pop rax
xor ebx,ebx
inc ebx # ebx = 1 = stdout
mov DWORD PTR [rsp-0x4],0x646c72
mov DWORD PTR [rsp-0x8],0x6f57206f
mov DWORD PTR [rsp-0xc],0x6c6c6548
sub rsp, 0xc
xor rcx,rcx
mov rcx, rsp
push 11
pop rdx
int 0x80
xor eax,eax
inc eax
xor ebx,ebx
int 0x80
Is this a good way to do it? Is there a better way?