6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed May 01, 2024 1:43 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: WDC Tools gotcha's
PostPosted: Sat Feb 24, 2024 9:10 am 
Offline

Joined: Tue Jan 09, 2024 6:48 am
Posts: 5
Many people seem to dislike to WDC Tools suite.
Saying it is old (no dispute there). Saying it is clunky (probably depends on what you are used to).
Saying it has many bugs/quirks. As long as, you are aware of them and can work around them, I call them "gotcha's".

As a beginning .asm and C programmer, with around 4 months of overall experience solely with WDC Tools (and none with CA65 or similar). I combined it with Notepad++ instead of TIDE. These are the gotcha's I have found/encountered so far.

1) Assembler (wdc02as/wdc816as)
- No spaces allowed around '+' in an equate: "STAT EQU BASE + 1" will have "STAT EQU BASE". Needs to be "STAT EQU BASE+1".
- Do not use the "REPT cnt" directive combination to auto-repeat cnt times an assembly statement. Assembler will crash. Need to manually replace/insert.

2) C Compiler (wdc02cc/wdc816cc)
- Some common datatypes are not standard included (e.g. uint8_t, uint16_t, uchar, ushort, ulong, etc.). Need to be user-defined.
- There is no prefix for binary values (e.g. in bitmasks etc). Must use HEX, octal or decimal.

3) Linker (wdcln)
Did not find anything so far.

4) Debugger (wdcdb)
- Needs to be run as Administrator
- Requires -hz (and -sz??) options during linking for the debugger to load/execute your code properly.

Are you aware of items you can add to the above list? Hopefully including workarounds or solutions.

PS : I am updating the above list as people respond, saving you reading the entire thread. Thank you for those who contribute.


Last edited by DMartens on Sat Feb 24, 2024 10:40 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools gotcha's
PostPosted: Sat Feb 24, 2024 10:16 am 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 745
Location: Germany
another thing for the C compiler, it doesn't support binary notation. it doesn't even tell you that anywhere, not in the documentation, an error message, or error number.
it just kinda prints out the first line with binary from the source file on it and then quietly crashes (and yes the compiler does actually appear to crash instead of exiting because the return code is "-1073741819" instead of "0", "1", etc.)
it took me so god damn long to figure out why i wasn't able to compile by mandelbrot program. well turns out it had some binary masks in it!

the reason why it doesn't have binary notation is because it technically isn't part of the C standard ("0b" is a GNU GCC extention that a lot of other compilers have adopted) so WDC didn't include the functionality, which IMO is a very strange decision considering that the Compilers are for CPUs that very often deal with individual bits and masks...


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools gotcha's
PostPosted: Sat Feb 24, 2024 2:21 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1399
Location: Scotland
DMartens wrote:
2) C Compiler (wdc02cc/wdc816cc)
- Some common datatypes are not standard included (e.g. uint8_t, uint16_t, uchar, ushort, ulong, etc.). Need to be user-defined.
- There is no prefix for binary values (e.g. in bitmasks etc). Must use HEX, octal or decimal.


C doesn't define uint8_t and so on. It's not part of the language standard.

Also note that the WDC C compiler is relatively old - it may well be ANSI C, but is it C89, C99, ... ?

C99 introduced the concept of a <stdint.h> file to define these types for you - some older C compilers also had it too but it may well have been very implementation dependant.

So - all you need to do is copy this file from another implementation that can use it, adapt as needs and use it.

And again binary prefix isn't a standard part of C ...

See here for an interesting way to do it:

https://www.thecodingforums.com/threads ... -c.318127/

So while I'll probably never use the WDC C compiler (because it doesn't run natively under Linux and cc65 is good enough for me) in this case I suspect it's not really at fault...

-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: WDC Tools gotcha's
PostPosted: Tue Apr 30, 2024 12:31 pm 
Offline
User avatar

Joined: Mon Aug 30, 2021 11:52 am
Posts: 256
Location: South Africa
A couple of gotcha's I've run into:

  • farmalloc doens't work WDC816CC and farmalloc. ~~far_heap_start and ~~far_heap_end seem to be ignored and no more than 64KB of memory can be allocated.
  • Low Level I/O functions don't exist WDC816CC and sprintf. Using FCNTL fails with an undefined symbol at linker time.
  • Development of the Terbium IDE seems to have been abandoned in the Windows XP days WDC Terbium IDE (Tide) with the W65C816
  • The peephole optimiser generates incorrect code when calling a function and assigning the result into a pointer referenced as an array when that pointer is a function parameter. (WDC are currently investigating this)
  • WDC816CC understands large code that can cross banks. WDCLN does not and will generate an error if the resultant binary is larger than 64KB.
  • Parameters can only be passed on the stack. Internal functions (like ~~~mul) can be called with parameters in A and X but the WDC816CC can't generate those functions.
  • WDC816CC error messages seldom point to the correct line and tend to be a little generic I.e. everything is always 'Bad Declaration'.

And after that list it might seem like I dislike the WDC Tools but... nope. I'm quite enjoying using them. I've quite a large project going so far with good mix of C and assembly. And - sometime in the future - I want to post a tutorial on how to use WDC's tools with the W65C816.


Top
 Profile  
Reply with quote  
 Post subject: Re: WDC Tools gotcha's
PostPosted: Tue Apr 30, 2024 7:05 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8166
Location: Midwestern USA
Although I have no immediate plans to write any C stuff for my POC units, I’m following this topic with some interest.

Long ago when TIDE was for sale and not freely downloadable, I purchased the package and installed it on my Windows XP box (which is still in use...XP, that is :D).  I wrote some small programs in C—mostly simple math and string manipulation stuff—just to get a feel for how the tools worked and to look at the resulting binary output (n.b. I don’t have much love for the TIDE assembler...the LONGI ON/OFF stuff is cumbersome, among other things).  The things I recall from those TIDE sessions were:

  1. Development procedure was awkward.  I came away with the impression a major project would be a major hassle to build.

  2. The output binary was bulky for the size of the programs I had written, especially since none had any I/O statements.  Exactly what might have bloated the binary was something I never determined.

  3. I had considerable trouble with malloc() and friends, which at the time I decided was due to not clearly understanding the memory models used by the compiler.  Based on what I’m reading here and elsewhere about the compiler, I’m now thinking there is/was something fundamentally wrong with the implementation of malloc() et al and some other low-level library stuff related to it.

  4. I was put off by the fact that no source code for any library functions was provided.  While I understand the desire to protect the source for the compiler proper, library functions by themselves are not of much value and hence don’t need to be protected in this fashion.  Given that any competent 6502/816 assembly language programmer could patch library functions that don’t work as they should and contribute their improvements back to other users, why WDC did not include the source for the libraries baffles me.

Given all this, I set aside TIDE and have not touched it since.

While it is unlikely I will ever be convinced the 65C02 is a good target, C on the 65C816 should be a fairly good fit, what with the latter’s stack addressing capabilities, movable direct page and MVN/MVP instructions for rapidly copying data blocks.  Math functions beyond basic integer arithmetic will never be very speedy, but that would be tolerable as long as one is not planning to solve aerodynamic problems or develop the 65C816 version of Microsoft’s Excel spreadsheet.  :D

That said, I can’t see doing C development with TIDE being in its present state.  It’s a shame that TIDE has these problems, as faulty tools tend to discourage use of the 816, same as the problems with WinCUPL would discourage the use of Atmel PLDs.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

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