Skip to content

Instantly share code, notes, and snippets.

@gitpraetorianlabs
Created June 1, 2016 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gitpraetorianlabs/558242368c626f20562585b17612ef67 to your computer and use it in GitHub Desktop.
Save gitpraetorianlabs/558242368c626f20562585b17612ef67 to your computer and use it in GitHub Desktop.
=------------------------=
| [0x4003b0] |
| main: | // Start in Main but is called by the libc constructor
| (fcn) sym.main 68 |
| addiu sp, sp, -0x28 |
| sw ra, 0x24(sp) | // Saved Return Address
| sw fp, 0x20(sp) |
| move fp, sp |
| sw zero, 0x18(fp) |
| addiu v0, zero, 1 |
| sw v0, 0x1c(fp) |
| lw a0, 0x18(fp) |
| lw a1, 0x1c(fp) |
| jal sym.call_one ;[a] | // Call (Jump and Link) the function call_one
| nop |
| move sp, fp |
| lw ra, 0x24(sp) |
| lw fp, 0x20(sp) |
| addiu sp, sp, 0x28 |
| jr ra |
| nop |
=------------------------=
|
|
V
=------------------------=
| [0x4003f4] |
| (fcn) sym.call_one 68 | // Function call_one
| addiu sp, sp, -0x20 |
| sw ra, 0x1c(sp) | // Saved Return Address so we can jump back to main()
| sw fp, 0x18(sp) |
| move fp, sp |
| sw a0, 0x20(fp) |
| sw a1, 0x24(fp) |
| jal sym.call_two ;[a] | // Call (Jump and Link) the function call_two
| nop |
| lw v1, 0x20(fp) |
| lw v0, 0x24(fp) |
| addu v0, v1, v0 |
| move sp, fp |
| lw ra, 0x1c(sp) |
| lw fp, 0x18(sp) |
| addiu sp, sp, 0x20 |
| jr ra |
| nop |
=------------------------=
|
|
V
=-----------------------=
| [0x400438] |
| (fcn) sym.call_two 36 | // Function call_two
| addiu sp, sp, -8 |
| sw fp, 4(sp) |
| move fp, sp |
| addiu v0, zero, 1 |
| move sp, fp |
| lw fp, 4(sp) |
| addiu sp, sp, 8 |
| jr ra | // Since call_two does not call any other functions there is no need to save the return address onto the stack.
| nop |
=-----------------------=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment