Beruflich Dokumente
Kultur Dokumente
#pragma io <I/O name> <address> : port0 is address 0x00 now variable port0 is defined as a byte function func defines a variable indata as byte read data from port0 (SFR for I/O) to variable indata
__io(<address>) <I/O name> : same effect as first two statements above, but only for local use defines a bitfield from MSB downwards; the number behind the colon designates the no of bits (here 1) to access only single bits defines variable register of this structure assigns a 1 to bit no 1 in variable register enables a variable e.g. WDCR of type ioport to be accessed either by WDCR.REG in the range of 0 to 255 or by WDCR.BIT.B00 to WDCR.BIT.B07 with 0 or 1
peculiarities of C statements
a++, ++a, a--, --a a == b a != b a <= b, a >= b a < b, a > b a<<1, a>>3 a += 7 (a == 3 && b == 7) (a==0) ? a = 5 : a = b; increments/ decrements a (before, after) equality unequality less than / greater than or equal less than / greater than but caution because: shifts a 1 position left rsp. 3 positions right Identical to a = a + 7 log. AND; caution: (a=3&&b=7) sets a to 3 and b to 7 conditioned expression; if a equ. zero then ... else ...
program control
if (condition) { statements ; } else statements; while (condition) { statements } do { statements; } while (condition);
for (init; condition; stmt) { statements } switch (expression) { case const1: blocka; case const2: blockb; break; default: blockd; } break; continue;
terminates forward, e.g. to the end of a loop terminates backward, e.g. directly back to beginning of a loop