Oziphantom wrote:
People here seem to enjoy using C to make 6502 content, so this might be of interest. Camelot have released a new KickC which is a slight variant of C rather than ANSI C to help with optimizing 6502 code
Developers of compilers for the 6502 could benefit from seeing how Keil's compiler for the 8051 handled the quirks of that architecture. Perhaps most importantly, automatic objects are statically overlaid so that they behave like automatic variables except that recursion is not allowed, and qualifiers can place objects in either fast storage (which is limited to about 120 bytes on that platform) or larger storage areas. If one adds qualifiers for integer arrays whose address will never be taken and whose size will be known even on extern declarations, something like:
Code:
int wow[4] = { 0xCAFE, 0xBABE, 0x1234, 0x5678};
int foo(unsigned char __abs x, int *__zp y)
{
return wow[x] + *y;
}
could yield something like:
Code:
.function foo 2,1 ; Uses two bytes of automatic objects in ZP; 1 in non-ZP storae
foo:
ldx ?foo_abs+0
lda __lo_wow,x
clc
ldy #0
adc (?foo_zp+0),y
sta __retval
lda __hi_wow,x
iny
adc (?foo_zp+0),y
sta __retval+1
rts
__lo_wow: .byte $FE, $BE, $34, $78
__hi_wow: .byte $CA, $BA, $12, $56
Nothing insanely complicated should be required to yield that kind of generated code once the proper declarations are in place.