SLAU131V October 2004 – February 2020
fact .macro N,loc
.if N < 2
MOV #1,&loc
.else
MOV #N,&loc
.eval N-1,N
fact1
.endif
.endm
fact1 .macro
.if N > 1
MOV #N,R12 ; Assume MPY requires args to be in R12,R13
MOV &loc,R13
CALL MPY
MOV R12,&loc ; Assume MPY returns product in R12
.eval N - 1,N
fact1
.endif
.endm
.global fact_result
.global MPY
fact 5,fact_result