tbird: .db 0x00,0x08,0x0C,0x0E,0x0F,0x00,0x10,0x30,0x70,0xF0To allocate and initialize a table in C, you could do:
unsigned char tbird[10]; tbird[0] = 0x00; tbird[1] = 0x08; . . .Or
unsigned char tbird[] = {0x00,0x08,0x0C,0x0E,0x0F,0x00,0x10,0x30,0x70,0xF0};In C, array indices start at 0. Thus, to access the 0x0C element, you would refer to tbird[2].
To do a bitwise AND in assembly, you would load one of the operands into an accumulator and use the anda or andb instruction. For example,
ldaa PORTC anda #0x03To do the same in C, you would:
PORTC & 0x03Here are some more common operators in C:
Add |
|
Is i equal to j? | if (i == j) |
Subtract |
|
Is i not equal to j? | if (i != j) |
Multiply |
|
Is i less than j? | if (i < j) |
Divide |
|
Is i less than or equal to j? | if (i <= j) |
Bitwise AND |
|
Is i greater than j? | if (i > j) |
Bitwise OR |
|
Is i greater than or equal to j? | if (i >= j) |
Bitwise Exclulsive OR |
|
Is i < 0 and j = 5? | if ((i<0) && (j==5)) |
Bitwise Complement |
|
Is i < 0 or j = 5? | if ((i<0) || (j==5)) |
Negate (2's Complement) |
|
||
Left shift |
|
||
Right shift |
|