[컴퓨터구조] 3. Arithmetic for Computers (1)
Example 6 main: li $s0, 0x06 li $s1, 0x10 move $a0, $s0 // $s0에서 $a0로 move move $a1, $s1 jal sum nop move $s3, $v0 // Get the result move $a0, $s3 // Print the sum li $v0, 1 syscall li $v0, 1 // Exit syscall sum: add $t1m $a0, $a1 move $v0, $t1 jr $ra // Return to the main function nop Memory Layout Stack: automatic storage Dynamic data: heap Static data: global variable Text: program code Jump ..
2023. 10. 9.
[CA] Lecture #10
Leaf Procedure Example // C code int leaf_example (int g, int h, int i, int j){ int f; f = (g+h) - (i+j); return f; } // g~j: x10~x13, f: x20 // temporaries x5, x6: g+h = x5, t+j = x6 Memory - stack 저장: x5, x6, x20 caller --> collee --> caller --> stack에 저장: collee에 의해 사용되어 값이 변하는 것만 저장한다. Local Data on the Stack // Assembly code leaf_example: addi sp, sp, -12 // stack에 12 byte 공간 확보 sw x5, 8(sp..
2023. 9. 28.