Mercurial > hg > Applications > Tokio
view Examples/6502/a.s65 @ 4:f864bb4ba9a4 default tip
update tags
author | convert-repo |
---|---|
date | Fri, 07 Nov 2008 20:36:52 +0000 |
parents | cfb7c6b24319 |
children |
line wrap: on
line source
;; ;; ackerman function ;; procedure name ACK ;; ACK(X,Y) ;; == if X=0 then Y+1 ;; else if Y=0 then ACK(X-1,1) ;; else ACK(X-1, ACK(X,Y-1)) ;; calling sequence ;; ;; X on x ;; Y on y ;; non compile 11.86 sec on Sun 140 ;; compile 7.54 sec on Sun 140 start cld ldx #1 ldy #1 jsr ack brk ack cpx #0 bne xneqzero xeqzero iny tya rts xneqzero cpy #0 bne yneqzero dex ;; x <- x-1 yeqzero ldy #1 jmp ack ;; tail recursion yneqzero txa pha dey ;; y <- y-1 jsr ack ;; ack x,y-1 tay pla tax dex ;; x <- x-1 jmp ack ;; tail recursion end ;;