Intel i960 User Manual page 256

Processor compiler
Hide thumbs Also See for i960:
Table of Contents

Advertisement

Language Implementation
Example 5: atadd.c
The following example refers to the short C program shown in
Example 7-5 below. The asm containing the
in bold.
Example 7-5 atadd.c
static inline
int atadd(p, val)
volatile int *p;
int val;
{
int wtmp;
__asm__ __volatile__("atadd
: "dI"(val),"m" (*p),"d"(p));
return wtmp;
}
volatile int critical_var;
int other_var;
int add_crit()
{
atadd(&critical_var, 1);
if (atadd(&critical_var, 2) != 1)
atadd(&other_var, 1);
}
Consider the lines containing the asm:
__asm__ __volatile__("atadd
"atadd %4,%2,%1"
and locks the bus until it is finished. This feature is used by multi-
processor systems.
provided by the
"=m" (*p)
i.e., operand 0. The
operand can be used.
%4,%2,%1" : "=m"(*p),"=d"(wtmp)
%4,%2,%1" : "=m"(*p),"=d"(wtmp)
: "dI"(val),"m" (*p),"d"(p));
is the
asm-template
takes three arguments. These values are
atadd
and
out-list
in-list
is the first
output-spec
"=m" constraint
instruction is shown
atadd
.
adds to memory
atadd
.
. It is the first operand,
indicates that any memory
7
7-67

Advertisement

Table of Contents
loading

Table of Contents