An assembler is a program that translates assembly language code into machine language code.
- One pass assembler
- Two pass assembler
This is my implementation of a pseudo assembler in python which tries to simulate a two pass assembler.
Let's see how a two pass assembler works in short. It takes an .asm file(here it does take .txt) and a MOT and converts it into an intermediate code after pass 1. In pass one Symbol table and Literal table are also created which are used in pass two(also pool table).
In pass 2 the IR file is converted into machine code using ST and LT. That is a short overview you can read more here.
Here are some output snaps.
Though this won't simulate an assembler completely and may sometime give wrong outputs. An actual assembler is far more complex and efficient.