6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Jun 16, 2024 6:40 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue May 11, 2021 3:52 am 
Offline
User avatar

Joined: Mon May 12, 2014 6:18 pm
Posts: 365
After recent threads on the WDC compiler and NutStudio, I got both compilers working and compared them to CC65 using a piece of code I analyzed in my Robot Game. You can see the results side by side in this spreadsheet. Anyone should be able to add comments. It shows the C code on the left with the output for each compiler in the next three columns. The "WDC rearranged" column has the WDC output in the same order as CC65 and NutStudio since the WDC output is in a different order that makes it difficult to compare to the other two. The last column is my assembly translation of the C.

The NutStudio version is pretty slick and seems more efficient than CC65 in a few places. This is really intriguing. WDC, on the other hand, uses almost none of the indexed addressing modes and is very inefficient.

Here's the C code:
Code:
#include <stdio.h>

#define SLOT_COUNT 5

enum stat_field_indexes
{
  type,
  cost,
  cost_type,
  quality,
  description=quality,
  stat_count,
  stat_begin
};

const unsigned char * const item_stats[]={"WDC won't compile empty array"};
unsigned char hero_equipped[SLOT_COUNT];
unsigned char * const stat_pointers[]={"WDC won't compile empty array"};

int main()
{
  unsigned char i,j;
  unsigned char stat_ID,stat_val;
  unsigned char *stat_ptr;

  for (i=0;i<SLOT_COUNT;i++)
  {
    for (j=0;j<item_stats[hero_equipped[i]][stat_count];j++)
    {
      stat_ID=item_stats[hero_equipped[i]][stat_begin+j*2];
      stat_ptr=stat_pointers[stat_ID];
    }
  }

  return 0;
}


Top
 Profile  
Reply with quote  
PostPosted: Wed May 12, 2021 6:14 am 
Offline
User avatar

Joined: Tue Jul 17, 2018 9:58 am
Posts: 104
Location: Long Island, NY
This is interesting. It's unfortunate that the WDC compiler is that much less efficient, even though it should be able to take advantage of the extra opcodes and addressing modes to get some performance and code size wins.

It matches with my findings (from mere moments ago) that my Tetris game is a lot quicker when compiled with cc65. I'll try to add some metrics to my simulator later, that will give a more quantitative cycles assessment.
For now I can see that the CODE section of the WDC build is 11,683 bytes vs the cc65 build's 9,186 bytes. :shock:


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

All times are UTC


Who is online

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