Pseudoinstructions are elements within assembly language that abstract common sequences of instructions. These elements are implemented to simplify programmer interfacing and source code complexity.
Pseudoinstructions are software-implementations and aren’t necessary to be made at a hardware level. Common examples of Pseudoinstructions, taken from the MIPS assembly language, include the following:
blt
bgt
ble
li
move
To better illustrate how pseudoinstructions are used, consider the following MIPS code:
.data .text main: li $t0, 9 # load 9 into temp. register 0 li $v0, 10 # Begin end sequence syscall
Note the instruction that loads the value 9 into the first temporary register: li $t0, 9
. This is a pseudoinstruction that represents the following:
addiu $8, $0, 0x00000009
There’s a lot more going on in that abstraction that one might have guessed. Let’s break things down:
li
gets converted toaddiu
$t0
gets converted to$0
9
gets converted to0x00000009
It’s enlightening to realize that the assembler doesn’t need human-friendly register names or numerical representations. Skipping these; let’s consider how the li gets converted into the addiu
and an additional element, the 0
, gets added into the mix.
The $t0 register is “getting” a new value; one specified explicitly by the programmer in this case. There is no preceding operation involving other values. As such, the assembler can consider the immediate value to be relative to zero. This allows a simple and cheap operation such as add to be used for either negative or positive values.
This basic example of pseduoinstructions helps illustrate how many common commands found in assembly languages like MIPS abstract away common sequences to reduce typing—or to simply make things easier to remember. Store the result of adding 0
and 0x00000009
into register $3
? No way. Just load 9 into the third temporary register.