lunes, 28 de enero de 2019

cc65 cheat sheet

if a variable is declared not on the top of a function then:

line 34:     int i;

hello.c(34): Error: Expression expected
hello.c(34): Warning: Statement has no effect
hello.c(34): Error: `;' expected
hello.c(34): Error: Undefined symbol: `i'
hello.c(34): Warning: Statement has no effect

with c99 this error must not be, but still I'm getting it:

cl65 --standard c99 -t atari hello-c89.c -o hello-c89.xex 
hello-c89.c(12): Error: Expression expected

cl65 -t atari hello.c -o hello.xex
target atarixl provides more free memory. (see 4)

since version 2.13 environment variable is : $(CC65_HOME)

instead of: CC65_INC

Segment `BSS' overflows memory area `MAIN' by 12345 bytes

One possibility is to change start address of your program. The default value is typically 8192, you can try decreasing it to 6144. You can do it by passing the -S 6144 option to the ld65 linker.

Definitions of memory.

arguments for command line compiler.

-Cl Make local variables static 
-O Optimize code 
-Oi Optimize code, inline more code 
-o name Name the output file 


1. Use prototypes
2. Don't declare auto variables in nested function blocks
3. Remember that the compiler does no high level optimizations
4. Longs are slow!
5. Use unsigned types wherever possible
6. Use chars instead of ints if possible
7. Make the size of your array elements one of 1, 2, 4, 8
8. Expressions are evaluated from left to right
9. Use the preincrement and predecrement operators
10. Use constants to access absolute memory locations
11. Use initialized local variables
12. Use the array operator [] even for pointers
13. Use register variables with care
14. Decimal constants greater than 0x7FFF are actually long ints
15. Access to parameters in variadic functions is expensive

8. Optimizing C array lookups

9. Fácil acceso a Peeks and Pokes" en C.

Advanced optimizations in CC65