6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Sep 26, 2024 10:11 pm

All times are UTC




Post new topic Reply to topic  [ 60 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Re: WDC02CC Compiler
PostPosted: Mon Apr 19, 2021 11:19 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
Thanks. No trace of WDC's compiler there... I think that the fact that it hasn't been got to work leaves it out of the comparison.

I read something about floating point here.

For some reason I want the people to be able to run this WDC C compiler. The comparison leaves CC65 as the one to be chosen because it's the one that works, having speed and code size against it.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 9:34 am 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1467
Location: Scotland
tokafondo wrote:
Thanks. No trace of WDC's compiler there... I think that the fact that it hasn't been got to work leaves it out of the comparison.

I read something about floating point here.

For some reason I want the people to be able to run this WDC C compiler. The comparison leaves CC65 as the one to be chosen because it's the one that works, having speed and code size against it.


Who are "the people"?

Personally, I am not interested in the WDC C compiler - mostly because it won't run natively under Linux and I don't feel I need it enough to bother with WINE, DOSBox or whatever just to run it. That may sound somewhat churlish, but really - if WDC want me to use it then they can make it easy for me to use because my time is precious to me and spending hours/days (as some have) just trying to get some code to work via it is not what I want to do.

So if/when I next need C I'll be using cc65 - because it works, and I was easily able to configure it for my systems (even though there is scant documentation on how to do that - and it's not just a matter of a new .cfg file - you need to alter the sources...)

