CHAPT ER 4 T HE INST RUCT ION SET ARCHIT ECT URE
127
Example usage: bvs label
Meaning: Branch to label if the v condition code is 1. For the object code shown
below, label is five words farther in memory than the bvs instruction. Object code:
00001110100000000000000000000101
Instruction: ba
Description: Branch to the address computed by adding 4
× disp22 in the Branch
instruction format to the address of the current instruction. Example usage:
ba label
Meaning: Branch to label regardless of the settings of the condition codes. For the
object code shown below, label is five words earlier in memory than the ba instruc- tion.
Object code:
00010000101111111111111111111011
4.3 Pseudo-Ops
In addition to the ARC instructions that are supported by the architecture, there are also
pseudo-operations
pseudo-ops that are not opcodes at all, but rather instructions to the assembler to perform some action at assembly time. A list of
pseudo-ops and examples of their usages are shown in Figure 4-12. Note that
unlike processor opcodes, which are specific to a given machine, the kind and nature of the pseudo-ops are specific to a given assembler, because they are exe-
cuted by the assembler itself.
T he
.equ
pseudo-op instructs the assembler to equate a value or a character
Pseudo-Op Usage
Meaning
.equ .equ
10
Treat symbol X as 10
16
.begin .begin
Start assembling
.end .end
Stop assembling
.org .org
2048
Change location counter to 2048
.dwb .dwb
25
Reserve a block of 25 words
X
.global .global Y
Y is used in another module
.extern .extern Z
Z is defined in another module
.macro .macro M a, b, ...
parameters a, b, ...
.endmacro .endmacro
End of macro definition
.if .if cond
Assemble if cond is true
.endif .endif
End of .if construct Define macro M with formal
Figure 4-12 Pseudo-ops for the ARC assembly language.
128
CHAPT ER 4 T HE INST RUCT ION SET ARCHIT ECT URE
string with a symbol, so that the symbol can be used throughout a program as if the value or string is written in its place. T he
.begin
and
.end
pseudo-ops tell the assembler when to start and stop assembling. Any statements that appear
before
.begin
or after
.end
are ignored. A single program may have more than one
.begin.end
pair, but there must be a
.end
for every
.begin
, and there must be at least one
.begin
. T he use of
.begin
and
.end
are helpful in mak- ing portions of the program invisible to the assembler during debugging.
T he
.org
origin pseudo-op causes the next instruction to be assembled with the assumption it will be placed in the specified memory location at runtime
location 2048 in Figure 4-12. T he
.dwb
define word block pseudo-op reserves a block of four-byte words, typically for an array. T he
location counter
which keeps track of which instruction is being assembled by the assembler is moved ahead of the block according to the number of words specified by the
argument to
.dwb
multiplied by 4. T he
.global
and
.extern
pseudo-ops deal with names of variables and addresses that are defined in one assembly code module and are used in another.
T he
.global
pseudo-op makes a label available for use in other modules. T he
.extern
pseudo-op identifies a label that is used in the local module and is defined in another module which should be marked with a
.global
in that module. We will see how
.global
and
.extern
are used when linking and loading are covered in the next chapter. T he
.macro
,
.endmacro
,
.if
, and
.endif
pseudo-ops are also covered in the next chapter.
4.4 Examples of Assembly Language Programs