99 Bottles of Beer/Assembly: Difference between revisions
m
Sigh, still not right!
Puppydrum64 (talk | contribs) |
m (Sigh, still not right!) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 4:
{{collection|99 Bottles of Beer}} [[implementation of task::99 Bottles of Beer| ]]
[[99 Bottles of Beer]] done in any of the assembler-languages.
<!-- still missing:
Line 15 ⟶ 11:
__toc__
==
For maximum compatibility, this program uses only the basic instruction set.
<
BOTTLES CSECT
USING BOTTLES,R12
Line 66 ⟶ 62:
DC H'0' must be binary zeroes
YREGS
END BOTTLES</
>
{{out}}
<pre style="height:20ex">
Line 96 ⟶ 93:
</pre>
==
IMPORTANT NOTE: This assembly language solution is targeted at the Apple 1.
Line 107 ⟶ 104:
and cannot be "fixed" due to non-compliance, only deleted.
<
.TF AP1BEER.O,AP1
.LF AP1BEER.LST
Line 263 ⟶ 260:
:4E 44 20 42 55 59 20 53 4F 4D 45 20 4D
:4F 52 45 2C 8D
BEER</
==
<
.tf beer6800.obj,AP1
.lf beer6800
Line 423 ⟶ 420:
e0FB0 74 68 65 20 73 74 6F 72 65 20 61 6E 64 20 62 75
e0FC0 79 20 73 6F 6D 65 20 6D 6F 72 65 2C A0
j0F00</
▲=={{header|68000 Assembly}}==
The following is a Sega Genesis cartridge that can be assembled and run on the Fusion emulator. Press the A button to advance to the next part of the song. The game freezes when finished. Thanks to Keith S. of Chibiakumas for the cartridge header and print routines.
<
;Ram Variables
Cursor_X equ $00FF0000 ;Ram for Cursor Xpos
Line 913 ⟶ 911:
DC.B $80 ;23 DMA source address high (C=CMD) CCHHHHHH
VDPSettingsEnd:
even</
==
<
;; 99 bottles of beer, in 8080 assembly ;;
;; Written to run under CP/M ;;
Line 1,019 ⟶ 1,017:
sstore: db 'Go to the store and buy some more,',13,10,0
</syntaxhighlight>
==
<!-- printf missing ? --->
<syntaxhighlight lang="arm_assembly">
.global main
Line 1,056 ⟶ 1,054:
.ascii "No more bottles of beer on the wall, no more bottles of beer.\n"
.ascii "Go to the store and buy some more, 99 bottles of beer on the wall\n\000"
</syntaxhighlight>
==
<
; This is not strictly LLVM, as it uses the C library function "printf".
Line 1,128 ⟶ 1,126:
break:
ret i32 0
}</
<!-- missing here:
==
-->
==
The following example demonstrates the use of pointer variables (the argument <tt>,^#</tt> to the <tt>&VERSE#</tt> method), and therefore may not be as efficient as one which does not use pointer variables.
<
; Beer program with OASYS assembler.
Line 1,153 ⟶ 1,151:
['QUIT]
GQ
</syntaxhighlight>
==
====Using Windows/MASM32====
<
.model flat, stdcall
option casemap :none
Line 1,200 ⟶ 1,198:
INVOKE StdOut, offset str4
INVOKE ExitProcess, 0
end start</
====using DOS/BIOS====
<
[bits 16]
DrinkBeer:
Line 1,285 ⟶ 1,283:
.dataBeerSong3: db 0, " bottles of beer on the wall", 0
</syntaxhighlight>
====Implemented in the nasm preprocessor====
<
section .data
Line 1,319 ⟶ 1,317:
mov ebx, 0
mov eax, 1
int 0x80</
====x86_64 (GAS)====
Could maybe have done it all with macros, but I wanted to write my own itoa function. Plus I feel like using the preprocessor for its looping directives takes the challenge out of the problem. To extend to larger numbers, all you have to do is increase the size of the buffer and modify START_BOTTLES.
<syntaxhighlight lang="asm">// Compiles with `gcc -nostdlib`
#define SYS_EXIT $60
#define SYS_WRITE $1
Line 1,491 ⟶ 1,489:
regstring3:
.ascii " bottles of beer on the wall.\n\n"
</syntaxhighlight>
==
For Sinclair ZX Spectrum.
<
start:
Line 1,565 ⟶ 1,563:
line1: defb ' bottles of beer on the wall,',13,'$'
line2_3: defb ' bottles of beer,',13,'Take one down, pass it around,',13,'$'
line4: defb ' bottles of beer on the wall.',13,13,'$'</
|