Table of Contents

Assembler (ivss)

An assembler translates assembly statements into encoded instructions, section contents, symbols, and relocation records. In ivss, the executable is named asembler. A small input file illustrates the distinction between instructions and directives:

.section my_code
    ld $5, %r1
    ld $7, %r2
    add %r2, %r1
    halt
.end

ld, add, and halt request executable operations. .section chooses where their bytes are emitted, while .end stops reading source. Save the example as main.s and assemble it with:

$ ./asembler -hex -o main.o main.s

-hex selects the serialized object format consumed by the linker. Without it, the assembler writes a human-readable object dump, which is useful for inspecting symbols and bytes but is not the linker's input format.

The assembler parses statements, expands any pseudoinstructions, and records unresolved symbol uses. The linker later assigns final addresses. Producing an object file therefore does not execute the program or resolve every reference to another file.

Source: asembler.c.