Skip to content

Instantly share code, notes, and snippets.

@gitpraetorianlabs
Created June 1, 2016 22:25
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/b34407e557ef5e0bbb7a7963835dca00 to your computer and use it in GitHub Desktop.
Save gitpraetorianlabs/b34407e557ef5e0bbb7a7963835dca00 to your computer and use it in GitHub Desktop.
=-------------------------------=
| [0x4003b0] |
| main: | // Disassembling the main() function
| (fcn) sym.main 68 |
| addiu sp, sp, -0x28 | // Adjust stack by 40 bytes
| sw ra, 0x24(sp) | // Return address is saved onto the Stack
| sw fp, 0x20(sp) | // Frame pointer is saved onto the Stack
| move fp, sp | // Move stack pointer to the frame pointer
| sw zero, 0x18(fp) | // Initialize int a to 0
| addiu v0, zero, 0x41 | // Add 0x41 to zero and store the result into $v0
| sw v0, 0x1c(fp) | // Initialize int b to 0x41
| lw a0, 0x18(fp) | // Load value of int a into $a0
| lw a1, 0x1c(fp) | // Load value of int b into $a1
| jal sym.pass_args_to_me ;[a] | // Jump and Link to the pass_args_to_me Function (RA = PC + 8)
| nop | // No instructions to execute when calling pass_args_to_me
| move sp, fp | // Move the frame pointer to the stack pointer register
| lw ra, 0x24(sp) | // Restore the previously saved Return Address
| lw fp, 0x20(sp) | // Restore the previously saved Frame Pointer address
| addiu sp, sp, 0x28 | // Adjust the offset by 40 bytes since we are leaving the function
| jr ra | // Jump to the address loaded in to $ra (return address register)
| nop | // No instruction to execute when jumping to the address in $ra
=-------------------------------=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment