Hacker's Edge Game Guide: Programming/Example program: echo.asm

Example program: echo.asm
Sept. 4, 2014
Last updated at June 29, 2016

Here is an example program which takes an argument from the command-line and just echoes it back to the terminal:

LDA $f4
CMP #2
BEQ showstring
 LDA ($f5),Y ; Load byte from [data+Y] offset into A.
 CMP #$00 ; Compare A to a null(0x00)
 BEQ done ; If A == null, branch to done.
 STA $ffd0 ; Store A in memory at address 0xffd0
 INY ; Increment Y
 BNE showstring ; If A != null, branch to loop.
done: ; Done label
LDA #$a
STA $ffd0

This example will be available on the in-game examples server, which you can then copy the source to your host and compile it yourself.