FizzBuzz in 68k Assembly

Fizz buzz is a group word game for children to teach them about division. Players take turns to count incrementally, replacing any number divisible by three with the word “fizz”, and any number divisible by five with the word “buzz”.

	ORG	$1000
FIZZ	DC.B	'FIZZ',$0D,$0A,0
BUZZ	DC.B	'BUZZ',$0D,$0A,0
FBUZZ	DC.B	'FIZZBUZZ',$0D,$0A,0
CRLF	DC.B    $0D,$0A,0
 
START
	MOVEQ 	#0, D1		; Rolling value
	MOVEQ	#10, D2		; Set D2 with dec number 10
	BSR	LOOP		; Branch to loop
 
QUIT	MOVE.B  #9, D0		; Moves the dec number 9 into data register D0
        TRAP    #15		; Execute trap command in D0
 
DBUZZ	LEA     BUZZ, A1	; Load BUZZ address into address register A1
        MOVE.B  #14, D0		; Set trap command to display NULL terminated string in A1
        TRAP    #15		; Execute trap command 
	BRA	LOOP		; Branch to LOOP
 
DFIZZ	LEA     FIZZ, A1	; Load FIZZ address into address register A1
        MOVE.B  #14, D0		; Set trap command to display NULL terminated string in A1
        TRAP    #15		; Execute trap command 
	BRA	LOOP		; Branch to LOOP
 
DFBUZZ	LEA     FBUZZ, A1	; Load FBUZZ address into address register A1
        MOVE.B  #14, D0		; Set trap command to display NULL terminated string in A1
        TRAP    #15		; Execute trap command 
	BRA	LOOP		; Branch to LOOP
 
DVAL	MOVEQ	#15, D0		; Set trap command to display D1
	TRAP	#15		; Execute trap command
	LEA     CRLF, A1	; Load FBUZZ address into address register A1
        MOVE.B  #14, D0		; Set trap command to display NULL terminated string in A1
        TRAP    #15		; Execute trap command
	BRA	LOOP		; Branch to LOOP
 
LOOP	CMP	#100, D1	; Compare D1 to 100
   	BEQ	QUIT		; Equality in previous compare meets break condition
 
	ADDQ	#1, D1		; Increment loop	
	MOVE.L	D1, D3		; Store D1 to D3 for DIV
 
	DIVU	#15, D3		; D3 / 15
	SWAP	D3		; Swap D3 remainder byte	
	CMP	#0, D3		; Evaluate D3 for 0
	BEQ	DFBUZZ		; Run subroutine to display 'FIZZBUZZ'
 
	MOVE.L	D1, D3		; Store D1 to D3 for DIV
	DIVU	#3, D3		; D3 / 3
	SWAP	D3		; Swap D3 remainder byte	
	CMP	#0, D3		; Evaluate D3 for 0
	BEQ	DFIZZ		; Run subroutine to display 'FIZZ'
 
	MOVE.L	D1, D3		; Store D1 to D3 for DIV
	DIVU	#5, D3		; D3 / 5
	SWAP	D3		; Swap D3 remainder byte	
	CMP	#0, D3		; Evaluate D3 for 0
	BEQ	DBUZZ		; Run subroutine to display 'BUZZ'
 
	BRA	DVAL		; Other conditions not met, branch into DVAL
 
	END	START