Task

Write a program that prints the integers from   1   to   100   (inclusive).



But:

   for multiples of three,   print   Fizz     (instead of the number)
   for multiples of five,   print   Buzz     (instead of the number)
   for multiples of both three and five,   print   FizzBuzz     (instead of the number) 


The   FizzBuzz   problem was presented as the lowest level of comprehension required to illustrate adequacy.



Also see

   (a blog)   dont-overthink-fizzbuzz
   (a blog)   fizzbuzz-the-programmers-stairway-to-heaven


t   IS $255
Ja  IS $127
 
       LOC Data_Segment
data   GREG   @
 
fizz   IS @-Data_Segment
       BYTE "Fizz",0,0,0,0
 
buzz   IS @-Data_Segment
       BYTE "Buzz",0,0,0,0
 
nl     IS @-Data_Segment
       BYTE #a,0,0,0,0,0,0,0
 
buffer IS @-Data_Segment
 
 
 
       LOC #1000
       GREG @

% "usual" print integer subroutine
printnum LOC @
       OR   $1,$0,0
       SETL $2,buffer+64
       ADDU $2,$2,data
       XOR  $3,$3,$3
       STBU $3,$2,1
loop   DIV  $1,$1,10
       GET  $3,rR
       ADDU $3,$3,'0'
       STBU $3,$2,0
       SUBU $2,$2,1
       PBNZ $1,loop
       ADDU t,$2,1
       TRAP 0,Fputs,StdOut
       GO   Ja,Ja,0
 
Main   SETL $0,1           % i = 1
1H     SETL $2,0           % fizz not taken
       CMP  $1,$0,100      % i <= 100
       BP   $1,4F          % if no, go to end
       DIV  $1,$0,3
       GET  $1,rR          % $1 = mod(i,3)
       CSZ  $2,$1,1        % $2 = Fizz taken?
       BNZ  $1,2F          % $1 != 0? yes, then skip
       ADDU t,data,fizz
       TRAP 0,Fputs,StdOut % print "Fizz"
2H     DIV  $1,$0,5
       GET  $1,rR          % $1 = mod(i,5)
       BNZ  $1,3F          % $1 != 0? yes, then skip
       ADDU t,data,buzz
       TRAP 0,Fputs,StdOut % print "Buzz"
       JMP  5F             % skip print i
3H     BP   $2,5F          % skip if Fizz was taken
       GO   Ja,printnum    % print i
5H     ADDU t,data,nl
       TRAP 0,Fputs,StdOut % print newline
       ADDU $0,$0,1
       JMP  1B             % repeat for next i
4H     XOR  t,t,t
       TRAP 0,Halt,0       % exit(0)