ABIexp
ABIexp
.ORIG x3000
MAIN LD R6,STADDR
ADD R5,R6,#-1
;; Call SLSQR with N
LD R0,N ;; push the argument
ADD R6,R6,#-1
STR R0,R6,#0
JSR SLSQR
LDR R0,R6,#0 ;; pop the result
ADD R6,R6,#1
ADD R6,R6,#1 ;; pop and discard the argument
ST R0,NSQ
HALT
;; SillySquare routine
SLSQR ADD R6,R6,#-1 ;; "push" space for return
ADD R6,R6,#-1 ;; push R7
STR R7,R6,#0
ADD R6,R6,#-1 ;; push R5
STR R5,R6,#0
ADD R5,R6,#-1 ;; update R5 for new frame
;; SillySquare routine
SLSQR ADD R6,R6,#-1 ;; "push" space for return
ADD R6,R6,#-1 ;; push R7
STR R7,R6,#0
ADD R6,R6,#-1 ;; push R5
STR R5,R6,#0
ADD R5,R6,#-1 ;; update R5 for new frame
;; SillySqure(n) = SillySquare(n-1) + n + n - 1