Emulator Guide
Emulator Guide
programs developed for that processor. With this emulator, you can also code
in assembly language as it comes along with a built-in editor, which allows us
to recreate a totally realistic user experience on PCs equipped with this
processor.
Where to start?
1. Start Emu8086 by selecting its icon from the start menu, or by running
Emu8086.exe.
2. Select "Samples" from "File" menu.
3. Click [Compile and Emulate] button (or press F5 hot key).
4. Click [Single Step] button (or press F8 hot key), and watch how the code is
being executed.
5. Try opening other samples, all samples are heavily commented, so it's a
great learning tool.
JA RCL
Operand types:
➢ REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP,
SP.
Things to remember:
When two operands are required for an instruction they are separated by
comma. For example:
REG, memory
When there are two operands, both operands must have the same size (except
shift and rotate instructions). For example:
AL, DL
DX, AX
m1 DB ?
AL, m1
m2 DW ?
AX, m2
#make_COM# include
'emu8086.inc' ORG 100h
MOV AL, 1
MOV BL, 2
PRINTN 'Hello World!' ; macro. MOV CL, 3
PRINTN 'Welcome!' ; macro. RET
ORG 100h
VAR1 DB 7
var2 DW 1234h
Copy the above code to the source editor, and press F5 key to compile it and
load in the emulator. You should get something like:
MOV instruction copies the second operand (source) to the first
operand
(destination).
the source operand can be an immediate value, general-purpose
register or memory location. the destination register can be a
general-purpose register, or
memory
location.
both operands must be the same size, which can be a byte or a word.
Note: The
MOV
instruction cannot b
used to set
the value of
the CS and IP register
you can type the above program to emu8086 code editor, and press [Compile
and Emulate] button (or press F5 key on your keyboard).
The emulator window should open with this program loaded, click [Single Step]
button and watch the register values.
Variables
Variable is a memory location. For a programmer it is much easier to have some
value be kept in a variable named "var1" then at the address 5A73:235B,
especially when you have 10 or more variables.
Arrays
Interrupts
Interrupts can be seen as a number of functions. These functions make the
programming much easier, instead of writing a code to print a character you
can simply call the interrupt and it will do everything for you. There are also
interrupt functions that work with disk drive and other hardware. We call such
functions software interrupts.
Interrupts are also triggered by different hardware; these are called hardware
interrupts. Currently we are interested in software interrupts only.
The following example uses INT 10h sub-function 0Eh to type a "Hello!"
message. This function displays a character on the screen, advancing the
cursor and scrolling the screen as necessary.
Currently you may not be able to fully understand the contents of the
emu8086.inc (located in Inc folder), but it's OK, since you only need to
understand what it can do.
To use any of the functions in emu8086.inc you should have the following line
in the beginning of your source file: Library: include 'emu8086.inc'
Example1:
Example2:
Suggested Reference:
• Hamacher, Carl, (2013) Computer organization and embedded systems
New York: McGraw-Hill, 6th Ed.
• Clements, Alan (2014), Computer organization and
Architecture: Themes and Variations. Stamford, CT: Cengage Learning