EasyManua.ls Logo

ST ST7 - Multiple-Statement Assembler Block

ST ST7
317 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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 mustbe 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.

Table of Contents

Related product manuals