TITLE "Fibonacci numbers" SUBTITLE"Recursive Fibonacci function" ; activation record format RETAD = 0 I = 4 J = 8 K = 12 ARSIZE = 16 ; expect R1 = return address ; uses R2 = stack pointer for activation records ; expect R3 = i, the parameter ; return R3 = fib(i) ; use R4-... FIB: STORES R1,R2 ; save return addr STORE R3,R2,I ; save parameter i ; ---------- begin body ---------- LOAD R3,R2,I CMPI R3,1 BGTU ELSE ; if (i <= 1) { ; ------- then clause ------- BR ENDIF ; } else { ELSE: ; ------- else clause ------- ENDIF: ; } ; ---------- end body ------------ LOADS R1,R2 JUMPS R1 ; returns