234/317
8 - C Language and the C Compiler
#define EnableInterrupts
{asm RIM;}
#define DisableInterrupts
{asm SIM;}
8.4.1.2 Multiple-statement assembler block
When a block of several lines must be included, the lines must be enclosed in an
asm
block, as
follows:
asm
{
<statement>
<statement>
<statement>
etc.
<statement>
}
An example of in-line assembler statements is transferring word values to or from word regis-
ters.
The timers have 16-bit registers that must be written in a certain order to guarantee the proper
operation of the timer. Since the C compiler optimizes the code size, some assignments might
not be performed in the order they are written. In this case, it is safer to use in-line assembly
language as in this example:
asm
{
ld a, TAIC2HR
ld Position, a
ld a, TAIC2LR
ld Position:1, a
}
This assembly code is logically equivalent to the following expression, that reads a word value
at the address starting from that of the high-order byte of the register:
Position = *((int *) &TAIC2HR)
but the order of reading of the two bytes is important, and C does not give any guarantee re-
garding the order.
Please note that the syntax
Position:1
means the byte following the one placed at address
Position
.
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...