Lately I've been learning x86 Assembly from the book Programming from the Ground Up, but I have an x86-64 computer, so things start to go wrong at one point (pretty early in the book). I got to the part where I'm dealing with functions, specifically the power example. In this example he pushes the parameters onto the stack and then copies them into registers later in the function. Here's what his code looks like:
pushl $3 # second argument pushl $2 # first argument call power # call function ... power: pushl %ebp # save old base pointer movl %esp, %ebp # make stack pointer the base pointer subl $4, %esp # get room for our local storage movl 8(%ebp), %ebx # put first argument in %eax movl 12(%ebp), %ecx # put second argument in %ecx Of course, this is 32-bit, and I'm running 64-bit, so I tried updating the registers and instruction suffixes to end up with something like this (comments shouldn't be needed this time):
pushq $3 pushq $2 call power ... power: pushq %rbp movq %rsp, %rbp subq $4, %rsp movq 8(%rbp), %rdi movq 12(%rbp), %rsi Given, I might just be confusing the actual registers I'm supposed to use, but I'm not completely sure. All I know is that when I print the value of %rdi in the GNU Debugger after the command movq 8(%rbp), %rdi it seems to me as if it has the memory address rather than the contents of it considering I get the following:
(gdb) i r rdi rdi 0x400081 4194433 Also, is there something like a forum for Assembly hobbyists? I've done some basic searching but haven't managed to find one (except for a forum for x86 assembly that just has one post and it's a welcome post, http://www.x86-assembly.org/).
Thanks!
movq 8(%rbp), %rditomovq 16(rbp)(same thing with the next line) and you could use the registers for arguments, it is required for syscalls to use the x86-64-abi.