6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Nov 12, 2024 6:22 pm

All times are UTC




Post new topic Reply to topic  [ 60 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: WDC02CC Compiler
PostPosted: Wed May 06, 2020 8:42 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
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:
   106 00:0012: 85 58              sta   CNT + 1
   107 00:0014: 05 58              ora   CNT + 0

No spaces and it gets it right.
Code:
   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


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Wed May 06, 2020 6:30 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
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


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Thu May 07, 2020 11:54 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1746
Location: Sacramento, CA
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/


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Sun May 24, 2020 10:45 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
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


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Sat Jun 13, 2020 1:34 am 
Offline
User avatar

Joined: Sat Jun 13, 2020 1:23 am
Posts: 1
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!


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Sun Apr 18, 2021 1:03 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
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:
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,
Attachment:
wdc.zip [27.22 KiB]
Downloaded 72 times
, so you can study them in the case they could be of help.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Sun Apr 18, 2021 1:25 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
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


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Sun Apr 18, 2021 2:13 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Mon Apr 19, 2021 10:29 am 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
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.

Attachment:
zpage.inc.txt [3.27 KiB]
Downloaded 57 times


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Mon Apr 19, 2021 11:27 am 
Offline
User avatar

Joined: Tue Jul 17, 2018 9:58 am
Posts: 107
Location: Long Island, NY
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Mon Apr 19, 2021 2:27 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Mon Apr 19, 2021 3:45 pm 
Offline
User avatar

Joined: Tue Jul 17, 2018 9:58 am
Posts: 107
Location: Long Island, NY
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Mon Apr 19, 2021 6:39 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1485
Location: Scotland
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/


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Mon Apr 19, 2021 9:07 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Mon Apr 19, 2021 9:55 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
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?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 60 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: