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:
- break or b [line Number]: it will set a breakpoint at the given line number.
- run or r : Run the program until it ends or a breakpoint is encountered.
- step or s : It will run the program one instruction at a time.
- print or p [address or Register]: It prints the value of register or memory location for ex:
p A will print the value of register A.
p 2500 will print the value at memory location x2500 if any. - quit or q : quit the debugger
- help: will show all the commands of debugger
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