talks

Log | Files | Refs

commit 63f9bea765da7b25ca12d14cb4e30b9f2fab06df
parent 5bb82b0d0d6e7769bfbddeac3b7ad89728d9f856
Author: dwrz <dwrz@dwrz.net>
Date:   Fri, 13 Nov 2020 17:14:52 +0000

Document x86 assembly examples

Diffstat:
Mx86-assembly/src/exit/exit.s | 4++++
Mx86-assembly/src/func/func.s | 10++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/x86-assembly/src/exit/exit.s b/x86-assembly/src/exit/exit.s @@ -3,10 +3,14 @@ _start: # Store system call 1 in the EAX register. + # mov = instruction + # $1, %eax = operands + # %eax = register mov $1, %eax # Store the exit code 0 in the EBX register. mov $0, %ebx # Call interrupt handler 0x80 (128) -- on Linux, this is the kernel. + # Kernel will take over and see 1 in %eax, 0 in %ebx. int $0x80 diff --git a/x86-assembly/src/func/func.s b/x86-assembly/src/func/func.s @@ -29,3 +29,13 @@ square: pop %rbp # ret pops and return to address on stack. ret + +# |----------------+-----------+----------------| +# | Address | Data | Stack Pointers | +# |----------------+-----------+----------------| +# | 0x7fffffffe8f8 | | | +# | 0x7fffffffe900 | 0x0 (rbp) | | +# | 0x7fffffffe908 | 0x401002 | | +# | 0x7fffffffe910 | 3 | ←rsp | +# |----------------+-----------+----------------| +# ←rbp