Generating Code for Procedures no parameters - with local variables ------------------------------------------------------------------------ Since there is no parameter passing, we will have the callee do the work. Caller: jal _procedure_1_ (or some scheme to generate labels) Callee: _procedure_1_: sw $ra, ($sp) # store return address 1 1 sw $s2,-4($sp) # store old level 2 display 3 3 1 1 la $s2,($sp) # reset new level 2 display 3 3 addi $sp,-12 # increment by AR size If you have no local variables, the AR size is 8 bytes, one variable 12 bytes, two local variables then 16 bytes and so forth. Generate the code for whatever the subprogram does. Callee: to return addi $sp,12 (or 8 or 16 whatever the AR size) 1 1 lw $s2,-4($sp) # restore old level 2 disp. 3 3 lw $s4,($sp) # set return address jr $s4 ------------------------------------------------------------------------ Your addresses and then as before for globals variables from level1: -8($s1) for the first variable -12($s1) for the second variable (if exists) level2; -8($s2) for the first one and so on ...