11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Register UsageC Language Featuressame argument types as your assembler function, and compile to assembler code with the DSPICC-S option, allowing you to examine the assembler code.3.6.2 Function Return ValuesFunction return values are passed to the calling function as follows:3.6.2.1 Integral Return ValuesAll integral return values no larger than 2 bytes in size are returned from a function in W0. Integralreturn values of 4 bytes in size are returned in W0/W1, with the low order word in W0.3.6.2.2 Structure Return ValuesComposite return values (struct and union) of size 4 bytes or smaller are returned in W0/W1 aswith integral return values. For larger types, the structure or union is copied into a space allocatedby the calling function, a pointer to which is passed in W14 when the function is called.3.7 Register UsageThe <strong>dsPIC</strong> devices use register W15 for the system stack pointer. Registers W0 through W7 may beused for function parameters, and function return values may be returned in W0/W1. The compilerassumes that registers W8 through W13 will not be altered over function calls. Any assemblerroutines that are called from C code should preserve these registers.3.8 OperatorsHI-TECH C supports all the ANSI operators. The exact results of some of these are implementationdefined. The following sections illustrate code produced by the compiler.3.8.1 Integral PromotionWhen there is more than one operand to an operator, they typically must be of exactly the same type.The compiler will automatically convert the operands, if necessary, so they have the same type. Theconversion is to a “larger” type so there is no loss of information. Even if the operands have the sametype, in some situations they are converted to a different type before the operation. This conversionis called integral promotion. HI-TECH C performs these integral promotions where required. If you42

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

Saved successfully!

Ooh no, something went wrong!