Hacker's Edge Game Guide: Programming/Using the 6502 Assembler

Using the 6502 Assembler
Aug. 3, 2016

The 6502 Assembler included in-game within Hacker's Edge is a bit different than other 6502 Assemblers roaming the Internet. The 6502 Assembler in Hacker's Edge supports relocatable code and other features and directives not found in other popular 6502 Assemblers.

Your program should always end with a BRK operation, which will call the kernel routine to return you back to your shell program. Although BRK is $00 in memory, you can never be sure that the area where your program loaded into was filled with $00 before your code was loaded in. Without a BRK, your program will continue to run operations past your program's end point in memory and may cause some unexpected behavior!

Special Directives

Anything that begins with a period is classified as an assembler directive, here is a list of the publicly available ones at the moment:

.DATA.DATAEnds the code segment and begins the data segment.
.OUT.OUT KERNEL.SYSEnforces the name of the output binary image.
.TYP.TYP RAWSpecifies a binary type to generate, currently only RAW is supported, if left out, it uses the default relocatable type.


Labels come in two different types, relative ones used in branching statement, and ones which support relocation. Relocating labels cannot be used when pointing to a value in your data segment, relocating @ labels can only be used with JSR and JMP operations. However, you can create these labels anywhere in your code segment and use LDA #>@label or #<@label to refer to the high and low bytes of the pointing address respectively.

Inserting RAW data

Inserting RAW data into your binary is required for your data segment, or if you are creating a custom binary type. Here are the statements you can use to insert RAW data bytes and words into your output binary.

DCBDCB $40,$50,$8c,$00Inserts RAW bytes into your output binary.
DCWDCW $a350,@labelInserts RAW 16-bit words into your output binary, supports absolute labels.
DCSDCS Hello World!\n\0Inserts a string along with newlines and/or nulls into your output binary.