Lab 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6
At a glance
Powered by AI
The key takeaways are to learn how to assemble and execute instructions using the DEBUG software emu8086 and practice various data transfer, arithmetic, flag control, compare and jump instructions. It also covers calling and using subroutines.

The objectives of the lab are to learn how to assemble instructions into memory, execute instructions to determine their operation, and verify the operation of data transfer and arithmetic instructions. It also involves practicing examples from the textbook using emu8086.

The main steps to complete the data transfer instructions part are to assemble various MOV instructions, initialize registers, fill memory locations, trace instruction execution and explain the addressing modes and values.

Microprocessor I Labs

16.317 Microprocessor I, Spring 2007


Lab 2: Assembling and executing instructions with DEBUG software
Due on 03/02/2007, 12:30pm EST
Reference:
Walter A. Triebel and Avtar Singh, Lab Manual to Accompany the 8088 and 8086
Microprocessors, Prentice Hall, ISBN 0-13-012843-0.
Objective
Learn how to:
1. Assemble instructions into the memory of PC.
2. Execute an instruction to determine the operation it performs.
3. Verify the operation of data transfer and arithmetic instructions.
Part 1: Practice 8086 Emulator
You need to practice a 8086 Emulator, emu8086, by reproducing the examples in the
text book. It is helpful to read carefully the explanations along with the examples.
Specifically, you need to practice the following examples:
Loading, verifying and saving machine code
Example 4.24 till page 130 (page 127 - 130)
Executing instructions and tracing programs
Example 4.26 (page 136)
To learn how to use emu8086 tool, please refer to the following web site.
http://www.emu8086.com/assembly_language_tutorial_assembler_reference/referen
ce.html
Part 2: Assignment
Note: You need to use emu8086 to do the following assignments.
You need to show your screen print-out to the TA to check off. Make sure youre
your print-out captures all the steps.
Answer ALL the questions in your report.
Data transfer instructions I
Step 1

Using emu8086 to assemble the instructions


(a)
(b)
(c)
(d)
(e)
(f)

MOV
MOV
MOV
MOV
MOV
MOV

AX,BX
AX,AAAA
AX,[BX]
AX,[4]
AX,[BX+SI]
AX,[SI+4]

Prof. Yan Luo, UMass Lowell

Page 1/6

Microprocessor I Labs

(g) MOV AX,[BX+SI+4]

Step 2

Initializing the internal registers of the 80x86 as follows:


(AX)
(BX)
(CX)
(DX)
(SI)
(DI)
(BP)

Step 3

=
=
=
=
=
=
=

0000H
0001H
0002H
0003H
0010H
0020H
0030H

Verify the initialization by displaying the new content of registers


Fill all memory locations in the range DS:00 through DS:1F with 00H and the
initialize the word storage location that follow:
(DS:0001H)
(DS:0004H)
(DS:0011H)
(DS:0014H)
(DS:0016H)

Step 4

=
=
=
=
=

BBBBH
CCCCH
DDDDH
EEEEH
FFFFH

Trace the execution of the instructions (a) through (f). Explain the execution
of each instruction, including addressing mode, physical address for memory
addressing mode, value in AX.

Data transfer instructions II


Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8

Assemble the instruction MOV SI, [0ABC] to memory at address CS:100 and
verify loading of the instruction. How many bytes does the instruction take up?
Initialize the word of memory starting at DS:0ABC with the value FFFFH
Clear the SI register, verify by displaying its content.
Trace the execution. Describe the operation performed by the instruction
Assemble the instruction MOV WORD PTR [SI], ABCD into memory at
address CS:100 and then verify loading of the instruction. How many bytes
does it take?
Initialize SI register with the value 0ABCH
Clear the word of memory starting at DS:0ABC
Trace the execution. Describe the operation performed by the instruction

Arithmetic instructions
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6

Assemble the instruction ADC AX, [0ABC] to memory at address CS:100 and
verify loading of the instruction. How many bytes does the instruction take up?
Initialize the word of memory starting at DS:0ABC with the value FFFFH
Initialize AX with the value 0001H. Verify by displaying register contents.
Clear the carry flag
Trace the execution. Describe the operation performed by the instruction
Does a carry occur?

Flag-control instructions
Prof. Yan Luo, UMass Lowell

Page 2/6

Microprocessor I Labs

Step 1

Assemble the instruction sequence


LAHF
MOV BH, AH
AND BH, 1FH
AND AH, 0E0H
MOV [200H], BH
SAHF

Step 2
Step 3
Step 4
Step 5

Into memory at address CS:100 and then verify loading of the instruction. How
many bytes do they take?
Initialize the byte of memory starting at DS:200 with the value 00H
Clear register AX and BX
Display the current state of flags, make sure the status flags equal NG, ZR,
AC, PE and CY
Trace the execution. Describe the operation performed by each instruction.
What value is read out of the flags register?
What value is saved in memory?
What value is reloaded into flags register?

Compare instructions
Step 1

Assemble the instruction sequence


MOV BX, 1111H
AND AX, 0BBBBH
CMP BX, AX

Step 2
Step 3
Step 4

Into memory at address CS:100 and then verify loading of the instruction. How
many bytes do they take?
Clear register AX and BX.
Display the current state of flags
Trace the execution. Describe the operation performed by each instruction.
What value is read out of the flags register?
What value is saved in memory?
What value is reloaded into flags register?
What are the status flags before and after the compare instruction was
executed?

