Expressions
3-28
Following are examples of expressions that use relocatable and absolute sym-
bols. These examples use four symbols that are defined in the same section:
.global extern_1 ; Defined in an external module
intern_1: .word ’”D’ ; Relocatable, defined in current module
LAB1: .set 2 ; LAB1 = 2
intern_2 ; Relocatable, defined in current module
-
Example 1
The statements in this example use an absolute symbol, LAB1 (which is
defined above to have a value of 2). The first statement loads the value 51
into the accumulator:
LD #LAB1 + ((4+3) * 7), A ; ACC A = 51
LD #LAB1 + 4 + (3*7), A ; ACC A = 27
-
Example 2
All legal expressions can be reduced to one of two forms:
relocatable symbol
±
absolute symbol
or
absolute value
Unary operators can be applied only to absolute values; they cannot be
applied to relocatable symbols. Expressions that cannot be reduced to
contain only one relocatable symbol are illegal. The first statement in the
following example is valid; the statements that follow it are invalid.
LD extern_1 – 10, B ; Legal
LD 10–extern_1, B ; Can’t negate reloc. symbol
LD –(intern_1), B ; Can’t negate reloc. symbol
LD extern_1/10, B ; / isn’t additive operator
LD in extern_1, B ; Multiple relocatables
-
Example 3
The first statement below is legal; although intern_1 and intern_2 are
relocatable, their difference is absolute because they’re in the same
section. Subtracting one relocatable symbol from another reduces the
expression to
relocatable absolute value. The second statement
is illegal because the sum of two relocatable symbols is not an absolute
value.
LD intern_1 – in extern_1, B ; Legal
LD in in extern_1, B ; Illegal
-
Example 4
An external symbol’s placement is important to expression evaluation.
Although the statement below is similar to the first statement in the
previous example, it is illegal because of left-to-right operator precedence;
the assembler attempts to add intern_1 to extern_1.
LD in extern_1 – intern_2, B ; Illegal
Summary of Contents for TMS320C54x
Page 38: ......
Page 39: ......
Page 40: ......
Page 41: ......
Page 42: ......
Page 43: ......
Page 44: ......
Page 45: ......
Page 46: ......
Page 47: ......
Page 48: ......
Page 49: ......
Page 50: ......
Page 51: ......
Page 52: ......
Page 53: ......
Page 54: ......
Page 55: ......
Page 56: ......
Page 57: ......
Page 58: ......
Page 59: ......
Page 60: ......
Page 61: ......
Page 62: ......
Page 276: ......
Page 277: ......
Page 278: ......
Page 279: ......
Page 280: ......
Page 281: ......
Page 282: ......
Page 283: ......
Page 284: ......
Page 285: ......
Page 286: ......
Page 287: ......
Page 288: ......
Page 289: ......
Page 290: ......
Page 291: ......
Page 292: ......
Page 293: ......
Page 294: ......
Page 295: ......
Page 296: ......
Page 297: ......
Page 298: ......
Page 299: ......
Page 300: ......
Page 301: ......
Page 302: ......