This repository has been archived on 2024-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
microgentambly/examples/fizzbuzz.mga

51 lines
513 B
Plaintext
Raw Normal View History

2021-09-29 20:29:13 +02:00
#Fizzbuzz
INT n
INT i
INT nfizz
INT nbuzz
INT modfizz
INT modbuzz
SET n 0
SET nfizz 3
SET nbuzz 5
SET modfizz 0
SET modbuzz 0
SET i 0
IN INT n How many?\n
:loop
OUT \n
MOD i nfizz modfizz
JE fizzdo modfizz 0
:fizzdone
MOD i nbuzz modbuzz
JE buzzdo modbuzz 0
:buzzdone
INC i 1
JE loop modbuzz 0
JE loop modfizz 0
DEC i 1
OUT $i$
INC i 1
JL loop i n
OUT \n
END
:fizzdo
OUT fizz
JMP fizzdone
:buzzdo
OUT buzz
JMP buzzdone