Thursday, October 25, 2012

8085 Assembler program in C++

In my Compiler Design lab, there was an assignment on making a 2 pass assembler for 8085 Micro processor. This assembler takes a 8085 assembly program (in mnemonics like MOV A, B) and outputs the corresponding Machine code in hexadecimal characters.
NOTE - This is just a lab work for demonstrating how a assembler works. It is not a real assembler for producing binaries.

First Download the 8085 zip

Files present in archieve-
1. assembler.cpp
2. assembler.h
3. test_assembler.cpp
4. symbols8085.txt
5. sample.asm
6. sample2.asm
7. README

Currently there are 208 commands for 8085 which can be processed. You can modify/add commands by editing "symbols.txt".

Instructions for Linux
  1. First extract the contents of archieve in some folder. Lets call this folder WORK
  2. Open terminal and change directory to WORK. To do this, run "cd WORK"
  3. Now compile the files using "g++ -o 8085assembler test_assembler.cpp"
  4. Test the sample file (sample.asm) using "./8085assembler sample.asm". You should get a string consisting of hexadecimal characters on a single line. For output to be displayed on seperate lines (for each instruction) use "./8085assembler sample.asm -n"


You can create your own 8085 input files. Just pass them as an argument to ./8085assembler
For any query, just post a comment.

1 comment: