Beruflich Dokumente
Kultur Dokumente
MNEMONICS
MOV AX, data
MOV BX, data
ADD AX,BX
MOV [1200],AX
HLT
LOOP
MNEMONICS
MOV AX, data
MOV BX, data
MOV CX,0000
ADD AX,BX
JNC LOOP
INC CX
MOV [1200],AX
MOV [1202],CX
HLT
MNEMONICS
MOV AX, data
MOV BX, data
SUB AX,BX
MOV [3580],AX
HLT
LOOP
MNEMONICS
MOV AX, data
MOV BX, data
MOV CX,0000
SUB AX,BX
JNB LOOP
INC CX
MOV [1200],AX
MOV [1202],CX
HLT
MNEMONICS
MOV AX,[1100]
MOV BX,[1102]
MUL BX
MOV [1200],AX
MOV [1202],DX
HLT
Division:
LABEL
MNEMONICS
MOV AX,[1100]
MOV BX,[1102]
DIV BX
MOV [1200],AX
MOV [1202],DX
HLT
Lab 2
Ex.No.2: Introduction to General purpose registers, addressing modes, logical operators of
8086
2.1 Introduction:
The purpose of this experiment is to learn about the general purpose registers, instruction
sets, addressing modes and logical operators of 8086 by finding the larger and the smaller
numbers from an array which is stored in a memory location.
2.2 Hardware Requirement:
The 8086 Microprocessor kit, Power Supply.
2.3 Program Logic:
To find the largest number in any given array, the contents of the array must be compared
with an arbitrary biggest number. The first number of the array is taken in a register AL. The
second number of the array is compared with the first one. If the first one is greater than the
second one, it is left unchanged. However if the second one is greater than the first, the second
number replaces the first one in the AL register. The procedure is repeated for every number in
the array and thus it requires n iterations. At the end of nth iteration the largest number will
reside in the register AL.
For smallest number the above said logic is repeated but, If the first number is smaller
than the second one it is left unchanged. Otherwise the second number replaces the first number
in the AL register
2.4 Program:
Introduction of general purpose registers, logical operators, indirect addressing, and loop
instructions :
Smallest number:
LABEL
LOOP1
MNEMONICS
MOV SI,1100
MOV CL,[SI]
INC SI
MOV AL,[SI]
DEC CL
INC SI
MOV BL,[SI]
CMP AL,BL
JC LOOP2
MOV AL,BL
LOOP2
DEC CL
JNZ LOOP1
MOV [1200],AL
HLT
Largest number:
LABEL
LOOP1
LOOP2
MNEMONICS
MOV SI,1100
MOV CL,[SI]
INC SI
MOV AL,[SI]
DEC CL
INC SI
MOV BL,[SI]
CMP AL,BL
JNC LOOP2
MOV AL,BL
DEC CL
JNZ LOOP1
MOV [1200],AL
HLT
6. Find the values in the destination for each line of this program .
STC
MOV AX,5432H
RCR AL, 1
MOV CL,03
RCL AX,CL
MOV CL,05
ROR AX,CL
ROL AX,1
END
LOOP3
LOOP2
MNEMONICS
MOV SI,1200
MOV CL,[SI]
DEC CL
MOV SI,1200
MOV CH,[SI]
DEC CH
INC SI
MOV AL,[SI]
INC SI
CMP AL,[SI]
JC LOOP1
XCHG AL,[SI]
XCHG [SI-1],AL
LOOP1
DEC CH
JNZ LOOP2
DEC CL
JNZ LOOP3
HLT
Descending order:
LABEL
LOOP3
LOOP2
LOOP1
MNEMONICS
MOV SI,1200
MOV CL,[SI]
DEC CL
MOV SI,1200
MOV CH,[SI]
DEC CH
INC SI
MOV AL,[SI]
INC SI
CMP AL,[SI]
JNC LOOP1
XCHG AL,[SI]
XCHG [SI-1],AL
DEC CH
JNZ LOOP2
DEC CL
JNZ LOOP3
HLT