No Login Data Private Local Save

Two‑Pass Assembler Simulator - Online Simple SIC/XE

6
0
0
0

Two-Pass SIC/XE Assembler Simulator

Educational tool demonstrating the two-pass assembly process for the Simplified Instructional Computer (SIC/XE) architecture.

Pass 1: Symbol Table Pass 2: Object Code Format 1/2/3/4 PC-Relative
SIC/XE Source Code
1
2
3
4
5
Ready
# LOCCTR Source Statement Object Code
Enter code and click Assemble to see results
Symbol Address (Hex) Type / Flags Defined On Line
Run Pass 1 to populate the symbol table

Run Pass 2 to generate object code records

Assembly log will appear here

Pass 1

Scans source, builds symbol table, tracks location counter, handles directives.

Pass 2

Generates object code, resolves symbols, computes displacements.

Addressing Modes

Immediate (#), Indirect (@), Indexed (,X), PC-relative, Base-relative.

SIC/XE ISA

Format 1/2/3/4 instructions, 1MB addressing, 9 registers.

Frequently Asked Questions

A two-pass assembler processes source code twice. Pass 1 scans the entire program to build the symbol table (mapping labels to addresses) and track the location counter. Pass 2 uses the symbol table to generate machine code (object code), resolving all forward references. This approach elegantly handles symbols that are used before they are defined—a common scenario in assembly programming.

SIC/XE (Simplified Instructional Computer with Extra Equipment) is a hypothetical computer designed for educational purposes. It features up to 1MB of memory (20-bit addressing), 9 registers (A, X, L, B, S, T, F, PC, SW), and supports four instruction formats. It's widely used in computer science courses to teach assembly language, assembler design, and system programming concepts.

In PC-relative addressing, the displacement is calculated as: displacement = target_address - (current_PC), where current_PC = instruction_address + 3 (for Format 3). The displacement is a 12-bit signed value (range: -2048 to +2047). The assembler automatically selects PC-relative mode when the target is within range, setting the p flag to 1 in the instruction encoding.

Format 1 (1 byte): Opcode only—used for instructions like FIX, FLOAT, HIO.
Format 2 (2 bytes): Opcode + two register fields—used for register-to-register operations like ADDR, CLEAR, COMPR.
Format 3 (3 bytes): Opcode + flags (n,i,x,b,p,e) + 12-bit displacement—the most common format.
Format 4 (4 bytes): Same as Format 3 but with a 20-bit absolute address field (e=1), prefixed with + in assembly.

Assembly code often contains forward references—symbols used before they are defined (e.g., a JMP to a label defined later). In a single pass, the assembler wouldn't know the address of the forward-referenced symbol. Pass 1 collects all symbol definitions and their addresses. Pass 2 then has complete information to generate correct machine code for every instruction. Two-pass design is a classic and elegant solution to this fundamental problem.

This simulator supports key SIC/XE assembler directives: START (sets program origin), END (marks program end and entry point), BYTE (declare byte constants like C'ABC' or X'F1'), WORD (declare 3-byte word constants), RESB (reserve bytes), RESW (reserve words), EQU (equate symbol to a value), ORG (change location counter), BASE/NOBASE (control base-relative addressing).

BYTE reserves 1 or more bytes with an initial value (e.g., BYTE C'HELLO' stores 5 ASCII bytes). WORD reserves a 3-byte word with an initial value (e.g., WORD 100). RESB reserves a specified number of bytes without initialization (e.g., RESB 10 reserves 10 bytes). RESW reserves a specified number of 3-byte words (e.g., RESW 5 reserves 15 bytes). RESB/RESW are typically used for variables and buffer space.