Lab Report 4
Lab Report 4
EXPERIMENT 04
PROGRAM CONTROL FLOW INSTRUCTIONS
in 8086 MICROPROCESSORS
INTRODUCTION
In this lab of course, we have been introduced with different program control flow instructions in
8086 microprocessors.
These instructions are used to transfer/branch the instructions during an execution. It includes the
following instructions: Instructions to transfer the instruction during an execution without any
condition − CALL − Used to call a procedure and save their return address to the stack, RET −
Used to return from the procedure to the main program, JMP − Used to jump to the provided
address to proceed to the next instruction.
OBJECTIVES
● To understand behavior of different program control flow instructions
● To learn to write programs using different program control flow instructions in
EMU8086
OBSERVATIONS
In this Lab we wrote and executed an assembly language program to calculate the factorial of
YH (an 8-bit number) and stored the result of factorial at memory location 03002+X H. Then
Secondly, we have written an assembly language code to sum first YH integers using jump and
compare instructions and loop instructions.
Lastly, we have been asked an assembly language code to find the maximum of three numbers
present in three different registers. Stored the maximum number at memory location 03002 +
XH.
MEASUREMENTS
Task 1
1|Page
MOV DX,0300H
MOV DS,DX
MOV BX,4;YH
MOV AX,BX
MOV CX,BX
DEC CX
ABC:
DEC BX
MUL BX
LOOP ABC
MOV [0302H],AX
HLT
Task 2
MOV DX,0300H
MOV DS,DX
2|Page
MOV AX,4H
MOV CX,AX
DEC CX
LABEL1:
ADD AX,CX
DEC CX
CMP CX,0
JE LABEL2
JMP LABEL1
LABEL2:
HLT
2(b):
MOV DX,0300H
MOV DS,DX
MOV AX,4H
MOV CX,AX
DEC CX
3|Page
LABEL1:
ADD AX,CX
CMP CX,0
JE LABEL2
LOOP LABEL1
LABEL2:
HLT
Task 3
MOV DX,0300H
MOV DS,DX
MOV AX,74
MOV BX,87
MOV CX,31
4|Page
GREATER:
CMP AX,BX
JG AXGREAT
JMP BXGREAT
AXGREAT:
CMP AX,CX
JG AXMAX
JL CXMAX
BXGREAT:
CMP BX,CX
JG BXMAX
JL CXMAX
AXMAX:
MOV [4416H],AX
JMP ENDD
BXMAX:
MOV [4416H],BX
JMP ENDD
CXMAX:
MOV [4416H],CX
JMP ENDD
ENDD: HLT
5|Page
ISSUES
Some little difficulties were faced while understanding the concept but later on it has been
resolved and went smoothly.
APPLICATIONS
Emu8086 combines an advanced source editor, assembler, disassembler, software emulator
(Virtual PC) with debugger, and step by step tutorials. This program is extremely helpful for
those who just begin to study assembly language. It compiles the source code and executes it on
emulator step by step.
CONCLUSION
We learned the instruction set of 8086 microprocessors like data transfer instruction, logical
instruction, arithmetic instruction and branching instruction. Addressing mode tells us what is the
type of the operand and the way they are accessed from the memory for execution of an
instruction and how to fetch particular instruction from the memory.
6|Page
POST LAB
1. Write an assembly language program to sum first 10 even numbers and store the result at
memory location 03002+XH
MOV BX,0300H
MOV DS,BX
MOV CL,10H
MOV BL,02H
CHECK:
MOV AL,CL
DIV BL
CMP AH,00H
JE SUM
JNE STORE
HLT
SUM:
ADD DL,CL
LOOP CHECK
STORE:
MOV [1791H],DL
LOOP CHECK
7|Page
-------END------
8|Page