Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .text:00400660 # =============== S U B R O U T I N E =======================================
- .text:00400660
- .text:00400660
- .text:00400660 .globl c_function1
- .text:00400660 c_function1: # CODE XREF: main+28p
- .text:00400660
- .text:00400660 old_fp_offset = -8
- .text:00400660 old_ra_offset = -4
- .text:00400660
- .text:00400660 000 addiu $sp, -0x18 # Allocate 0x18 bytes on the stack
- .text:00400664 018 sw $ra, 0x18+old_ra_offset($sp) # push the value from $ra (return address) to the stack
- .text:00400668 018 sw $fp, 0x18+old_fp_offset($sp) # push the value of $fp (frame pointer) to the stack
- .text:0040066C 018 move $fp, $sp # set $fp = $sp
- .text:00400670 018 lui $v0, 0x40 # Load 0x40 as the MSB in $v0
- .text:00400674 018 addiu $a0, $v0, (aInsideC_functi - 0x400000) # Load the offset to the "Inside c_function1" string into $a0
- .text:00400678 018 lui $v0, 0x40 # Load 0x40 as the MSB in $v0
- .text:0040067C 018 addiu $t9, $v0, (_puts - 0x400000) # Load the offset to puts in $t9
- .text:00400680 018 jalr $t9 ; _puts # call puts($a0)
- .text:00400684 018 nop
- .text:00400688 018 li $v0, 5 # $v0 = 5 (to be returned)
- .text:0040068C 018 move $sp, $fp # Restore $sp (stack pointer) from $fp (frame pointer)
- .text:00400690 018 lw $ra, 0x18+old_ra_offset($sp) # pop the return address ($ra)
- .text:00400694 018 lw $fp, 0x18+old_fp_offset($sp) # pop the old frame pointer ($fp)
- .text:00400698 018 addiu $sp, 0x18 # Move the stack pointer back (free memory)
- .text:0040069C 000 jr $ra # ret (return from function call)
- .text:004006A0 000 nop
- .text:004006A0 # End of function c_function1
- .text:004006A0
- .text:004006A4
- .text:004006A4 # =============== S U B R O U T I N E =======================================
- .text:004006A4
- .text:004006A4
- .text:004006A4 .globl c_function2
- .text:004006A4 c_function2: # CODE XREF: main+3Cp
- .text:004006A4
- .text:004006A4 old_fp_offset = -8
- .text:004006A4 old_ra_offset = -4
- .text:004006A4 arg_0_offset = 0
- .text:004006A4
- .text:004006A4 000 addiu $sp, -0x18 # Allocate 0x18 bytes on the stack
- .text:004006A8 018 sw $ra, 0x18+old_ra_offset($sp) # Push the value of the return address on the stack ($ra)
- .text:004006AC 018 sw $fp, 0x18+old_fp_offset($sp) # Push the value of the frame pointer on the stack ($fp)
- .text:004006B0 018 move $fp, $sp # Initialize the new frame pointer ($fp = $sp)
- .text:004006B4 018 sw $a0, 0x18+arg_0_offset($fp) # Store the 1st argument ($a0) to the stack (so that it doesn't get lost)
- .text:004006B8 018 lui $v0, 0x40 # Load Upper Immediate
- .text:004006BC 018 addiu $a0, $v0, (aInsideC_func_0 - 0x400000) # Prepare $a0 with the address of the "Inside c_function2" string
- .text:004006C0 018 lw $a1, 0x18+arg_0_offset($fp) # Load arg0 from the stack as $a1 for the next function call
- .text:004006C4 018 lui $v0, 0x40 # Load Upper Immediate
- .text:004006C8 018 addiu $t9, $v0, (_printf - 0x400000) # Prepare the address of printf
- .text:004006CC 018 jalr $t9 ; _printf # call printf($a0, $a1)
- .text:004006D0 018 nop
- .text:004006D4 018 move $sp, $fp # $sp = $fp
- .text:004006D8 018 lw $ra, 0x18+old_ra_offset($sp) # pop return address from the stack ($ra)
- .text:004006DC 018 lw $fp, 0x18+old_fp_offset($sp) # pop old frame pointer from the stack ($fp)
- .text:004006E0 018 addiu $sp, 0x18 # Free 0x18 bytes of stack
- .text:004006E4 000 jr $ra # ret - return from procedure call
- .text:004006E8 000 nop
- .text:004006E8 # End of function c_function2
- .text:004006E8
- .text:004006EC
- .text:004006EC # =============== S U B R O U T I N E =======================================
- .text:004006EC
- .text:004006EC
- .text:004006EC .globl c_function3
- .text:004006EC c_function3: # CODE XREF: main+4Cp
- .text:004006EC
- .text:004006EC old_fp_offset = -8
- .text:004006EC old_ra_offset = -4
- .text:004006EC arg_0_offset = 0
- .text:004006EC arg_1_offset = 4
- .text:004006EC
- .text:004006EC 000 addiu $sp, -0x18 # Allocate 0x18 bytes on the stack
- .text:004006F0 018 sw $ra, 0x18+old_ra_offset($sp) # Push the value of the return address on the stack ($ra)
- .text:004006F4 018 sw $fp, 0x18+old_fp_offset($sp) # Push the value of the frame pointer on the stack ($fp)
- .text:004006F8 018 move $fp, $sp # Initialize the new frame pointer ($fp = $sp)
- .text:004006FC 018 sw $a0, 0x18+arg_0_offset($fp) # Store the 1st argument ($a0) to the stack (so that it doesn't get lost)
- .text:00400700 018 sw $a1, 0x18+arg_1_offset($fp) # Store the 2nd argument ($a1) to the stack (so that it doesn't get lost)
- .text:00400704 018 lui $v0, 0x40 # Load Upper Immediate
- .text:00400708 018 addiu $a0, $v0, (aInsideC_func_1 - 0x400000) # Prepare $a0 with the address of "Inside c_function3"
- .text:0040070C 018 lw $a1, 0x18+arg_0_offset($fp) # Save $a1 = arg_0
- .text:00400710 018 lw $a2, 0x18+arg_1_offset($fp) # Save $a2 = arg_1
- .text:00400714 018 lui $v0, 0x40 # Load Upper Immediate
- .text:00400718 018 addiu $t9, $v0, (_printf - 0x400000) # Get the address of printf
- .text:0040071C 018 jalr $t9 ; _printf # Call printf($a0, $a1, $a2)
- .text:00400720 018 nop
- .text:00400724 018 lw $v1, 0x18+arg_0_offset($fp) # $v1 = arg_0 (from stack)
- .text:00400728 018 lw $v0, 0x18+arg_1_offset($fp) # $v0 = arg_1
- .text:0040072C 018 addu $v0, $v1, $v0 # $v0 = $v1 + $v0
- .text:00400730 018 move $sp, $fp # $sp = $fp
- .text:00400734 018 lw $ra, 0x18+old_ra_offset($sp) # pop $ra
- .text:00400738 018 lw $fp, 0x18+old_fp_offset($sp) # pop $fp
- .text:0040073C 018 addiu $sp, 0x18 # free 0x18 bytes of stack
- .text:00400740 000 jr $ra # ret - return from procedure call
- .text:00400744 000 nop
- .text:00400744 # End of function c_function3
- .text:00400744
- .text:00400748
- .text:00400748 # =============== S U B R O U T I N E =======================================
- .text:00400748
- .text:00400748
- .text:00400748 .globl c_function4
- .text:00400748 c_function4: # CODE XREF: main+70p
- .text:00400748
- .text:00400748 arg_3_converted_offset= -0x10
- .text:00400748 old_fp_offset = -8
- .text:00400748 old_ra_offset = -4
- .text:00400748 arg_0_offset = 0
- .text:00400748 arg_1_offset = 4
- .text:00400748 arg_2_offset = 8
- .text:00400748 arg_3_offset = 0xC
- .text:00400748
- .text:00400748 000 addiu $sp, -0x20 # Allocate 0x20 bytes on the stack
- .text:0040074C 020 sw $ra, 0x20+old_ra_offset($sp) # Push the value of the return address on the stack ($ra)
- .text:00400750 020 sw $fp, 0x20+old_fp_offset($sp) # Push the value of the frame pointer on the stack ($fp)
- .text:00400754 020 move $fp, $sp # Initialize the new frame pointer ($fp = $sp)
- .text:00400758 020 sw $a0, 0x20+arg_0_offset($fp) # Store the 1st argument ($a0) to the stack (so that it doesn't get lost)
- .text:0040075C 020 sw $a1, 0x20+arg_1_offset($fp) # Store the 2nd argument ($a1) to the stack (so that it doesn't get lost)
- .text:00400760 020 move $v0, $a2 # $v0 = $a2
- .text:00400764 020 sw $a3, 0x20+arg_3_offset($fp) # Store the 4th argument ($a3) to the stack (so that it doesn't get lost)
- .text:00400768 020 sb $v0, 0x20+arg_2_offset($fp) # Store the 3rd argument ($a3 -> $v0) into the stack as a byte
- .text:0040076C 020 lb $v1, 0x20+arg_2_offset($fp) # Load $arg_3 into $v1
- .text:00400770 020 lwc1 $f0, 0x20+arg_3_offset($fp) # Load arg_3 as a floating point into $f0
- .text:00400774 020 cvt.d.s $f0, $f0 # Floating-point Convert to Double Floating-Point Format
- .text:00400778 020 sdc1 $f0, 0x20+arg_3_converted_offset($sp) # Store Double FPU
- .text:0040077C 020 lui $v0, 0x40 # Load Upper Immediate
- .text:00400780 020 addiu $a0, $v0, (aInsideC_func_2 - 0x400000) # Put the address of "Inside c_function4" in $a0
- .text:00400784 020 lw $a1, 0x20+arg_0_offset($fp) # $a1 = arg_0
- .text:00400788 020 lw $a2, 0x20+arg_1_offset($fp) # $a2 = $arg_1
- .text:0040078C 020 move $a3, $v1 # $a3 = $v1
- .text:00400790 020 lui $v0, 0x40 # Load Upper Immediate
- .text:00400794 020 addiu $t9, $v0, (_printf - 0x400000) # Load $t9 with the address of printf
- .text:00400798 020 jalr $t9 ; _printf # call printf($a0, $a1, $a2, $a3 ...)
- .text:0040079C 020 nop
- .text:004007A0 020 lw $v1, 0x20+arg_0_offset($fp) # $v1 = arg_0
- .text:004007A4 020 lw $v0, 0x20+arg_1_offset($fp) # $v0 = $arg_1
- .text:004007A8 020 addu $v0, $v1, $v0 # $v0 = $v1 + $v0
- .text:004007AC 020 move $sp, $fp # $sp = $fp
- .text:004007B0 020 lw $ra, 0x20+old_ra_offset($sp) # pop $ra
- .text:004007B4 020 lw $fp, 0x20+old_fp_offset($sp) # pop $fp
- .text:004007B8 020 addiu $sp, 0x20 # free 0x20 bytes from the stack
- .text:004007BC 000 jr $ra # ret - return from procedure call
- .text:004007C0 000 nop
- .text:004007C0 # End of function c_function4
- .text:004007C0
- .text:004007C4
- .text:004007C4 # =============== S U B R O U T I N E =======================================
- .text:004007C4
- .text:004007C4
- .text:004007C4 .globl main
- .text:004007C4 main: # DATA XREF: _ftext+Co
- .text:004007C4
- .text:004007C4 result_offset = -0x10
- .text:004007C4 old_fp_offset = -8
- .text:004007C4 old_ra_offset = -4
- .text:004007C4
- .text:004007C4 000 addiu $sp, -0x20 # Allocate 0x20 bytes on the stack
- .text:004007C8 020 sw $ra, 0x20+old_ra_offset($sp) # push the value of the return address ($ra) on the stack
- .text:004007CC 020 sw $fp, 0x20+old_fp_offset($sp) # push the old frame pointer ($fp) to the stack
- .text:004007D0 020 move $fp, $sp # Allocate the new $fp
- .text:004007D4 020 lui $v0, 0x40 # Load Upper Immediate
- .text:004007D8 020 addiu $a0, $v0, (aMain___ - 0x400000) # prepare parameter 0 ("main...") in $a0
- .text:004007DC 020 lui $v0, 0x40 # Load Upper Immediate
- .text:004007E0 020 addiu $t9, $v0, (_puts - 0x400000) # Put the address of puts in a temporary register $t9
- .text:004007E4 020 jalr $t9 ; _puts # call puts($a0)
- .text:004007E8 020 nop
- .text:004007EC 020 jal c_function1 # call c_function1()
- .text:004007F0 020 nop
- .text:004007F4 020 li $v0, 0x58 # $v0 = 0x58 (int result=88);
- .text:004007F8 020 sw $v0, 0x20+result_offset($fp) # push $v0 to the stack (relative to $fp) for storage
- .text:004007FC 020 li $a0, 8 # $a0 = 8
- .text:00400800 020 jal c_function2 # call c_function2($a0)
- .text:00400804 020 nop
- .text:00400808 020 lw $a0, 0x20+result_offset($fp) # load result back from stack into $a0 as a parameter of next function call
- .text:0040080C 020 li $a1, 0xC # load second parameter $a1 = 12
- .text:00400810 020 jal c_function3 # call c_function3($a0, $a1)
- .text:00400814 020 nop
- .text:00400818 020 sw $v0, 0x20+result_offset($fp) # save the function result ($v0) back on the stack
- .text:0040081C 020 lui $v0, 0x40 # Load Upper Immediate
- .text:00400820 020 lwc1 $f0, float_314159 # Load 3.14159 as a float into the FPU
- .text:00400824 020 lw $a0, 0x20+result_offset($fp) # Load result from the stack into $a0 as a parameter for the next function
- .text:00400828 020 li $a1, 0x26 # Load 38 (0x26) as the second parameter for the function call
- .text:0040082C 020 li $a2, 0x4D # Load 0x4D (the ASCII code for the character M) as the 3rd parameter
- .text:00400830 020 mfc1 $a3, $f0 # Load the floating point number from $f0 to $a3 as the 4th argument
- .text:00400834 020 jal c_function4 # call (c_function4($a0, $a1, $a2, $a3))
- .text:00400838 020 nop
- .text:0040083C 020 sw $v0, 0x20+result_offset($fp) # Save the function result back on the stack as result
- .text:00400840 020 lui $v0, 0x40 # Load Upper Immediate
- .text:00400844 020 addiu $a0, $v0, (aFinalResultD - 0x400000) # Prepare the "Final result:" string
- .text:00400848 020 lw $a1, 0x20+result_offset($fp) # Copy the actual result as the second parameter
- .text:0040084C 020 lui $v0, 0x40 # Load Upper Immediate
- .text:00400850 020 addiu $t9, $v0, (_printf - 0x400000) # Put printf's address in $t9
- .text:00400854 020 jalr $t9 ; _printf # Call printf($a0, $a1)
- .text:00400858 020 nop
- .text:0040085C 020 move $v0, $zero # Ignore printf's return value and write zeros over it
- .text:00400860 020 move $sp, $fp # $sp = $fp
- .text:00400864 020 lw $ra, 0x20+old_ra_offset($sp) # Restore (pop) return address $ra
- .text:00400868 020 lw $fp, 0x20+old_fp_offset($sp) # Restore (pop) old frame pointer
- .text:0040086C 020 addiu $sp, 0x20 # Free 0x20 bytes of stack memory
- .text:00400870 000 jr $ra # ret (return from procedure call)
- .text:00400874 000 nop
- .text:00400874 # End of function main
- .text:00400874
- .text:00400874 # ---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement