This directory contains the source code and example programs for a SIC (Simplified Instructional Computer) assembler. The assembler reads SIC assembly code, generates symbol tables, and produces an object program.
Program1.asm: Example SIC assembly program.Program2.asm: Another example SIC assembly program.sicAssembly.c: C program for assembling SIC assembly code.OPTable.instr: Instruction set for the SIC assembler.
The SIC assembly programs (Program1.asm and Program2.asm) contain instructions written in SIC assembly language. These programs are used as input to the assembler.
startLine: 1
endLine: 19The assembler (sicAssembly.c) reads the assembly code, generates symbol tables, and produces an object program. It consists of two main passes:
- PASS1: Reads the source file, generates the symbol table, and creates an intermediate file.
- PASS2: Reads the intermediate file, generates the object code, and writes the object program.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int PASS1(const char *programFileName);
int PASS2();
void cleanFiles();
int main(int argc, char *argv[])
{
const char *programFileName;
if (argc >= 2)
{
programFileName = argv[1];
}
else
{
printf("\nUsage: %s <program_file> (Using Default \"Program1.asm\")\n", argv[0]);
programFileName = "Program1.asm";
}
PASS1(programFileName);
PASS2();
if (argc == 3 && strcmp(argv[2], "--clean") == 0)
{
cleanFiles();
}
return 0;
}The instruction set (OPTable.instr) contains the opcodes for the SIC assembler. This file is used by the assembler to look up the opcodes for the instructions in the assembly programs.
startLine: 1
endLine: 25
-
Compile the SIC Assembler:
gcc sicAssembly.c -o SICAssembler
-
Run the SIC Assembler:
./SICAssembler Program1.asm
-
Clean Up Generated Files (Optional):
./SICAssembler Program1.asm --clean
This directory provides a simple yet comprehensive example of a SIC assembler. It includes example SIC assembly programs, the assembler source code, and the instruction set. By following the steps above, you can compile and run the assembler to generate object programs from SIC assembly code.