99 Bottles of Beer/Assembly: Difference between revisions

Content added Content deleted
Line 727: Line 727:


===x86_64 (GAS)===
===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.
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.
<lang>// Compiles with `gcc -nostdlib`
<lang>// Compiles with `gcc -nostdlib`
#define SYS_EXIT $60
#define SYS_EXIT $60
Line 886: Line 886:
counter:
counter:
.quad START_BOTTLES
.quad START_BOTTLES
numstring0:
buffer:
.byte 'x /* Separated out because want back of string */
.ascii "xxx" /* Separated out because want back of string */
numstring:
numstring:
.byte 'x
.byte 'x