added fizzbuzz example
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
; FizzBuzz classical challenge in MU8A for mu808 VM
|
||||
; 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
|
||||
set 70 0 60 ; store Fi into loc 60-61
|
||||
set 105 0 61
|
||||
set 66 0 62 ; store Buz + LF into loc 62-65
|
||||
set 117 0 63
|
||||
set 122 0 64
|
||||
set 10 0 65
|
||||
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
|
||||
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
|
||||
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
|
||||
out 1 1 0 ; normal counter output
|
||||
jmp 6 0 :le ; jump to the end of the loop
|
||||
:n out 65 65 1 ; output a newline
|
||||
:le fma 50 50 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
|
||||
Reference in New Issue
Block a user