The instruction set architecture : pseudo- ops

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

imageunlike 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 executed by the assembler itself.

The .equ pseudo-op instructs the assembler to equate a value or a character 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. The .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. The use of .begin and .end are helpful in making portions of the program invisible to the assembler during debugging.

The .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.) The .dwb (define word block) pseudo-op reserves a block of four-byte words, typically for an array. The 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.

The .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. The .global pseudo-op makes a label available for use in other modules. The

.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. The .macro, .endmacro, .if, and .endif pseudo-ops are also covered in the next chapter.

Leave a comment

Your email address will not be published. Required fields are marked *