FACT: MOV R1, -(R6) ; save registers MOV R2, -(R6) MOV #3, R0 ; calculating address of parameter: ADD R6, R0 MOV@ R0, R1 ; parameter MOV# 2, R2 CMP R2, R1 ; if x >= 2, do the longer part below BGE RECURSE MOV# 1, R0 ; return value is 1 RET: MOV (R6)+, R2 ; restore MOV (R6)+, R1 ; restore RTS RECURSE: DEC R1 ; x-1 MOV R1, -(R6) ; push parameter for recursive call JSR FACT INC R6 ; un-push INC R1 ; get x back MUL R1, R0 ; R0 becomes x*fact(x-1) BR RET