Jump instructions
You need to download two files (L5P3.LST and L5P3.EXE) from the course webpage at
http://faculty.uml.edu/yluo/Teaching/MicroprocessorI/umlrocks/L5P3.LST
http://faculty.uml.edu/yluo/Teaching/MicroprocessorI/umlrocks/L5P3.EXE
Step 1
Download the files in one of your file folders
Step 2
open the source listing in file L5P3.LST.
What is the starting address offset from CS: for the first instruction (PUSH
DS) and the last instruction (RET)?
Step 3
Load the run module L5P3.EXE with emu8086
Step 4
Verify loading of the program by unassembling the contents of the current
code segment for the offset range found in Step 2
Prof. Yan Luo, UMass Lowell

Page 3/6

Microprocessor I Labs

Step 5

Execute the program according to the instructions that follow


a. GO from address CS:00 to CS:5
b. Load the number whose factorial is to be calculated (N=3) into register
DX
c. Clear the memory storage location DS:0000 for the value of factorial
(FACT)
d. GO from address CS:5 to CS:10, what is the state of the zero flag?
e. Execute from the JZ instruction with a TRACE command, Was the
jump taken?
f. GO from address CS:12 to CS:16, What is the current value of AL?
g. Execute the JMP instruction with a TRACE command
Was the jump taken? What is the address of the next instruction to be
executed?
h. GO from address CS:E to CS:10. What is the state of the zero flag?
i. Execute the JZ instruction with a TRACE command. Was the jump
taken?
j. GO from address CS:12 to CS:16, What is the current value of AL?
k. Execute the JMP instruction with a TRACE command
Was the jump taken? What is the address of the next instruction to be
executed?
l. GO from address CS:E to CS:10. What is the state of the zero flag?
m. Execute the JZ instruction with a TRACE command. Was the jump
taken?
n. GO from address CS:12 to CS:16, What is the current value of AL?
o. Execute the JMP instruction with a TRACE command
Was the jump taken? What is the address of the next instruction to be
executed?
p. GO from address CS:E to CS:10. What is the state of the zero flag?
q. Execute the JZ instruction with a TRACE command. Was the jump
taken? What is the instruction to be executed next?
r. GO to CS:1B. What is the final value in AL? At what address is the
value in AL stored in memory as FACT?
s. Display the value stored for FACT in memory

Step 6

Quit from emu8086.

Subroutine instructions
You need to download one file (L5P4.EXE) from the course webpage at
http://faculty.uml.edu/yluo/Teaching/MicroprocessorI/umlrocks/L5P4.EXE
Step 1
Step 2
Step 3

Load the file L5P4.EXE with emu8086


Verify the loading of the program by unassembling the contents of the current
code segment.
Execute the instructions as follows.
a. Single step from address CS:00 to CS:5. What instruction is to be
executed next?
Prof. Yan Luo, UMass Lowell

Page 4/6

Microprocessor I Labs

Step 4

b. Load the numbers that follow for use by the arithmetic subroutine.
(AX) = -32 = FFE0H
(BX) = 27 = 001BH
(CX) = 10 = 000AH
(DX) = 200 = 00C8H
c. Execute the call instruction with a TRACE command. What instruction
is to be executed next?
d. Single step to address CS:10. What is the sum in DX?
e. Check the value of the last word pushed to the stack
f. Run the program to completion. What is the final value in DX? How
did the contents of DX become this value?
Exit emu8086.

Check off
Demonstrate the files you saved (in example 4.24) to the TA.
Get TAs signature on the screen print-out you obtained.
Attach your screen print-out to your report.
Report format
Your report needs to follow the format below.
Lab # and title:
Student Name:
Partners Name:
Lab Purpose:
<It is usually the objective of the lab.>
Lab Content:
< Answer the questions in lab specification. Describe what you do in the lab, e.g. what
commands you practiced. It has to be at least one page with 11pt font size. Try to
organize and summarize the lab in itemized lists.>
Difficulties:
< state what difficulties you encountered in the lab and how you managed to solve it. If
not, what have you tried? >
Conclusion and Suggestions:

Prof. Yan Luo, UMass Lowell

Page 5/6

Microprocessor I Labs

Grading
Student Name _________________

Student ID ___________________

Lab Two Rubrics


Partners can share screen capture or program print-out, however, each student MUST
submit his/her own report. Duplicated reports (including both parties) are considered
cheating, which result in a ZERO in the lab, reduction in letter grade for the course,
grade of F for the course, and/or university administrative penalties.
Item
Check off
Data transfer
I/II
Arithmetic
Flag control
Compare
Jump
Subroutine

Criteria
Check off with TA
Print-out or screen capture of the
instruction, Answer questions correctly
Print-out or screen capture of the
instruction, Answer questions correctly
Print-out or screen capture of the
instruction, Answer questions correctly
Print-out or screen capture of the
instruction, Answer questions correctly
Print-out or screen capture of the
instruction, Answer questions correctly
Print-out or screen capture of the
instruction, Answer questions correctly

Full Points
40
10

Actual Points

10
10
10
10
10

TOTAL
100

Prof. Yan Luo, UMass Lowell

Page 6/6

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy