EEE 432 - Lab Manual
EEE 432 - Lab Manual
Name of the experiment: Familiarization with Microprocessor 8086 kit and Emulator 8086
software.
Equipments:
1. Microprocessor 8086 kit.
2. Emulator-8086 software
The term “16-bit” means that its arithmetic logic unit, internal registers and most of its
instructions are designed to work with 16-bit binary words. 2) The 8086 has a 16-bit data bus, so
it can read data from or write data to memory and ports either 16 bits or 8 bits at a time.
A microcontroller puts the CPU and all peripherals onto the same chip, a microprocessor houses
a more powerful CPU on a single chip that connects to external peripherals.
Emulator 8086 Software
8086 Microprocessor Emulator, also known as EMU8086, is an emulator of the program 8086
microprocessor. It is developed with a built-in 8086 assembler.
The CS(code segment register) is used to address the code segment of the memory i.e a location
in the memory where the code is stored. The IP(Instruction pointer) contains the offset within the
code segment of the memory.
The Stack Pointer (SP) register is used to indicate the location of the last item put onto the stack.
Base Pointer (BP) − The 16-bit BP register mainly helps in referencing the parameter variables
passed to a subroutine.
SI is called source index and DI is destination index. As the name follows, SI is always pointed
to the source array and DI is always pointed to the destination. This is usually used to move a
block of data, such as records (or structures) and arrays. These register is commonly coupled
with DS and ES.
ES:DI (ES is Extra Segment, DI is Destination Index) is typically used to point to the destination
for a string copy, as mentioned above.
Data segment register (DS): points to the data segment of the memory where the data is stored.
Extra Segment Register (ES): also refers to a segment in the memory which is another data
segment in the memory. Stack Segment Register (SS): is used for addressing stack segment of
the memory.
Program:
MOV AX, 2233H
ADD AX, 1122H
Output:
Program:
MOV AX, 2233H
SUB AX, 1122H
Output:
Conclusion:
Experiment no: 02
Name of the experiment: Experimental study of arithmetic assembly language
instruction using Emulator.
Objectives:
Equipments:
1. Emulator-8086 software
Overview: In this experiment we worked with arithmetic commands ADD, SUB,
MUL, DIV, ADC and SBB. ADD is used for addition of two numbers and SUB is used
to subtract a number from another number. MUL and DIV are used to multiply
and divide two numbers respectfully.
ADC is called addition with carry. If there is a carry when two numbers are added,
then carry is added to the number. For SBB, subtraction is done with considering
carry.
Machine code, also known as machine language, is the elemental language of
computers. It is read by the computer's central processing unit (CPU), is
composed of digital binary numbers and looks like a very long sequence of zeros
and ones.
Program 1:
MOV AX, 2233H
ADD AX, 1122H
SUB AX, 1122H
In this program MOV is a basic command which is used to assign a number to a
variable register.AX is a variable register which contains the space of 16 bits. ADD
and SUB are commands which add and subtract the AX contents respectfully and
stores it to AX register. ‘H’ denotes the hexadecimal value. For each line of the
program written above there is a particular machine code. It is shown below.
Assembly language Machine code Calculation
MOV AX, 2233H B8 33 22 AX=2233H
ADD AX, 1122H 05 22 11 AX=3355H
SUB AX, 1122H 2D 22 11 AX=2233H
Output:
Program 2:
MOV AL, 55H
ADD AL, 11H
SUB AL, 11H
Output:
Program 3:
MOV CX,0BA98H
MOV DX,0FEDCH
MOV AX,4567H
MOV BX,0123H
ADD CX,AX
ADC DX,BX
Program 4:
MOV BX,5678H
MOV AX,1234H
MOV DX,6789H
MOV BX,2345H
SUB BX,DX
SUBB AX,CX
Program 5:
MOV AL, 00F0H
MOV BL, 0011H
MUL BL
Output:
Program 6:
MOV AX, 00F0H
MOV BL, 0010H
DIV BL
Output:
Program 7:
MOV AL,85H
MOV BL,35H
MOV AH,00H
IMUL BL
In this program MOV is a basic command which is used to assign a number to a
variable register. AH, AL and BL are variable registers which contain the space of
08 bits.IMUL is a command which multiplies signed BL contents. ‘H’ denotes the
hexadecimal value. For each line of the program written above there is a
particular machine code. It is shown below.
Assembly language Machine code Calculation
MOV AL,85H B0 85 AL=85H
MOV BL,35H B3 35 BL=35H
MOV AH,00H B4 00 AH=00H
IMUL BL F6 EB BL=0035H
Program 8:
MOV AL,85H
MOV BL,35H
MOV AH,00H
IDIV BL
In this program MOV is a basic command which is used to assign a number to a
variable register. AH, AL and BL are variable registers which contain the space of
08 bits.IDIV is a command which divides signed BL contents. ‘H’ denotes the
hexadecimal value. For each line of the program written above there is a
particular machine code. It is shown below.
Assembly language Machine code Calculation
MOV AL,85H B0 85 AL=85H
MOV BL,35H B3 35 BL=35H
MOV AH,00H B4 00 AH=00H
DIV BL F6 FB BL=0035H
Discussion:
Experiment no: 03
Equipments:
1. Emulator-8086 software
Theory: In this experiment we have performed with various commands such as AND,
OR,XOR,SHL,SAL,SAR,SHR,RCL,ROL,ROR,RCR and ADD.A short note on these commands
is below.
ADD :It is used for the addition of numbers OR:It is used to set bit at particular position
SAR: It is used to shift arithmetic right RCL: It is used to rotate left through carry
AND :It is used to clear certain bits SHL : It is used to Shift logical left
RCR: It is used to rotate right through carry XOR: It is used to invert certain bits
Output in Emulator:
Program 02:
Output in Emulator:
Program 03:
Program 04:
Output in Emulator:
Program: 05:
Output in Emulator:
Program:6
MOV AX,1234H
SHL AX,4
MOV BX,1234H
SHL BX,1
ADD AX,BX
Output in Emulator:
MOV AX,1234H
SHL AX,4
MOV BX,1234H
ADD AX,BX
Discussion:
Experiment no: 04
Name of the experiment: Experimental study of logical shift and rotate assembly language
instructions by using Emulator-8086’.
Objectives:
Equipments:
1. Emulator-8086 software
Overview: In this experiment we have performed with various commands such as AND,
OR,XOR,SHL,SAL,SAR,SHR,RCL,ROL,ROR,RCR and ADD.A short note on these commands is
below.
Problem 2(ii): Program and output for shift arithmetically left by 1,2,3,4 units are below.
MOV BX, 1234H
SAL BX, 1
In the above program MOV is a basic command which is used to assign a number to a variable
register.BX is a variable register which contains the space of 16 bits. SAL is a command which
shifts bits arithmetically left by 1 unit and stores it to BX register. ‘H’ denotes the hexadecimal
value. For each line of the program written above there is a particular machine code. It is shown
below.
Program and output for shift arithmetically right by 1,2,3,4 units are below.
MOV BX, 1234H
SAR BX, 1
In this program MOV is a basic command which is used to assign a number to a variable
register.BX is a variable register which contains the space of 16 bits. SAR is a command which
shifts bits arithmetically right by 1 unit and stores it to BX register. ‘H’ denotes the hexadecimal
value. For each line of the program written above there is a particular machine code. It is shown
below.
Assembly language Machine code Calculation
MOV BX, 1234H BB 34 12 BX=1234H
SAR BX,1 D1 FB BX=091AH
Output: Registers are below
Problem 2(iii): Program and output for rotate left by 1,2,3,4 units are below.
MOV BX, 1234H
ROL BX, 1
In the above program MOV is a basic command which is used to assign a number to a variable
register.BX is a variable register which contains the space of 16 bits. ROL is a command which
rotates bits left by 1 unit and stores it to BX register. ‘H’ denotes the hexadecimal value. For
each line of the program written above there is a particular machine code. It is shown below.
Assembly language Machine code Calculation
MOV BX, 1234H BB 34 12 BX=1234H
ROL BX,1 D1 C3 BX=2468H
Output: Registers are below
Program and output for rotate right by 1,2,3,4 units are below.
MOV BX, 1234H
ROR BX, 1
In this program MOV is a basic command which is used to assign a number to a variable
register.BX is a variable register which contains the space of 16 bits. ROR is a command which
rotates bits right by 1 unit and stores it to BX register. ‘H’ denotes the hexadecimal value. For
each line of the program written above there is a particular machine code. It is shown below.
Assembly language Machine code Calculation
MOV BX, 1234H BB 34 12 BX=1234H
ROR BX,1 D1 CB BX=091AH
Output: Registers are below
Problem 2(iv): Program and output for rotate left through carry by 1,2,3,4 units are below.
MOV BX, 1234H
RCL BX, 1
In the above program MOV is a basic command which is used to assign a number to a variable
register.BX is a variable register which contains the space of 16 bits. RCL is a command which
rotates bits left through carry by 1 unit and stores it to BX register. ‘H’ denotes the hexadecimal
value. For each line of the program written above there is a particular machine code. It is shown
below.
Program and output for rotate right through carry by 1,2,3,4 units are below.
MOV BX, 1234H
RCR BX, 1
In this program MOV is a basic command which is used to assign a number to a variable
register.BX is a variable register which contains the space of 16 bits. RCR is a command which
rotates bits right through carry by 1 unit and stores it to BX register. ‘H’ denotes the
hexadecimal value. For each line of the program written above there is a particular machine
code. It is shown below.
Discussion: In this experiment we have learnt how to use assembly language instruction. We
have performed with various commands such as
AND,OR,XOR,SHL,SAL,SAR,SHR,RCL,ROL,ROR,RCR and ADD of hexadecimal numbers using the
MDA-8086 microprocessor kit and also we have checked the result by using the software
‘Emulator-8086’.The results we have got from the kit and the software were same. Thus the
experiment was successful.
Experiment No: 05
Name of the experiment: Experimental study of assembly language program to perform (5*AL-
6*BH+ BH/8) and to convert temperature from 0F to 0C.
Objectives:
Theory: Arithmatic instructions such as: ADD, AD, SUB, SBB, MUL, IMUL, DIV, IDIV can be
used to to represent a simple expression. we have already been introduced about these
instructions in the previous experiments. PUSH & POP instructions are important instructions
that store and retrieve data from the LIFO(Last In First Out) stack memory. PUSH is used to
save the parameter .On the other hand, POP is used to retrieve them from the stack.
ADD instruction adds together its two operands, storing the result in its first operand.
ADC (Add with Carry) instruction adds the values, together with the carry flag. ADC is used to
synthesize multiword arithmetic.
SUB instruction subtracts the value
SUBB instruction subtracts the specified byte variable and the carry flag from the accumulator.
MUL (unsigned multiply) instruction multiplies an 8-, 16-, or 32-bit operand by either AL, AX,
or EAX. The Carry flag indicates whether or not the upper half of the product contains
significant digits.
IMUL executes a signed multiply of a byte, word, or long by the contents of the AL, AX, or
EAX register and stores the product in the AX.
DIV executes unsigned division. div divides a 16-, 32-, or 64-bit register value (dividend) by a
register or memory byte, word, or long (divisor). The quotient is stored in the AL, AX register
respectively. The remainder is stored in AH, Dx.
IDIV executes signed division. idiv divides a 16-, 32-, or 64-bit register value (dividend) by a
register or memory byte, word, or long (divisor). The size of the divisor (8-, 16- or 32-bit
operand) determines the particular register used as the dividend, quotient, and remainder.
Work 1: Performing the operation 5*AL - 6*BH + (BH/8) and storing the value to CX.
Instruction Machine Code Result
MOV AL,10 B0 0A
MOV BL,5 B3 05
MUL BL F6 E3
MOV CX,AX 8B C8
MOV BL,6 B3 06
MOV BH,8 B7 08
MOV AL,BH 8A C7
MUL BL F6 E3
SUB CX,AX 2B C8
PUSH CX 51
MOV CL,3 B1 03
SHR BH,CL D2 EF
MOV BL,BH 8A DF
MOV BH,00 B7 00
POP CX 59
ADD CX,BX 03 CB
MOV AL,40 B0 28
MOV BL,32 B3 20
SUB AL,BL 2A C3
MOV CL,5 B1 05
IMUL CL F6 E9
MOV DL,9 B2 09
IDIV DL F6 FA
Discussion:
Experiment Name: Study of INC, DEC, CMP, Loop & JUMP
instruction.
Theory:
INC instruction adds one to the destination operand. The destination operand can
be a register or a memory location.
It checks whether the carry flag is set or not. If yes, then jump takes place, that is:
If CF = 1, then jump.
It checks whether the carry flag is reset or not. If yes, then jump takes place, that
is: If CF = 0, then jump.
It checks whether the zero flag is set or not. If yes, then jump takes place, that is: If
ZF = 1, then jump.
iv) JNE / JNZ : Stands for 'Jump if Not Equal' or 'Jump if Not Zero'
It checks whether the zero flag is reset or not. If yes, then jump takes place, that is:
If ZF = 0, then jump.
Program : 1+3+5+7+…………………………………+15
Solution:
MOV CX,07
MOV AX,01
MOV DX,01
SUM:
INC AX
INC AX
ADD DX,AX
DEC CX
CMP CX,0
JZ SKIP
CMP CX,0
JNZ SUM
SKIP:
Output:
Experiment No. : 07
Experiment Name: Conversion of Upper case to Lower case and vice versa in assembly
language.
Objective:
Required Apparatus:
1. Emulator-8086
MOV AH,1
INT 21H
MOV BL,AL
MOV CL,32
XOR BL,CL
MOV AH,2
MOV DL,0AH
INT 21H
MOV DL,0DH
INT 21H
MOV DL,BL
INT 21H
Output:
Discussion:
Experiment no: 08
Name of the experiment: Experimental study of assembly language program to perform the
operation of character string output.
Objectives: The main objective of this experiment is to learn the assembly language instruction
to perform the operation of character string output by using the software ‘Emulator-8086’.
Equipment:
Emulator-8086 software
Overview:
In this experiment we have to use various commands such as MOV, INT, LEA, SUB etc. MOV is a
basic command which is used to assign a number to a variable register. ‘H’ denotes the
hexadecimal value. SUB is used for subtraction purpose.
INT is called ‘Interrupt vector’. It is the address of the BIOS and DOS routine. BIOS is called
‘Basic Input-Output System’. The BIOS routines are responsible for system testing and loading
the operating system. It handles the input-output operations. DOS is called ‘Disk Operating
System’.
LEA stands for “Load effective address”. It puts a copy of the source offset address into the
destination. Input and output of characters and strings may be done by the DOS routine INT
21h. INT 21h, function 9, causes the string whose offset address is in DX to be displayed. The
string must be end with a “$” character.
.Model small tells the assembler that you intend to use the small memory model - one code
segment, one data segment and one stack segment - and the values of the segment registers
are never changed. It has the following effects: You are allowed to write the instruction retn
(return from a near subroutine) as ret.
. STACK 100h : is a segment directive which defines 100h words as program STACK. The linker
sets the values of SS and SP. ... END identifier : the end of program directive. The identifier is
the place where the program to start to run.
A data definition statement sets aside storage in memory for a variable, with an optional name.
Data definition statements create variables based on intrinsic data types such as BYTE, WORD,
DWORD SBYTE, SWORD etc.
MOV AX,@DATA is the first line of code that gets run. I believe @DATA is a variable that holds
the value of the location in memory where the data segment lives. It moves the memory
location of @DATA into the AX register (16 bit register).
DS is called data segment register. It points to the segment of the data used by the running
program. You can point this to anywhere you want as long as it contains the desired data. ES is
called extra segment register.
LEA − Used to load the address of operand into the provided register.
Write a assembly language program to convert the first lower case letter of your name to
the upper case letter using character string output.
Program:
.MODEL SMALL
.STACK 100H
.DATA
MSG1 DB 'Enter the first lower case letter of your name= $'
MSG2 DB 'The first upper case letter of your name is= $'
.CODE
MOV AX,@DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,9
INT 21H
MOV AH,1
INT 21H
MOV BL,AL
MOV AH,2
MOV DL,0AH
INT 21H
MOV DL,0DH
INT 21H
LEA DX,MSG2
MOV AH,9
INT 21H
MOV AH,2
MOV CL,20H
SUB BL,CL
MOV DL,BL
INT 21H
Output:
Write a assembly language program to show the first letters of your full name in a column
using character string output.
Program:
.MODEL SMALL
.STACK 100H
.DATA
MSG DB 'Enter the first letters of your full name= $'
.CODE
MOV AX,@DATA
MOV DS,AX
LEA DX,MSG
MOV AH,9
INT 21H
MOV AH,1
INT 21H
MOV BL,AL
MOV AH,1
INT 21H
MOV BH,AL
MOV AH,1
INT 21H
MOV CL,AL
MOV AH,2
MOV DL,0AH
INT 21H
MOV DL,0DH
INT 21H
MOV AH,2
MOV DL,BL
INT 21H
MOV AH,2
MOV DL,0AH
INT 21H
MOV DL,0DH
INT 21H
MOV AH,2
MOV DL,BH
INT 21H
MOV AH,2
MOV DL,0AH
INT 21H
MOV DL,0DH
INT 21H
MOV AH,2
MOV DL,CL
INT 21H
Output:
Discussion: