This repo contains 8085 emulator
this 8085 emulator emulates almost all instructions accept few (see TODO .
it does not emulates at same speed though (3.2MHz) but at speed of host system.
it comes with 64K ram.
write your assembly code as usual with few things in mind.
// this is 8085 assembly program to sort numbers
LXI H,3000
MVI M,6
LXI H,3001
MVI M,1
LXI H,3002
MVI M,5
LXI H,3003
MVI M,2
LXI H,3004
MVI M,4
LXI H,3005
MVI M,3
hlt
// this is comment
%execute
%getmemory 3000 3010
MVI B,5
START:
LXI H,3000
MVI C,5
BACK:
MOV A,M
INX H
CMP M
JC SKIP
JZ SKIP
MOV D,M
MOV M,A
DCX H
MOV M,D
INX H
SKIP:
DCR C
JNZ BACK
DCR B
JNZ START
HLT
%execute
%getregister
%getmemory 3000 3010
q
//
at beginning of line indicate comment.
label:
should not follow any instruction but newline.
MOV M,A
this type to instruction showld not contain space between comma(,) and oprands.
%
sign following command is used to tell emulator what to do.
every file must end with q
to mark end.
%execute
executes instructions above can be called multiple times.
%getregister
prints register contents.
%getmemory start end
returns memory content in range.
%setpc location
set position of PC registor from here execution starts.
%setmemory location
set position of memory where instruction is to be stored.
%initmemory
set memory content to 0.
default PC=0
start memory=0
SP=65520
every registor and memory is 0 initially.
before execution HLT
must be there else there uill be infinite loop.
######################
# Address # Value #
######################
# 3000 # 6 #
# 3001 # 1 #
# 3002 # 5 #
# 3003 # 2 #
# 3004 # 4 #
# 3005 # 3 #
# 3006 # 0 #
# 3007 # 0 #
# 3008 # 0 #
# 3009 # 0 #
# 3010 # 0 #
######################
########################
# Register # values #
########################
# A # 5 #
# B # 0 #
# C # 0 #
# D # 3 #
# E # 0 #
# H # 11 #
# L # 189 #
# SP # 65520 #
# IR # 118 #
# PC # 61 #
# S # 0 #
# Z # 1 #
# AC # 0 #
# P # 1 #
# CY # 0 #
# BC # 0 #
# DE # 768 #
# HL # 3005 #
########################
######################
# Address # Value #
######################
# 3000 # 1 #
# 3001 # 2 #
# 3002 # 3 #
# 3003 # 4 #
# 3004 # 5 #
# 3005 # 6 #
# 3006 # 0 #
# 3007 # 0 #
# 3008 # 0 #
# 3009 # 0 #
# 3010 # 0 #
######################
using commandline java -Dfile.encoding=UTf-8 -jar 8085-emulator.jar in.file
run JAR directly and enter in prompt
java -Dfile.encoding=UTf-8 -jar 8085-emulator.jar
>
Enter file name to execute: in.file