View on GitHub

8085_Emulator

8085-Emulator

Download this project as a .zip file Download this project as a tar.gz file

8085-Emulator by Vishal Sanserwal

Emulator for 8085 which supports 25 most commonly used commands which are -
Load and Store - MOV, MVI, LXI, LDA, STA, LHLD, SHLD, STAX, XCHG  
Arithmetic - ADD, ADI, SUB, INR, DCR, INX, DCX, DAD, SUI 
Logical - CMA, CMP
Branching - JMP, JC, JNC, JZ, JNZ
One Additional command SET has been made to set data into valid memory locations (Eg - SET 2500,0A )  

Debugger

The program also has a debugger mode which you can select at the start of the program.Currently, it has following abilities:

The program will display contents of Registers A, B, C, D, E, H, L, flag Registers and used memory Locations only

How This Works

The emulator uses python-2 as a backend to perform all operations. Registers, as well as flags and memory, is taken as the ordered dictionary.
Note: Make sure to end the program with “HLT” as final instruction for both command line as well as file mode.

How to write program

Make sure all the statements are in CAPS.
For adding comments add ‘//’ in start of instruction

Defining Label

LABEL: OPERATION OPERAND
GO: ADD B

Writing Program on Command Line (Command Line Mode)

The emulator has a mode to write the program on the terminal itself without providing the file as input. This mode can be selected the first time you start the emulator.
Note:To exit the writing mode enter “EOF”

Sample Program

//add 2 8 bit nos carry
LXI H,2500
MVI M,74
INX H
MVI M,AA
MVI C,00
LDA 2500
MOV B,A
LDA 2501
ADD B
JNC 2016
INR C
STA 2502
MOV A,C
STA 2503
HLT

To run program:

$ python emulator.py