FizzBuzz/Assembly: Difference between revisions
m
Fixed syntax highlighting and duplicate headers.
Not a robot (talk | contribs) (Add ARM Assembly) |
m (Fixed syntax highlighting and duplicate headers.) |
||
(One intermediate revision by one other user not shown) | |||
Line 1:
{{collection|FizzBuzz}}
==
<syntaxhighlight lang="asm">FIZZBUZZ CSECT A SECTION OF CODE STARTS HERE, LABEL IT FIZZBUZZ
**********HOUSE KEEPING AREA**********************
USING *,12 FOR THIS PROGRAM WE ARE GOING TO USE REGISTER 12
Line 87:
**********HOUSE KEEPING AREA**********************
SAVE DS 18F
END HELLO </
==
The modulus operation is rather expensive on the 6502,
so a simple counter solution was chosen.
<syntaxhighlight lang="asm"> .lf fzbz6502.lst
.cr 6502
.tf fzbz6502.obj,ap1
Line 171:
Buzz .da #0
;------------------------------------------------------
.en </
==
This implementation uses two counters instead of divisions for the moduli.
<
; FizzBuzz for Motorola 68000 under AmigaOs 2+ by Thorham
;
Line 271:
buzz
dc.b "Buzz",0</
==
<syntaxhighlight lang="asm">;; CP/M FizzBuzz in 8080 assembly
bdos: equ 5 ; CP/M calls
Line 337:
buzz: db 'Buzz$'
num: db '000$'
nl: db 13, 10, '$'</
==
Assembly programs that output a number on the screen are programmable in two ways: calculating the number in binary to convert it next in ASCII for output,
or keeping the number in Binary Coded Decimal (BCD) notation
Line 371:
is a multiple of five, so the number is never displayed,
because it is replaced by the string "buzz".
<
mov dx,03030h ; For easier printing, the number is
;kept in Binary Coded Decimal, in
Line 458:
buzz: ;The "buzz" string.
db "buzz"</
==
For the Amstrad CPC (should work with e.g. the built-in assembler in JavaCPC; use <tt>call &4000</tt> to start from BASIC):
<
wr_char equ &bb5a ; write ASCII character in register A to screen
cursor equ &bb78 ; get cursor position
Line 644 ⟶ 580:
buzz:
db "Buzz"</
|