I am making this thread in an effort to avoid highacking pichichi010's.
You are completely right for the first 2.
However, the 6502 has a lot of adressing modes !
Also, more registers can be simulated using zero page variables.
You can do most arithmetical operations directly with them - which many processors can't (they can only load/store to/from memory, and do operations on their registers).
The more I think, the more I guess it would be a really good investment to have great C compilers.
At my work I work with an "obscure" microcontroller by Texas Instruments, and I program it in C, I'm pretty sure the compiler is by TI too, and the debugger shows code both in C and in assembly (the output of the compiler).
I am not familiar with the architecture of this microcontroller (nowhere like I'm familiar with the 6502), but I can tell the output is very clean, and extremely close to what I would have done if I wrote it in assembly.
Most C code translate into ~2 lines or assembly or so.
All this to say I think it's better to spend time to make great tools than to spend time to deal with complicated things because you're writing code in assembly.
I think CC65 is open source so maybe if it's so bad we should all spend some time to improve it to make proper code - for all diferent kinds of 65xxx processors, and all the community would benefit from it.
The other option - porting GCC to 65xxx processors should probably be envigased too but it sounds more complicated. Someone already did that but the project somehow ended in an incomplete status.
So yeah I am more and more thinking that it would be better to do complete games in C that uses unoptimized code than half-completed game engine that uses very optimized assembly code, but that no-one will ever play.
That being said - I haven't ever programmed a single line of C for the NES, but I should look into it very soon - and also look at CC65's sources to see how expandable the compiler is.
The success of the author of "Zooming Secretary" and "Alter Ego" where all of us failed for years to release a complete games definitely convinced me that I was going wront when writing 10k+ lines of assembly to build a game engine that could be done with only 1k of C lines - and it would be more portable to other platforms as a bonus.
mic wrote:
Stack access is not such a large problem. I'd say the bigger problems are:
Lack of registers.
Register width.
Few addressing modes.
With that being said, it would certainly be possible to generate good 65xx code from C. It's just that the efforts to develop good compilers/optimizers tend to go into platforms that are used on a large scale, like x86 or ARM.
Lack of registers.
Register width.
Few addressing modes.
With that being said, it would certainly be possible to generate good 65xx code from C. It's just that the efforts to develop good compilers/optimizers tend to go into platforms that are used on a large scale, like x86 or ARM.
You are completely right for the first 2.
However, the 6502 has a lot of adressing modes !
Also, more registers can be simulated using zero page variables.
You can do most arithmetical operations directly with them - which many processors can't (they can only load/store to/from memory, and do operations on their registers).
Quote:
With that being said, it would certainly be possible to generate good 65xx code from C. It's just that the efforts to develop good compilers/optimizers tend to go into platforms that are used on a large scale, like x86 or ARM.
The more I think, the more I guess it would be a really good investment to have great C compilers.
At my work I work with an "obscure" microcontroller by Texas Instruments, and I program it in C, I'm pretty sure the compiler is by TI too, and the debugger shows code both in C and in assembly (the output of the compiler).
I am not familiar with the architecture of this microcontroller (nowhere like I'm familiar with the 6502), but I can tell the output is very clean, and extremely close to what I would have done if I wrote it in assembly.
Most C code translate into ~2 lines or assembly or so.
All this to say I think it's better to spend time to make great tools than to spend time to deal with complicated things because you're writing code in assembly.
I think CC65 is open source so maybe if it's so bad we should all spend some time to improve it to make proper code - for all diferent kinds of 65xxx processors, and all the community would benefit from it.
The other option - porting GCC to 65xxx processors should probably be envigased too but it sounds more complicated. Someone already did that but the project somehow ended in an incomplete status.
So yeah I am more and more thinking that it would be better to do complete games in C that uses unoptimized code than half-completed game engine that uses very optimized assembly code, but that no-one will ever play.
That being said - I haven't ever programmed a single line of C for the NES, but I should look into it very soon - and also look at CC65's sources to see how expandable the compiler is.
The success of the author of "Zooming Secretary" and "Alter Ego" where all of us failed for years to release a complete games definitely convinced me that I was going wront when writing 10k+ lines of assembly to build a game engine that could be done with only 1k of C lines - and it would be more portable to other platforms as a bonus.