As for floating point - I started to write my own IEEE compliant code and stopped and used my ATmega "co processor" to do the hard work for me (for my BCPL system - BBC Basic has excellent and faster floating point written in 65C02) There is an Apple FP library but I do not think they have ever published the sources (and I'm not referring to the Woz ones, but a separate library known as S.A.N.E.)

But... If someone can put together a rock-solid tutorial on the WDC C compiler to run under Linux from a Makefile, then I'll certainly take a look.

-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: Tue Apr 20, 2021 11:22 am 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
drogon wrote:
Who are "the people"?

Well... anyone interested.

drogon wrote:
(and I'm not referring to the Woz ones, but a separate library known as S.A.N.E.)

Found while research:

SANE _is_ IEEE-754/854, using single, double and extended precision (4, 8 and 10 bytes respectively). The SANE library was available for 8-bit Apple II models (used by AppleWorks, for example), and is part of the toolbox for the Apple IIgs and Macintosh. (my italics)

I don't know if the Apple IIgs toolbox is available for download, though. All I can find are books about it, but not it. Also, I don't know if the toolbox includes sources or binaries.

drogon wrote:
But... If someone can put together a rock-solid tutorial on the WDC C compiler to run under Linux from a Makefile, then I'll certainly take a look.


What I've been able to do is just installing wine through the package manager, and setting environment variables. I'll have to research (maybe trivial stuff for coders) how to prepare a working makefile that should be using... cc65? and mod it to use wdcXXXas and / or wdcXXXcc, as it seems to be needed.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 11:55 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
It looks to me like the IIgs Toolbox is a part of the ROM. I think the various ROM versions can be found to download as binaries (they are needed to emulate the iigs) but I didn't have any luck finding a disassembly.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 12:08 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
BigEd wrote:
It looks to me like the IIgs Toolbox is a part of the ROM. I think the various ROM versions can be found to download as binaries (they are needed to emulate the iigs) but I didn't have any luck finding a disassembly.


https://archive.org/details/GSOS_6.0.1_source

Inside the file there, there ise this IIGS.601.SRC/GSToolbox/SANE/ folder...

- elems.asm
- elems.macros
- sane.asm
- sane.macros


Last edited by tokafondo on Tue Apr 20, 2021 1:48 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 12:29 pm 
Offline
User avatar

Joined: Tue Jul 17, 2018 9:58 am
Posts: 106
Location: Long Island, NY
drogon wrote:
But... If someone can put together a rock-solid tutorial on the WDC C compiler to run under Linux from a Makefile, then I'll certainly take a look.


For me the other missing link is not just running the compiler but obtaining it as well. I've been pretty spoiled by projects and frameworks which include bash scripts to check for and install all the needed tooling. It's particularly helpful in modern workflows that involve developing on some disposable remote virtual instance, or simply to make it easier to teach others how to write for your platform. Pretty much everywhere I've worked encouraged writing/maintaining such scripts to speed onboarding and make equipment upgrades less of a headache.

This makes having to go to WDC's website, give them your email address, and wait to receive a *limited-use download link* really unappealing.


Attachments:
File comment: They've gone to a lot of trouble to keep people from actually using these tools :P
Screenshot 2021-04-20 070551.png
Screenshot 2021-04-20 070551.png [ 39.61 KiB | Viewed 912 times ]
Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 12:33 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
Well... They ask you not to disassemble the binaries, and not use them for commercial products that would run 65xx code in a chip provided by anyone else apart WDC themselves.

I can see that as a fair petition.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 2:53 pm 
Offline

Joined: Thu Apr 23, 2020 5:04 pm
Posts: 50
tokafondo wrote:
Thanks. No trace of WDC's compiler there... I think that the fact that it hasn't been got to work leaves it out of the comparison.

I read something about floating point here.

For some reason I want the people to be able to run this WDC C compiler. The comparison leaves CC65 as the one to be chosen because it's the one that works, having speed and code size against it.

I would not recommend basing decisions on this pretty biased article. Someone pointed me to this comparison some time ago, because it seemed to mention a bug in my compiler (vbcc). Trying to verify this was made somewhat tedious, because the author of this comparison uses his own simulator and, in the case of vbcc, his own linker scripts and configuration files. After having a short look I found that the test that did not work with vbcc uses the pages 0x300 and 0x400 to write the results in a simulated frame-buffer or something like that. However his vbcc linker files contains:
Code:
MEMORY
{
  ...
  ram:     org=0x0300, len=0x0500
}

SECTIONS
{
  ...
  data:   {*(data)} >ram AT>out
  ...
  bss (NOLOAD): {*(bss)} >ram
  ...
}

I did not investigate further, but putting the data and bss section in the frame buffer does seem suspicious to me. As I did not want to waste much time with the tinkered configs, I slightly adapted the code to the C64 screen buffer and the result compiled with vbcc for C64 looked very similar to the one compiled with cc65. Strangely however, the player "sprite" only showed with cc65. Further investigation showed that the test code used an uninitialized variable for the y-coordinate of the player. After fixing this bug in the test, the result of vbcc exactly matched that of cc65.

When I tried to add a timer variable to measure run-time on the C64, the code did not compile anymore on cc65, because it exceeded the 256 byte limitation of cc65. Apparently the test was exactly tailored to cc65's limitations whereas the vbcc result was basically sabotaged. It is obviously not an unbiased comparison but rather the author started with code for cc65 and did no further investigations when the code did not work with a compiler he personally dislikes (whereas for gcc which apparently generated actually broken code he even went out of his way to fix the assembly code by hand). Using this approach your daily-use compiler will of course tend to look more stable. That does not really say much.

As I wrote above, I am the author of the compiler that the author of this comparison hates, so obviously I am not unbiased as well. When I checked his article, I did not write anything and I did not really want to get involved (and write lengthy posts like this one). However, if people point to this blog, I have to say that after what I have checked so far, it is my firm (and as my findings hopefully show mostly fact-based) opinion that this comparison is much too flawed to base a compiler decision on.

I did not spend much time with this article (mainly wanted to check if there was a bug in my compiler) and only limited time with other 6502 compilers. So I will not comment on the stability of the different compilers. I just can say do not use this article to base your decisions on. It is in no way a fair comparison.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 3:03 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Interesting, thanks. Just to note, the idea of a 256 byte limit in cc65 was new to me, but a search turns up this:
"There are some limitation on the size of local variables. Not all operations are available if the size of local variables exceeds 256 bytes."
(It's easy to imagine how that might have happened.)


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 3:06 pm 
Offline

Joined: Thu Apr 23, 2020 5:04 pm
Posts: 50
drogon wrote:
There is an Apple FP library but I do not think they have ever published the sources (and I'm not referring to the Woz ones, but a separate library known as S.A.N.E.)

FYI, vbcc comes with a fp library using wozfp as well as one using the SANE FP routines. They have been made into a linkable library by creating relocation information using two versions of the ROM for different memory locations. While using quite a lot of space they seem to be a very solid IEEE implementation. Surprisingly, they seem to be about as fast as the wozfp routines, even though they internally perform all calculations on 80bit format and most operands have to be explicitly converted to 80bit and back again. Of course that probably says more on the speed of the wozfp routines which shine when it comes to memory usage.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 3:37 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1948
Location: Sacramento, CA, USA
vbc wrote:
... Of course that probably says more on the speed of the wozfp routines which shine when it comes to memory usage.

Yeah, I've been studying Woz' code for decades, and I haven't yet encountered an obvious example of him intentionally spending any bytes just to save some cycles. :)

_________________
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!

Mike B. (about me) (learning how to github)


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 3:46 pm 
Offline

Joined: Sat Apr 11, 2020 7:28 pm
Posts: 344
What would be a fair set of tests that could be created to make a comparison between 65xx C compilers?

Or FP libraries, regarding code size or calculation speeds?


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 5:04 pm 
Offline

Joined: Thu Apr 23, 2020 5:04 pm
Posts: 50
BigEd wrote:
Interesting, thanks. Just to note, the idea of a 256 byte limit in cc65 was new to me, but a search turns up this:
"There are some limitation on the size of local variables. Not all operations are available if the size of local variables exceeds 256 bytes."
(It's easy to imagine how that might have happened.)

Yes, it does not seem to contain a code path for handling stack-frames larger than 256 bytes. Probably not an unreasonable restriction. I guess the intersection of code that requires larger stack-frames with code that runs reasonable on a 6502 system will be limited. Also, cc65 is often used with an option that converts all local variables to static ones. Still a funny coincidence that the test juust fitted...


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 5:55 pm 
Offline

Joined: Thu Apr 23, 2020 5:04 pm
Posts: 50
tokafondo wrote:
What would be a fair set of tests that could be created to make a comparison between 65xx C compilers?

Well, that is a non-trivial area of science, basically. And it is made harder by the fact that the existing 6502 compilers do vary quite a lot regarding their goals/capabilities, and quite a lot of existing C code does not work on 6502. So, clearly not an easy task, but IMHO at least you should either use code that has not been written/pre-selected with any specific compiler in mind, or it should be adapted/optimized equally for all compilers.

As always, pointing out flaws is much easier than creating a flawless comparison.

Quote:
Or FP libraries, regarding code size or calculation speeds?

That would probably be easier to compare, but some work is needed to create a test-framework that works equally with all fp libraries. vbcc can be used to compare wozfp and SANE, but at the moment no other fp libraries are available for it. Of course, if anybody wants to port another fp library to work with vbcc, that would be much appreciated. :-)


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC02CC Compiler
PostPosted: Tue Apr 20, 2021 6:34 pm 
Offline
User avatar

Joined: Mon May 12, 2014 6:18 pm
Posts: 365
vbc wrote:
tokafondo wrote:
What would be a fair set of tests that could be created to make a comparison between 65xx C compilers?

Well, that is a non-trivial area of science, basically. And it is made harder by the fact that the existing 6502 compilers do vary quite a lot regarding their goals/capabilities, and quite a lot of existing C code does not work on 6502. So, clearly not an easy task, but IMHO at least you should either use code that has not been written/pre-selected with any specific compiler in mind, or it should be adapted/optimized equally for all compilers.
Another way to go about it is to write the type of code you are actually going to be using the compilers for. You may not actually care if a particular compiler is better at doing something you don't need it to do.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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: