; Example program for non-void function call with 1 parameter ; ; Peter Strazdins, April 2008 macro Push (e) ; push value of e onto stack ; (use before calling proc. with value parameters) load e ; (AC = ) incsp #1 ; (SP = SP + 1; done last in case e=!num) store !0 ; (Memory[SP] = AC) endmacro macro Pop (n) ; pop n elements of the stack ; (use at end of proc. call or end of proc body) incsp #-n ; (SP = SP - n) endmacro ; #include external Log10 ; ; int main () { log: block 1 ; int log; main: ; ; log = Log10( 511 ); incsp #1 ; /* SP=SP+1 */ /* make RV slot */ Push (#511) ; /* AC=511; SP=SP+1; Mem[SP]=AC */ call Log10 ; /* SP=SP+1; Mem[SP]=PC; PC=Log10 */ Pop (1) ; /* SP=SP-1 */ load !0 ; /* AC=Mem[SP] */ /*store RV*/ store log ; /* Mem[Log]=AC */ incsp #-1 ; /* SP=SP-1 */ /*pop RV slot*/ ; trap #1 ; return 0; end main ; }