I'm having some problems figuring out how to program in x86_64 assembly. None of the classes I've taken on assembly have ever trained me on modern assembly programming, and I figured it would make me reach satori, so I would like to learn it. I found this code online, and I was trying to get it to work on my ubuntu system.
9.
_start:
10.
mov eax, 4 ; write to file
11.
mov ebx, 1 ; STDOUT handle
12.
mov ecx, hello ; our message
13.
mov edx, length ; size of message
14.
int 80h ; execute the syscall
15.
16.
xor ebx, ebx ; send 0 as 'exit code'
17.
mov eax, 1 ; terminate process
18.
int 80h ; execute the syscall
When I was linking the object code it gave me an error about how it isn't compatible with my architecture. What is so different about i386 and i386_64 programming?
Name:
Anonymous2010-04-04 21:46
Or does it have entirely to do with the linker? When I inject i386_64 it gives me a weird bug and does not go any further. Something about nonreferenced memory locations.
Name:
Anonymous2010-04-04 22:09
Is my question that stupid?
Name:
Anonymous2010-04-04 22:21
>>3
/prog/ consists of like, 3 people at a time. Be patient.
When I was linking the object code it gave me an error about how it isn't compatible with my architecture.
Then you're assembler or linker is set to the wrong architecture, or your trying to mix in libraries from a different arch. Don't do that.
What is so different about i386 and i386_64 programming?
See >>6.
OP, what you have is x86 assembly. If you're on an x86, do this: $ nasm -f elf -o dicks.o dicks.s
$ ld -o dicks dicks.o
If you're on x86_64, do this:
change your assignments to eax to 4 and 60, resp. $ sed -i 's/e\(..\)/r\1/g; s/int 80h/syscall/' dicks.s
$ nasm -f elf64 -o dicks.o dicks.s
$ ld -o dicks dicks.o