Greetings. I am getting my feet wet with programming a 6502 in C. I have looked at some of the sample programs, but most of the resources online are trying to target an NES (including its GPU and "mappers"). I would like to break it down even more simply, just a simple bare bones 6502 processor with $FFFF bytes of RAM attached and a single memory mapped hardware register at $5000. This is all in simulation land so there's no risk if I screw anything up.
Anyway, my C code looks like this:
Code:
#include <stdint.h>
#define UART_REG 0x5000
#define REG_DATA(x) ((volatile uint8_t*)(x))[0]
void main (void)
{
REG_DATA(UART_REG) = 'H';
REG_DATA(UART_REG) = 'e';
REG_DATA(UART_REG) = 'l';
REG_DATA(UART_REG) = 'l';
REG_DATA(UART_REG) = 'o';
while(1){};
}
So modifying the Makefile in the "samples" directory to use "sim6502" as the target, These commands were executed:
Code:
$ make
../bin/cc65 -Ors --codesize 500 -T -g -t sim6502 hello.c
../bin/ca65 hello.s
../bin/ld65 -o hello -t sim6502 -m hello.map hello.o sim6502.lib
This worked in the sense that I got an assembler file, mapper file, and raw hex file. However, when I look at the raw hex file, There are only $CF bytes. If I understand the architecture correctly, there needs to be a reset vector placed at $FFFC and $FFFD in order for the processor to jump to the correct start routine.
What steps do I need to do in order to make the appropriate jump into my C program? Ideally, I would like to output a raw hex file that contains $FFFF bytes, so I can easily load the values into my simulated RAM.
Thanks!