uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 85e4383332eddaf9738a332ebc109808d699cd54
parent 42ade9e8c8d37c212675a5928a6029577a9c74c4
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Thu, 23 Feb 2023 19:04:34 -0800

(fizzbuzz.tal) Migrated to immediate opcodes

Diffstat:
Mprojects/examples/exercises/fizzbuzz.tal | 24+++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/projects/examples/exercises/fizzbuzz.tal b/projects/examples/exercises/fizzbuzz.tal @@ -1,24 +1,22 @@ -( FizzBuzz: +( FizzBuzz: A program that prints the integers from 1 to 100. for multiples of three, print "Fizz" for multiples of five, print "Buzz" for multiples of both three and five, print "FizzBuzz" ) -|0100 ( -> ) @reset - +|0100 ( -> ) #6400 &loop ( integer ) - DUPk ,print-dec JSR #2018 DEO + DUPk print-dec #2018 DEO ( fizzbuzz ) - DUP #03 ,mod JSR ,&no3 JCN ;s/fizz ,print-str JSR &no3 - DUP #05 ,mod JSR ,&no5 JCN ;s/buzz ,print-str JSR &no5 + DUP #03 mod ?&no3 ;dict/fizz print-str &no3 + DUP #05 mod ?&no5 ;dict/buzz print-str &no5 #0a18 DEO - INC GTHk ,&loop JCN + INC GTHk ?&loop POP2 ( halt ) #010f DEO - BRK @mod ( a b -- c ) @@ -26,17 +24,17 @@ BRK JMP2r @print-dec ( num -- ) - #0a DIV ,&emit JSR - #0a ,mod JSR - &emit + #0a DIV print-num + #0a DIVk MUL SUB +@print-num #30 ADD #18 DEO JMP2r @print-str ( addr* -- ) &while LDAk #18 DEO - INC2 LDAk ,&while JCN + INC2 LDAk ?&while POP2 JMP2r -@s &fizz "Fizz $1 &buzz "Buzz $1 +@dict &fizz "Fizz $1 &buzz "Buzz $1