updated the fizzbuzz example
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
; Outputs first 100 FizzBuzz numbers
|
||||
; Created by Luxferre in 2025, released into public domain
|
||||
|
||||
set 1 0 50 ; store constant 1 into loc 50
|
||||
set 100 0 51 ; store constant 100 into loc 51
|
||||
set 3 0 3 ; store constant 3 into loc 3
|
||||
set 5 0 5 ; store constant 5 into loc 5
|
||||
@@ -16,20 +15,20 @@ set 1 0 1 ; counter in loc 1
|
||||
:lp mdf 1 3 2 ; loop start; store counter mod 3 into loc 2
|
||||
mdf 1 5 4 ; store counter mod 5 into loc 4
|
||||
set 1 0 10 ; set normal output flag to loc 10
|
||||
jmp 5 2 :bu ; jump next if not divisible by 3
|
||||
jne 2 :bu ; jump next if not divisible by 3
|
||||
out 60 61 1 ; output Fizz sequence
|
||||
out 64 64 1
|
||||
out 64 64 1
|
||||
set 0 0 10 ; unset normal output flag
|
||||
:bu jmp 5 4 :no ; jump next if not divisible by 5
|
||||
:bu jne 4 :no ; jump next if not divisible by 5
|
||||
out 62 63 1 ; output Buzz sequence
|
||||
out 64 64 1
|
||||
out 64 64 1
|
||||
set 0 0 10 ; unset normal output flag
|
||||
:no jmp 0 10 :n ; jump next if normal output flag is off
|
||||
:no jeq 10 :n ; jump next if normal output flag is off
|
||||
out 1 1 0 ; normal counter output
|
||||
jmp 6 0 :le ; jump to the end of the loop
|
||||
juc :le ; jump to the end of the loop
|
||||
:n out 65 65 1 ; output a newline
|
||||
:le fma 50 50 1 ; increment the counter
|
||||
:le inc 1 ; increment the counter
|
||||
sub 1 51 6 ; save the difference into loc 6
|
||||
jmp 4 6 :lp ; go back in the loop if not every number is displayed yet
|
||||
jle 6 :lp ; go back in the loop if not every number is displayed yet
|
||||
|
||||
Reference in New Issue
Block a user