IST 2010A-COMPUTER OERGANIZATION
AND PROGRAMMING
LAB 4&5: Assembly Programming in Emulator 8086
Objectives :
i. To learn EMU8086 installation and familiarize with
EMU8086 environment
ii. To learn how to:
•Assemble instructions into the memory of 8086
using Emu8086
•Use Emu8086 to execute instructions
•Run opt-in programs in EMU8086
•Write a complete assembly program.
•Edit an existing source program.
1
Part I: Introduction to Emu8086
An Integrated Development Environment (IDE)
provides a convenient environment to write a source
file, assemble and link it to a -.COM or -.EXE file, and
trace it in both source file and machine code. Emu86
is an educational IDE for assembly program
development.
You can download the latest student version of
EMU86 from the web page www.emu8086.com.
It is a Windows program, and will run by dragging
an -.ASM, -.OBJ, -.LST, -.EXE , or -.COM file into the
emu86 shortcut icon.
By this action, asm or lst files will start the 8086
assembler source editor, while obj and exe files starts
the disassembler and debugger units.
2
EMU8086 Source Editor
• The source editor of EMU86 is a special
purpose editor which identifies the 8086
mnemonics, hexadecimal numbers and labels
by different colors as seen in Figure 1.
Figure 1.
3
EMU8086 Report Window
• The compile
button on the
taskbar starts
assembling and
linking of the
source file.
• A report window
is opened after
the assembling
process is
completed.
• Figure2 shows
the emulator of Figure 2
8086 which gets 4
opened by
Part 2: Opt-in Examples in Emu8086
Look at “Code Examples‟.
After opening one of the code samples, then
press “emulate”, then, “run”. Also try
these :
• “add/subtract‟
• “palindrome‟
• “traffic lights‟
• “led test‟
• “stepper motor‟
• “thermometer‟
5
Part 3: Assemble and execute instructions in
Emu8086
Use emu8086 to make the
calculations following:
a) 10101101b = ?
b) 17h = ?
c) 59 = ? h
Procedure:
Choose “Math” and specify
Figure 3
“Base Convertor” in
emu8086.
Enter one of the numbers
6
like in the Figure 3
Use EMU8086 to evaluate an expressions
• Evaluate : 0FFFFh
*12h +0FFFFh
• Procedure:
1. Choose “Math”
and specify “Multi
Base Calculator”
in emu8086.
Figure 4.
2. Enter the
expression like in
7
the Figure 4.
Part 4: Writing and Running
Assembly Code in Emu8086
• In this part, we are entering Assembly
language world.
• Let’s say “Hello, World”
8
Part 4: Writing and Running Assembly Code in
Emu8086
• Write the following assembly language program in Emu8086
9
Part 4: Writing and Running Assembly Code in
Emu8086
1. After executing the assembly language program in
8086 emulator, provide and explain its view in the
following: stack, variables, memory, 8086 machine
code listing, registers and the ALU contents.
2. Choose other two 16-bit numbers of your own,
i) add the two numbers and repeat step 1.
ii) Subtract the two numbers and repeat step 1.
10
Part 5: Exercise Part
Exercise - 1
Calculate : (30 10 + 15 10 ) * ( 575 10 – 225 10 ) + 210
1. Choose “New” and specify “COM template” in
emu8086.
2. Enter the following code to the editor:
11
Part 5: Exercise Part
Exercise - 1
3.“ Start emulation by clicking the “emulate” button
on the toolbar. A new emulator window will appear.
4. Single-step the program codes by pressing the
“single step” button on the toolbar of the emulator
window. Table 1
5. Each time after
pressing the “single
step” button, check
and record down the
contents of AX and
BX registers in Table 12
Part 5: Exercise Part
Exercise - 2
In this example, we will develop a program
to perform the following arithmetic
operations:
14 10 * ( 23310 – 125 10 ) + 227
Procedure:
1. Develop an assembly language program to
perform the above arithmetic operations by
only using registers AX and BX (write the
program in Table 2). 13
Part 5: Exercise Part
Exercise - 2
Procedure:
2. Write the program who does the calculation above into the
assembler editor in EMU8086
3. Emulate the program by pressing the “emulate” button on
the toolbar.
4. In the emulator window, single-step the program codes by
pressing the “single step” button on the toolbar.
5. Each time after single-stepping, observe and record down
the contents of AX and BX registers in Table 2.
6. Using a calculator, calculate the
Table
answer2for the above arithmetic
operations: ……………..
Is it the same as the final answer in
the AX register?
………………………………….…” 14