Table of Contents

Pseudoinstructions (ivss)

Pseudoinstructions express an operation that the assembler implements with a sequence of machine instructions. ivss expands a full-width immediate load rather than fitting the entire value inside one instruction:

.section my_code
before_load:
    ld $0x12345678, %r1
after_load:
    halt
.equ load_bytes, after_load - before_load
.end

The machine's immediate displacement field is only twelve bits. Asm_PushLoadWord() builds the value a byte at a time, using shifts and additions together with register clearing. This implementation emits eleven four-byte instructions for the load, so load_bytes is forty-four.

The sequence uses %r13 as a helper and clears it afterward. Other destination choices can also require %r12; these registers are not guaranteed to preserve unrelated values across expanded loads.

Labels after the statement advance by the emitted sequence's size, not by one instruction width. Inspecting the object dump or emulator trace exposes the expansion. The source remains convenient to write, while the emulator executes only the resulting machine instructions.

Source: asembler.c.