Table of Contents#
- Introduction to SIC
- SIC Architecture Overview
- SIC Assembly Language Programming
- SIC/XE: Extended Architecture
- Assembling and Executing SIC Programs
- Best Practices in SIC Programming
- Educational Use Cases and Benefits
- References
1. Introduction to SIC#
SIC was created to:
- Teach assembly language programming by reducing syntax and instruction set complexity.
- Explain computer organization (registers, memory, instruction execution) without real-world architectural details (e.g., pipelining, out-of-order execution).
- Demonstrate system software concepts (assemblers, linkers, loaders) via a simple target architecture.
Why SIC?#
- Simplicity: Fixed instruction format, few registers, and linear memory make it easy to learn.
- Completeness: Supports essential operations (load/store, arithmetic, branching, subroutines) for meaningful programs.
- Extensibility: The extended variant (SIC/XE) introduces advanced features (indexing, extended addressing) to bridge to real architectures.
2. SIC Architecture Overview#
Registers#
SIC has five 16-bit registers, each with a specific role:
- A (Accumulator): Performs arithmetic/logic operations (e.g.,
ADD,SUB). - X (Index Register): Supports indexed addressing (e.g., array access).
- L (Linkage Register): Stores return addresses for subroutines (used with
JSUB/RSUB). - PC (Program Counter): Holds the address of the next instruction.
- SW (Status Word): Contains flags (e.g., sign, zero) for conditional branching (more prominent in SIC/XE).
Memory Organization#
- Addressing: 15-bit addresses (0 to 32767) support 32,768 bytes (32 KB) of byte-addressable memory.
- Data Types:
BYTE: 1 byte (8 bits).WORD: 3 bytes (24 bits) (a quirk of SIC’s design, as arithmetic uses 16-bit registers).- Memory is allocated via directives like
RESB(reserve bytes) andRESW(reserve words).
Instruction Set and Format#
All SIC instructions are 3 bytes (24 bits) with the format:
- Opcode (8 bits): Defines the operation (e.g.,
LDA,ADD,J). - Address (16 bits): A 15-bit effective address (the 16th bit is unused).
Core Instructions:#
- Load/Store:
LDA(load A from memory),STA(store A to memory),LDX(load X from memory),STX(store X to memory). - Arithmetic:
ADD(add memory to A),SUB(subtract memory from A). - Branching:
J(unconditional jump),JEQ/JGT/JLT(conditional jumps, SIC/XE only). - Subroutines:
JSUB(jump to subroutine, store return address in L),RSUB(return from subroutine, load PC from L).
## 3. SIC Assembly Language Programming
Assembly Source Format#
A SIC assembly program has four columns (optional columns in brackets):
[Label] Opcode Operand ; Comment- Label: Symbolic address (e.g.,
NUM1,SUM), used to reference memory. - Opcode: Machine instruction (e.g.,
LDA) or directive (e.g.,START,BYTE). - Operand: Depends on the opcode (e.g., memory address, constant, directive parameter).
- Comment: Optional (for readability).
Directives and Macros#
Directives guide the assembler (not executed as machine code):
START: Marks the program’s start (e.g.,START 1000loads the program at address 1000).END: Marks the program’s end (e.g.,END STARTsets the entry point toSTART).BYTE: Define byte data (e.g.,BYTE 'A'(ASCII) orBYTE X'05'(hex)).WORD: Define a 3-byte word (e.g.,WORD 123stores 123 as 3 bytes).RESB/RESW: Reserve memory (e.g.,RESB 10reserves 10 bytes,RESW 2reserves 2 words (6 bytes)).
Example Program: Arithmetic Calculation#
This program adds two numbers and stores the result:
START 1000 ; Program starts at memory address 1000
NUM1 WORD 5 ; First number (3 bytes: 000005)
NUM2 WORD 3 ; Second number (3 bytes: 000003)
SUM RESW 1 ; Reserve 3 bytes for the sum
LDA NUM1 ; Load NUM1 into accumulator (A = 5)
ADD NUM2 ; Add NUM2 to A (A = 5 + 3 = 8)
STA SUM ; Store A to SUM (SUM = 8)
RSUB ; Return (simulate program end)
END START ; End of program, entry point is START- Explanation:
START 1000initializes the PC to 1000.NUM1andNUM2define 3-byte words with values 5 and 3.LDA NUM1loads 5 into A;ADD NUM2adds 3 (A = 8);STA SUMstores 8 intoSUM.RSUBreturns (noHALTin SIC, so this simulates termination).
4. SIC/XE: Extended Architecture#
SIC/XE (Extended) adds features to bridge to real-world architectures:
Key Enhancements#
- Base Register:
B(base register) used along with displacement for addressing (replaces simple direct addressing). - General-Purpose Registers:
SandTfor flexible data manipulation. - Extended Addressing: 20-bit addresses (supporting up to 1 MB of memory).
- Condition Codes:
SW(status word) includesEQ(equal),GT(greater than),LT(less than) for conditional branching.
Extended Instruction Format#
Instructions now include addressing mode bits:
Opcode (6) | n (1) | i (1) | x (1) | b (1) | Address (12)
n: Indirect addressing (1 = indirect, 0 = direct).i: Immediate addressing (1 = immediate, 0 = memory).x: Index register flag (1 = use X index register, 0 = no indexing).b: Base register flag (1 = use B register, 0 = no base addressing).- Address: 12 bits (extended to 20 bits with indexing/base/indirect addressing).
Example: Indexed Addressing#
To access an array element ARRAY[X]:
LDA ARRAY,X ; Load A with ARRAY[X] (indexed addressing)5. Assembling and Executing SIC Programs#
SIC Assembler: Two-Pass Process#
The SIC assembler converts assembly source to machine code in two passes:
- Pass 1: Builds a symbol table (labels → addresses) and calculates segment sizes.
- Pass 2: Generates machine code, resolves symbolic addresses, and outputs an object file/listing.
Linking and Loading#
- Linking: Combines multiple object modules, resolving external references (e.g., subroutine calls across files).
- Loading: Places the linked program into memory (using the
STARTaddress) and initializes the PC.
Simulation and Execution#
A SIC simulator (e.g., software emulators) executes machine code:
- Fetches the instruction from
PC. - Decodes the opcode and address.
- Executes the operation (e.g., load from memory, add to A).
- Updates registers (e.g.,
PC+= 3 for the next instruction).
6. Best Practices in SIC Programming#
Code Structure and Readability#
- Meaningful Labels: Use descriptive labels (e.g.,
TOTALinstead ofL1). - Comments: Explain non-trivial operations (e.g., “Load array index into X”).
- Data/Code Separation: Place data (e.g.,
NUM1,ARRAY) in a separate section from code.
Debugging Tips#
- Listing File: Verify addresses and object code using the assembler’s listing.
- Step Simulation: Execute step-by-step to track register/memory changes.
- Symbol Table Check: Ensure labels are resolved (no “undefined symbol” errors).
Optimization Strategies#
- Register Reuse: Minimize memory access by reusing registers (e.g., keep loop counters in X).
- Indexed Addressing: Use
Xfor arrays to reduce code size (e.g.,LDA ARRAY,Xinstead of multipleLDAwith offsets). - Subroutines: Use
JSUB/RSUBfor code reuse (e.g., common math functions).
7. Educational Use Cases and Benefits#
- Assembly Language: Learn low-level programming (opcodes, addressing modes) without x86/ARM complexity.
- Computer Organization: Understand instruction fetch, decode, and execution (CPU cycle).
- System Software: Implement simple assemblers/linkers for SIC to learn system software design.
- Bridging to Real Architectures: SIC/XE’s features (indexing, extended addressing) mirror real-world architectures (e.g., x86’s
ESI/EDI).
8. References#
- Beck, L. L. (1997). System Software: An Introduction to Systems Programming. Addison-Wesley.
- Online SIC Simulators/Assemblers (e.g., educational tools for SIC/SIC/XE).
- Academic Resources: Papers on pedagogical computer architectures.
This guide provides a comprehensive overview of SIC, from architecture and assembly to best practices and education. By mastering SIC, learners build a foundation for low-level computing and system software.