flat assembler
Message board for the users of flat assembler.

Index > Linux > stack-problem with amd64

Author
Thread Post new topic Reply to topic
Spinne



Joined: 17 Apr 2006
Posts: 2
Location: Germany
Spinne 17 Apr 2006, 10:32
Hello.
When I wrote 32-bit programs, it was no problem to print characters from the stack on the screen. I simply pushed the characters and called sys_write with ecx=esp (the address of the characters) ... and it worked.
But now I'm trying to do so in a 64-bit programm. But unfortunately it doesn't work. Here is a simple code for demonstrating my problem:
Code:
format ELF64 executable
segment writeable readable executable
entry $
 mov rax,0x4141414141414141 ; 'AAAAAAAA'
 push rax
 mov rax,4
 mov rbx,1
 mov rcx,rsp
 mov rdx,1
 int 0x80
 pop rax

 mov rax,1
 int 0x80    

The same program in 32-bit worked fine, but nothing happens now. I hope you can help me seeing my mistake.
Post 17 Apr 2006, 10:32
View user's profile Send private message Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 215
Location: Budapest, Hungary
Endre 20 Apr 2006, 09:13
1. If you have 32bit kernel then you have to use the legacy 32 bit system calls across int 0x80 and 32bit registers.
2. If you have 64bit kernel then you have to use the new system call technique which is no longer based on int 0x80 but on instructions syscall, sysret. This means that system calls are no longer interrupt but call-gates.
Post 20 Apr 2006, 09:13
View user's profile Send private message Reply with quote
Spinne



Joined: 17 Apr 2006
Posts: 2
Location: Germany
Spinne 01 May 2006, 11:26
Yes, I'm using a 64bit kernel. And with syscall it works. Thank you.
Post 01 May 2006, 11:26
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.