WDC02CC Compiler

Programming the 6502 microprocessor and its relatives in assembly and other languages.
User avatar
BitWise
In Memoriam
Posts: 996
Joined: 02 Mar 2004
Location: Berkshire, UK
Contact:

WDC02CC Compiler

Post 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.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
User avatar
BitWise
In Memoriam
Posts: 996
Joined: 02 Mar 2004
Location: Berkshire, UK
Contact:

Re: WDC02CC Compiler

Post 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.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
User avatar
8BIT
Posts: 1787
Joined: 30 Aug 2002
Location: Sacramento, CA
Contact:

Re: WDC02CC Compiler

Post 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
Please visit my website -> https://sbc.rictor.org/
User avatar
BitWise
In Memoriam
Posts: 996
Joined: 02 Mar 2004
Location: Berkshire, UK
Contact:

Re: WDC02CC Compiler

Post 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.
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs
User avatar
Irishjourno
Posts: 1
Joined: 13 Jun 2020

Re: WDC02CC Compiler

Post 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!
tokafondo
Posts: 344
Joined: 11 Apr 2020

Re: WDC02CC Compiler

Post 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.
User avatar
Dr Jefyll
Posts: 3525
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: WDC02CC Compiler

Post by Dr Jefyll »

tokafondo wrote:
the other one about the WDC compiler that I opened
( That other thread is here. )
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
tokafondo
Posts: 344
Joined: 11 Apr 2020

Re: WDC02CC Compiler

Post by tokafondo »

Dr Jefyll wrote:
tokafondo wrote:
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.
tokafondo
Posts: 344
Joined: 11 Apr 2020

Re: WDC02CC Compiler

Post 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.
zpage.inc.txt
(3.27 KiB) Downloaded 116 times
User avatar
Agumander
Posts: 129
Joined: 17 Jul 2018
Location: Long Island, NY
Contact:

Re: WDC02CC Compiler

Post by Agumander »

BitWise wrote:
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.
tokafondo wrote:
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. :D

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.
tokafondo
Posts: 344
Joined: 11 Apr 2020

Re: WDC02CC Compiler

Post 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.
User avatar
Agumander
Posts: 129
Joined: 17 Jul 2018
Location: Long Island, NY
Contact:

Re: WDC02CC Compiler

Post by Agumander »

tokafondo wrote:
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.
User avatar
drogon
Posts: 1671
Joined: 14 Feb 2018
Location: Scotland
Contact:

Re: WDC02CC Compiler

Post by drogon »

tokafondo wrote:
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
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
tokafondo
Posts: 344
Joined: 11 Apr 2020

Re: WDC02CC Compiler

Post 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?
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: WDC02CC Compiler

Post by GARTHWILSON »

Someone posted a 65xx C compiler comparison at https://www.videogamesage.com/topic/762 ... ent-163145 .
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Post Reply