Permalink
Browse files

Factorial with print-to-screen

  • Loading branch information...
suranyami committed Apr 24, 2012
1 parent 53ae2ce commit 57c0f40f44874ee0404911698c7918fd743f8e98
Showing with 21 additions and 0 deletions.
  1. +21 −0 factorial.dasm16
View
@@ -0,0 +1,21 @@
+ SET A, 5 ; Number to factorial
+ SET B, 0 ; Result
+ SET B, A
+:loop SUB A, 1
+ IFE A, 0
+ SET PC, print
+ MUL B, A
+ SET PC, loop
+:print SET A, 0xF2B0 ; current char, starting at 0
+ SET C, 0 ; Character position
+ SET Y, B
+:print_char SHL Y, 4
+ SET I, o
+ ADD I, A
+ SET [0x8000+C], I
+ ADD C, 1
+ IFE Y, 0
+ SET PC, halt
+ SET PC, print_char
+:halt SET PC, halt
+

0 comments on commit 57c0f40

Please sign in to comment.