updated the fizzbuzz example

This commit is contained in:
Luxferre
2025-04-30 12:58:10 +03:00
parent 03a9a72d6e
commit d4a107cd32
2 changed files with 34 additions and 36 deletions
+28 -29
View File
@@ -1,31 +1,30 @@
1 5 1 0 50 1 5 100 0 51
2 5 100 0 51 2 5 3 0 3
3 5 3 0 3 3 5 5 0 5
4 5 5 0 5 4 5 70 0 60
5 5 70 0 60 5 5 105 0 61
6 5 105 0 61 6 5 66 0 62
7 5 66 0 62 7 5 117 0 63
8 5 117 0 63 8 5 122 0 64
9 5 122 0 64 9 5 10 0 65
10 5 10 0 65 10 5 1 0 1
11 5 1 0 1 11 10 1 3 2
12 10 1 3 2 12 10 1 5 4
13 10 1 5 4 13 5 1 0 10
14 5 1 0 10 14 1 5 2 19
15 1 5 2 20 15 3 60 61 1
16 3 60 61 1 16 3 64 64 1
17 3 64 64 1 17 3 64 64 1
18 3 64 64 1 18 5 0 0 10
19 5 0 0 10 19 1 5 4 24
20 1 5 4 25 20 3 62 63 1
21 3 62 63 1 21 3 64 64 1
22 3 64 64 1 22 3 64 64 1
23 3 64 64 1 23 5 0 0 10
24 5 0 0 10 24 1 0 10 27
25 1 0 10 28 25 3 1 1 0
26 3 1 1 0 26 1 6 0 28
27 1 6 0 29 27 3 65 65 1
28 3 65 65 1 28 7 127 127 1
29 7 50 50 1 29 8 1 51 6
30 8 1 51 6 30 1 4 6 11
31 1 4 6 12
+6 -7
View File
@@ -2,7 +2,6 @@
; Outputs first 100 FizzBuzz numbers ; Outputs first 100 FizzBuzz numbers
; Created by Luxferre in 2025, released into public domain ; 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 100 0 51 ; store constant 100 into loc 51
set 3 0 3 ; store constant 3 into loc 3 set 3 0 3 ; store constant 3 into loc 3
set 5 0 5 ; store constant 5 into loc 5 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 :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 mdf 1 5 4 ; store counter mod 5 into loc 4
set 1 0 10 ; set normal output flag to loc 10 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 60 61 1 ; output Fizz sequence
out 64 64 1 out 64 64 1
out 64 64 1 out 64 64 1
set 0 0 10 ; unset normal output flag 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 62 63 1 ; output Buzz sequence
out 64 64 1 out 64 64 1
out 64 64 1 out 64 64 1
set 0 0 10 ; unset normal output flag 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 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 :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 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