Page 1 of 4
WDC02CC Compiler
Posted: Wed May 06, 2020 8:42 am
by BitWise
I've been trying to get a simple application to compile using WDC's 6502 compiler and have come to the conclusion that its currently impossible with the free version of the tools (WDC Tools 2.1).
The issues are:
1. The compiler crashes if you use a conditional expression e.g. (this == that) ? 7 : 11. You can rewrite code to avoid these.
2. A configuration file used to define the page zero locations used by the runtime routines looks like it should support some conditional selection based on processor type (65C02/65C134) but it doesn't. You have to comment out the addresses for processor you aren't using.
3. WDC should have provided a template startup assembler module that kicks off the main function (commonly called crt0.o in UNIX). You have to hand craft one but this needs some knowledge not in the C or assembler manual.
4. The C library provided seems to contains internal runtime support routines compiled for the 65C02 but standard C library functions compiled for the 65C134. They expect the runtime variables on page zero to be in different places.
Sadly there is no work around for this last one. The free compiler doesn't come with source so you can't rebuild the libraries and runtime to match.
There is also a bug in the assembler (3.49.1) which stops expression evaluation when it hits a space, Like this:
Code: Select all
106 00:0012: 85 58 sta CNT + 1
107 00:0014: 05 58 ora CNT + 0
No spaces and it gets it right.
Code: Select all
106 00:0012: 85 59 sta CNT+1
107 00:0014: 05 58 ora CNT+0
I'm working with WDC to try and get things going again.
Re: WDC02CC Compiler
Posted: Wed May 06, 2020 6:30 pm
by BitWise
It just occurred to me that the 65C02 library is broken but what about the 65C134 one? Well that seems to have internal and library functions that expect the same addresses so after tweaking the compiler configuration and rebuilding I have an application that uses the library's printf to output "hello world" via the routines I coded to interface to my system's BIOS I/O entry points.
There is something odd about the 65C134 library, its 109K compared to the 65C02 one at a mere 51K. I shall investigate further.
So for the time being it seems that if you pretend your 65C02 is actually a 65C134 and you can use WDC02CC to build a C application for it.
Re: WDC02CC Compiler
Posted: Thu May 07, 2020 11:54 am
by 8BIT
That's good news Andrew.
I actually bought their TIDE system about 8 years ago. I spent 3 months emailing back and forth with them as nothing seemed to work right. Menu options that did nothing, getting errors trying to compile even a 1 line source, and absolutely terrible documentation. I finally gave up and asked for a refund. They begrudgingly agreed - which went against their policy of no refunds, but even they could not figure out why it didn't work right for me.
I have stuck with CC65 since then. Your work around for supporting the 65C02 looks promising. I will keep watching your progress.
Thanks for posting your findings.
Daryl
Re: WDC02CC Compiler
Posted: Sun May 24, 2020 10:45 pm
by BitWise
I'm working with WDC to help fix the 65C02 C compiler.
I've found and fixed the bug that caused the crash when compiling ternary expressions and am currently working some changes to the code generation to make it easier to control where runtime variables are stored without having to have custom library builds.
I'm going to add some headers for standard devices like the 65C21, 65C22 and 65C51 as well as the peripherals on the 65C134. I want to publish some examples for the various SXB boards as well as my own minimal 65C02 system -- Not sure what the examples will be yet.
I have much to do -- It's going to take a while.
Re: WDC02CC Compiler
Posted: Sat Jun 13, 2020 1:34 am
by Irishjourno
That's great that they are investing in updating the compiler: I just bought Parallels to run WDC's tool chain, and quickly ran into the wall with TIDE. I wish they'd hire a good technical writer for six months to rewrite and beef up their documentation too! Examples for the SXB board would great: I think a lot of people would find them very appealing of the core of their own retro-style computers, but the details are a little opaque!
Re: WDC02CC Compiler
Posted: Sun Apr 18, 2021 1:03 pm
by tokafondo
Sorry for resurrecting such an old thread, but as the other one about the WDC compiler that I opened was going the route of trying to get WDC02CC working, I jumped here.
I found this document:
http://www.micetek.com/tw/pdf/sld_6502_eng.pdf
And from page 138 (counted from the start of the PDF file) onwards, there are some instructions on how to get WDC Compiler working.
Code: Select all
Sample Projects
Provided in EP6502\SAMPLES\WDC sub-directory.
• Prime sub-directory (C Sample for V5.0 only)
Run the following:
a) WDC02AS -g -s -l t0.asm
b) WDC02CC -bs prime1.c
c) WDC02CC -bs prime2.c
d) WDC02CC -bs prime3.c
e) WDCLN -cC000 -d0280 -sn -hi -g -t -o prime.hext0.obj prime1.obj prime2.obj prime3.obj -lc -lm
It seems there is a t0.asm file that could be studied. There are actually several of those files. I'm including the whole WDC folder referenced,
- wdc.zip
- (27.22 KiB) Downloaded 123 times
, so you can study them in the case they could be of help.
Re: WDC02CC Compiler
Posted: Sun Apr 18, 2021 1:25 pm
by Dr Jefyll
the other one about the WDC compiler that I opened
( That other thread is
here. )
Re: WDC02CC Compiler
Posted: Sun Apr 18, 2021 2:13 pm
by tokafondo
the other one about the WDC compiler that I opened
( That other thread is
here. )
Yeah, I mean... The last posts in that thread were about how to get the WDC compiler working. So I found this thread about that subject so I thought it could be interesting to stop
there and continue
here.
Re: WDC02CC Compiler
Posted: Mon Apr 19, 2021 10:29 am
by tokafondo
I saw that there is
zpage.inc file that
t0.asm expects to be present when compiling.
It's part of the WDC Tools package. I'm attaching anyway.
Re: WDC02CC Compiler
Posted: Mon Apr 19, 2021 11:27 am
by Agumander
A configuration file used to define the page zero locations used by the runtime routines looks like it should support some conditional selection based on processor type (65C02/65C134) but it doesn't. You have to comment out the addresses for processor you aren't using.
I'd skimmed this thread before but was focused on reverse engineering the loader asm to think to try this. Commenting out the second set of register defs in wdc02cc.cfg got my program to work perfectly.
It seems there is a t0.asm file that could be studied. There are actually several of those files. I'm including the whole WDC folder referenced,
Woah, where did you find these? That t0.asm looks to be the correct example needed.
EDIT: The T0.ASM from the PRIME folder in fact works as an almost drop-in replacement for the startup.asm I was working on, and my test C program seems to compile and run flawlessly.
In my case I had to modify the C_STACK and STARTUP offsets to fit the memory map for my build, as well as define an NMI vector which the example T0.ASM leaves as zero.
Re: WDC02CC Compiler
Posted: Mon Apr 19, 2021 2:27 pm
by tokafondo
Nice!!! I found it as part of the development package this Micetek company sells.
I hope more programmers could test and confirms this as it could mean AFAIK that there is finally a C compiler working for the 6502 platform.
AFAIK = I can't actually tell if it already exists.
Re: WDC02CC Compiler
Posted: Mon Apr 19, 2021 3:45 pm
by Agumander
there is finally a C compiler working for the 6502 platform.
Wait, does cc65 not work? I'm interested in trying that one next since the license allows modification and distribution; and I'd like to put together an easy all-in-one toolchain for my system.
Re: WDC02CC Compiler
Posted: Mon Apr 19, 2021 6:39 pm
by drogon
Nice!!! I found it as part of the development package this Micetek company sells.
I hope more programmers could test and confirms this as it could mean AFAIK that there is finally a C compiler working for the 6502 platform.
AFAIK = I can't actually tell if it already exists.
Finally???
I've been using cc65 for a few years now and way back in the early 80's there was the Aztec C compiler for the Apple II...
Perhaps you mean finally you can use the WDC C compiler - which from this thread seems a good feat to achieve.
-Gordon
Re: WDC02CC Compiler
Posted: Mon Apr 19, 2021 9:07 pm
by tokafondo
Thanks.
How would the three compilers would compare? Is there something to be gained to get WDC's compiler working? Do the other compilers miss something that the WDC does feature?
Re: WDC02CC Compiler
Posted: Mon Apr 19, 2021 9:55 pm
by GARTHWILSON