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

Example program: hello.asm
Sept. 4, 2014
Last updated at July 27, 2016

Here is a more complex example which takes in user input, and checks what the user has typed and displaying a different string if they type in a specific name:

.INC kernel.inc
LDY #prompt
JSR %print
LDY #buffer
JSR %input
LDA $f1
STA $fb
STA $fd
LDA #buffer
STA $fa
LDA #kevin
STA $fc
JSR %strcmp
LDA $ff
BNE someone
LDY #hi
BRA sayit
someone:
LDY #wrong
sayit:
JSR %print
BRK

.DATA
prompt:
DCS What is your name? \0
kevin:
DCS Kevin\0
hi:
DCS Hello Master!\n\0
wrong:
DCS You aren't my master!\n\0
buffer:
DCB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00

This example is fairly long and has many new concepts when compared to the previous example programs. This example shows how you can use memory to store user input and later check it.