17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

+ 0.3 0.4 0.6 51.3<br />

- 0.3 0.4 0.6 52.3<br />

* 0.4 3.2 22.2 35.8<br />

/ 11.3 32 106.6 144.9<br />

exp() * * * 510.4<br />

ln() * * * 644.8<br />

sin() * * * 698.7<br />

Instead of 800, the compiler calls 0. Why?<br />

The PIC® ROM address field in opcodes is 8-10 Bits depending on the chip and specific<br />

opcode. The rest of the address bits come from other sources. For example, on the 174 chip to<br />

call address 800 from code in the first page you will see:<br />

BSF 0A,3<br />

CALL 0<br />

The call 0 is actually 800H since Bit 11 of the address (Bit 3 of PCLATH, Reg 0A) has been set.<br />

Instead of A0, the compiler is using register 20. Why?<br />

The PIC® RAM address field in opcodes is 5-7 bits long, depending on the chip. The rest of the<br />

address field comes from the status register. For example, on the 74 chip to load A0 into W you<br />

will see:<br />

BSF 3,5<br />

MOVFW 20<br />

Note that the BSF may not be immediately before the access since the compiler optimizes out<br />

the redundant bank switches.<br />

What can be done about an OUT OF RAM error?<br />

The compiler makes every effort to optimize usage of RAM. Understanding the RAM allocation<br />

can be a help in designing the program structure. The best re-use of RAM is accomplished<br />

when local variables are used with lots of functions. RAM is re-used between functions not<br />

active at the same time. See the NOT ENOUGH RAM error message in this manual for a more<br />

detailed example.<br />

362

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!