Hardware is built and has some code running. (only 1 hardware error so far...no pull-up on BE pin)
Here is some feedback on the compiler.
With no UART or screen/keyboard the only hello world is via a LED connected to to a register that controls memory bank switching.
The register is at 0xBF00, in assembler the code to write to this register would be
lda #192
sta $BF00
In the WDC Tools W65C02S C COMPILER/OPTIMIZER USER GUIDE, page 35, under Referencing I/O there are some examples of doing this in C, but the target appears to be the W65C816S.
In C one could do something like this,
volatile unsigned char *reg1_write = (unsigned char *)0xBF00;
*reg1_write = 0x80;
I ran into trouble with the make file, specifically this line when linking
WDCLN -cE000 -d300 -sz -hi -g -t -o main.hex STARTUP02.obj main.obj -lc
The -cE000 tells the linker where to place the CODE in ROM
The -d300 tells the linker where to place the DATA in RAM/ROM
See WDC Tools W65C02S C COMPILER/OPTIMIZER USER GUIDE, page 13, Creating A ROM Program
Also ASSEMBLER/LINKER/LIBRARIAN user manual, page 35
for more details
The resulting Intel HEX file looks like this, (I've cut it back to safe space)
:0603000000D800FF00BF61
:18E000002018E000000000AD04038568AD05038569A98092684C07E056
...
:18FF4800390538F020A906853CA903853DA900A898913CE63CD002E6AD
:18FF60003DA538D004C6393004C63880EB2000E00000FFFFFFFFFFFF05
...
:10FFF000FFFFFFFFFFFFFFFFFFFF000000FF00000C
:00000001FF
The first line is the problem. These constants (and my BF00) should be in ROM from where the startup code will copy them to RAM. (not at 0300)
It took me a while to get my head around this. I even switched to using assembler just to get my first lines of code running. I inlined the above to assembler lines in the C program.
The linker line should look like this.
WDCLN -cE000 -d300, -sz -hi -g -t -o main.hex STARTUP02.obj main.obj -lc
Notice just the coma has been added. The manuals explain this (well) and though I've read it a hundred times I don't get the feeling that I missing something.
With the modified linker line the HEX file now looks like this,
:18E000002018E000000000AD04038568AD05038569A98092684C07E056
...
:18E0F000A0070878B13C9930008810F828A0018A6C300000D800FF00E5
:01E10800BF57
:18FF0000D8A2FF9AA9008532A9028533A9068538A90085390538F029EA
...
:18FFD800FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF29
:10FFF000FFFFFFFFFFFFFFFFFFFF000000FF00000C
:00000001FF
now my BF00 is in the light location, following the CODE section.
Something else that I had to compensate for, notice that the HEX file address is at E000 which is correct.
But when loading this HEX file into the programmer it loads at E000 and onward. I don't want it there. I want it at 0000.
Fortunately the programmer (TL-8662-plus) has an option to relocate the file a specified start address.
It may(or not) be possible to do this from the linker line above. I was unable get it to work.
For interest the C code
*reg1_write = 0x80;
translates to
43 00
44 00:000A: 85 68 sta <104
45 00:000C: AD xx xx lda _reg1_write+1
46 00:000F: 85 69 sta <105
47 00
48 00
If I was going to use a structure like this to initialize a 6551 for example then some inline assembler like
lda #192
sta $BF00
would be more efficient.
It's been a very long time since I've used an "EPROM" programmer and it's the first time I'm bringing up a 6502 so if I've missed anything please fell free to correct or add.
Next step is a 6551 UART....how would we survive without a UART for debugging...and software downloads. (Oh yes....It's called an ISP)
Regards
Andre