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;
}