tail recursive factorial
(define (fact n r)
(if (eq? n 0) r (fact (- n 1) (* n r))))
fact: cmp arg1, #0
jump.ne next
load val, arg2
rts
next: mul arg2, arg1
sub arg1, #1
jump fact
Previous slide
Next slide
Back to first slide
View graphic version