Hacker's Edge Game Guide: Programming/Getting started with cc65

Getting started with cc65
March 31, 2018

In this article I will explain how to get started with programming in either C or Assembly with Hacker's Edge. While Hacker's Edge used to have a custom 6502 assembler available in-game, beta players found this custom implementation very limiting, and so now it is possible to use the cc65 toolchain to assemble or even compile programs written in C. cc65 is available for all major operating systems. Here is a list of what you are going to need to follow this guide:

Start by downloading the cc65 compiler for your OS, either in a prebuilt binary form, or in source form. You can follow the directions here to get started: cc65 getting started

Once you have cc65 all ready to go, either download the Hacker's Edge development kit in ZIP format from bitbucket, or clone the repository to your local machine. Currently, it is easier to go into the HackerOS directory and use the Makefile there. If you do not have make available, you can always run the ca65/cc65/ld65 programs from a custom script or batch file. In fact, I will explain how to assemble a simple program using ca65 and ld65 here:

.export _main

.include "kernel.inc"


    .byte "Hello from Assembly!", $a,$0


_main: lda #hello
           jsr _print

Save this file into HackerOS as hello.s, then run the following:

ca65 he-bin.s
ca65 hello.s
ld65 -C ../cfg/he-bin.cfg -o hello.bin hello.o he-bin.o

Now you can upload the generated binary image hello.bin to the game server by making an FTP connection to ftp.hackers-edge.com on port 2121. The resulting binary image should run in HackerOS, just be sure to link in he-bin.o, or it won't have the proper headers and such to run. Happy coding!