Ehiremen / dlx-assembler

An assembler that converts dlx-format instructions to 32-bit binaries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dlx-assembler

an assembler that converts dlx-format instructions to 32-bit binaries. done using C++ and compiled on JetBrains CLion.
the program reads a dlx-format instruction file and converts each line to its equivalent assembly language format. the assembly instructions get written to a file (instr.txt)--this can be changed in "void convertAndWriteInstr(vector vecOfCodeLine, vector vecOfLabelsAdr)" ~line 546.

my approach:

  • read the input file (specified by the user in string getFileName())
  • convert to lowercase and store in a new file (lower.txt)
  • remove commas, colons, and parentheses from the lower.txt file, and store in a new tokenated file (tk.txt)
  • read the first word of each instruction and check if that word is in either Opcode OR ALUFunc map; if not, we identify it as a label
  • finally, run void convertAndWriteInstr(vector vecOfCodeLine, vector vecOfLabelsAdr) to generate the binaries for each instruction

NOTE: dlx_assembler.cpp is fairly large (~600 lines), but everything called in main() is either a defined class or a defined function so this code can readily be divided into multiple source files

files included:

About

An assembler that converts dlx-format instructions to 32-bit binaries


Languages

Language:C++ 99.3%Language:CMake 0.7%