lunes, 28 de enero de 2019

cc65 cheat sheet

1.
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

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

3.
since version 2.13 environment variable is : $(CC65_HOME)

instead of: CC65_INC

4.
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.


https://en.wikipedia.org/wiki/Data_segment

5.
https://cc65.github.io/doc/atari.html
Definitions of memory.

6.
https://www.cc65.org/doc/cc65-2.html
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 

7.
https://www.cc65.org/doc/coding.html

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
http://8bitworkshop.com/blog/compilers/2019/03/17/cc65-optimization.html


9. Fácil acceso a Peeks and Pokes" en C.
http://atariage.com/forums/topic/289164-cc65-news-os-structure/#entry4236915

10.
Advanced optimizations in CC65
https://github.com/ilmenit/CC65-Advanced-Optimizations

11.
Global variables
ojala todo sea variables globales asi usamos menos el stack


No hay comentarios.:

Publicar un comentario