I know it's a slightly old Thread, but thanks for posting the STARTUP files.
after i (mostly) got CC65 to work i wanted to try out the WDC C Compiler for the 65816, so this was perfect!
maybe it's because i now have experience from setting up CC65 but i found it somewhat straight forward to getting the compiler to work.
with some exceptions of course...
for example WDC's included STDINT.H is... kinda broken, and it took me a lot of cryptic compiler errors before i figured out why.
it doesn't define uint8_t or int8_t (only the 16 and 32 bit types) and even then uint32_t and int32_t don't actually work because SIZEOF_LONG is aparently never declared so the 32 bit types are never defined either.
i had to heavily modify the file to allow for anything besides uint16_t and int16_t to be usable. (though it does mean the file now assumes that char = 1 byte, int = 2 bytes, and long = 4 bytes)
other than that all i did to get it up and running was:
modify the STARTUP file to fit the hardware i want. (renamed from STARTUP.ASM to crt0.s to be more consistent with CC65 and Interrupt routines are kept in a seprate file)
the only directly C related symbol in crt0.s is MAIN, which has a different name depending on the Memory Model, i just choose large (main is therefore ~~MAIN) because it has the fewest memory restrictions.
after that i was able to start writing C and just had to fiddle around with the Linker for a while. here the complete commands i used to compile, and link everything:
Code: Select all
WDC816AS -O Config\crt0.o Config\crt0.s
WDC816AS -O Config\interrupt.o Config\interrupt.s
WDC816CC -SOP -ML -O Temp\test.o test.c
WDCLN -T -HB -C10000,0 -D20000, -O test.bin Config\crt0.o Config\interrupt.o Temp\test.o
(CODE gets loaded and runs in Bank 1, Data gets loaded with CODE but then gets copied to Bank 2)
one thing i did to make sure the crt0.s code will be put at the very start of the output file (because it contains the header i need) is removing the "STARTUP SECTION OFFSET $xxxx" line, which then automatically placed it into the CODE Segment, then when linking i just made it be the first input file in the command (it seems to link from left to right like CC65)
though i got it to output some code i don't know if it will actually work as i currently have no 65816 Computer.
another thing, how exactly does the compiler use the Direct page? does it move it around whenever it needs more than 256 DP Locations, so do i need to keep track of that when handling interrupts? and how do i tell the linker to reserve some specific bank 0 addresses for myself so it doesn't overwrite them with other vairables?
and one last thing, sorry for kinda hijacking the thread but i have not been able to figure this out in either CC65 or WDC816CC...
what do you have to do in C to get the compiler to declare a symbol with a specific value and then export it?
like this:
Code: Select all
; WDC:
TEST_SYM EQU $69
XDEF TEST_SYM
; CC65:
TEST_SYM = $69
.export TEST_SYM
i tried using extern like this:
but all that does is generate a Label named "TEST_SYM" that points to the value, instead of being set to it:
which is completely different from what i try to achieve.
any tips?