home | articles | links | fun | about
Up to: Quick math and science observations

idea of a function call and registers. memory is memory... stack is just a region. sp - stack pointer -- pointer to region of memory to write variables. stack just a place to put variables.

idea of secret agent -- take info, do operations, return. return everything in precise way you got it.

how do you know how much to change the stack pointer? hardcoded?

leaf procedures easy... nested ones tough.

how to preserve input registers and return addr?

one way: push all regs that must be saved on stack. callER pushes things it needs on stack (argument regs, temp vars) callEE pushes return addr and saved regs (s0-s7) sp adjusted for number of regs on stack

on last leg of recursive function, don't need to load args or return addr... just jump. the values didn't change, that's why :). no other calls, so $ra didn't change. go through this.