CPSC 355 Lecture Notes - Lecture 24: Block Code, Local Variable, Call Stack

102 views4 pages

Document Summary

Cpsc 355 - lecture 24 nov 8th. Leaf subroutines do not call any other subroutines: i. e. are leaf nodes on a structure diagram. Eg: optimized cube function cube: mul mul ret w9, w0, w0 w0, w9, w0. Arguments beyond the 8th are passed on the stack: the calling code allocates memory at the top of the stack, and writes the (cid:862)spilled(cid:863) argu(cid:373)e(cid:374)t (cid:448)alues there. By convention, each argument is allocated 8 bytes: the callee reads this memory using the appropriate offset. // function prototype int sum(int a1, int 2, int 3, . , int a10); int main( ) { register int result; result = su(cid:373)(cid:894)(cid:1005)(cid:1004), (cid:1006)(cid:1004), (cid:1007)(cid:1004), , (cid:1005)(cid:1004)(cid:1004)(cid:895); // 2 extra arguments (8 + 2) = 10 args. // 16 just for the frame record x29, x30, [sp, -16]! retur(cid:374) a(cid:1005) + a(cid:1006) + a(cid:1007) + + a(cid:1005)(cid:1004); spilled_mem_size = 16 global main mov w29, sp.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents