3 1 Cse Mpi Unit 2
3 1 Cse Mpi Unit 2
3 1 Cse Mpi Unit 2
UNIT-II
2.1) Arithmetic instruction ALPs
2.2) Logical instruction ALPs
2.3) Sorting and String manipulation ALP
103
MPI
numbers.
PROCEDURE:
1. Start the program
2. Move the data byte 39 to AL register
3. Move the data byte 35 to BL register
4. Add the contents BL to the contents of AL. Result will be stored in AL register.
5. Use the instruction AAA to adjust the result to correct unpacked BCD
5. Stop the program by using Interrupt.
PROGRAM: ADDRESS OPCODE
LABEL
MNEMONIC
OPERAND
MOV
AL, 39
MOV
BL, 35
ADD
AL, BL
AAA
INT
104
MPI
LABEL
MNEMONIC
OPERAND
MOV
AL, 39
MOV
BL, 35
SUB
AL, BL
AAS
INT
MNEMONIC OPERAND
MOV
AL, 09
MOV
BL, 06
MUL
BL
AAM
INT
105
MPI
MNEMONIC OPERAND
MOV
AX, 0507
MOV
CH, 09
AAD
DIV
CH
INT
106
MPI
LABEL
MNEMONIC OPERAND
L1:
107
MOV
AX, 0000
MOV
BX, 3050
MOV
DX,0000
MOV
CX,0004
MOV
SI, 3000
MOV
DI,3010
MOV
AX, [SI]
ADC
AX, [DI]
MOV
[BX], AX
INC
SI
INC
SI
INC
DI
INC
DI
INC
BX
INC
BX
DEC
CX
JNZ
L1
MPI
L2:
JNB
L2
INC
DX
INT
LABEL
MNEMONIC OPERAND
108
MOV
AX, 0000
MOV
BX, 3050
MOV
DX,0000
MPI
L1:
L2:
MOV
CX,0004
MOV
SI, 3000
MOV
DI,3010
MOV
AX, [SI]
SBB
AX, [DI]
MOV
[BX], AX
INC
SI
INC
SI
INC
DI
INC
DI
INC
BX
INC
BX
DEC
CX
JNZ
L1
JNB
L2
INC
DX
INT
109
MPI
LABEL
MNEMONIC OPERAND
L1:
MOV
BL, 00
MOV
DL, 01
MOV
CX, 0005
MOV
SI, 2600
MOV
[SI], BL
INC
SI
MOV
[SI], DL
ADD
BL, DL
XCHG
BL, DL
LOOP
L1
INT
110
MPI
LABEL
MNEMONIC OPERAND
L1:
111
MOV
SI, 2500
MOV
DI, 2600
MOV
AX, [SI]
MOV
CX, AX
DEC
CX
MUL
CX
LOOP
LI
MOV
[DI], AX
INT
MPI
112
MPI
LABEL
MNEMONIC OPERAND
MOV
AL, 34
MOV
AH, 12
MOV
BL, AL
MOV
BH, AH
MOV
DI, 3010
AND
AL, 0F
MOV
[DI], AL
INC
DI
MOV
CL, 04
SHR
BL, CL
MOV
[DI], BL
INC
DI
AND
AH, 0F
MOV
[DI], AH
INC
DI
SHR
BH, CL
MOV
[DI], BH
INT
113
MPI
ADDRESS OPCODE
LABEL
MNEMONIC OPERAND
MOV
AX, 1234
MOV
BX, 0FFFF
OR
AX, BX
INT
LABEL
MNEMONIC OPERAND
114
MOV
AX, 0012
MOV
BX, 0FFFF
AND
AX, BX
INT
MPI
ADDRESS OPCODE
LABEL
MNEMONIC OPERAND
MOV
AX, 0FFFF
NOT
AX
INT
LABEL
MNEMONIC OPERAND
115
MOV
AL, 0F
MOV
BL, 00
TEST
AL, BL
INT
MPI
OPERAND
MOV
AX, 0AAAA
MOV
CL, 01
RCL
AX, CL
INT
MNEMONIC OPERAND
MOV
AX, 0AAAA
MOV
CL, 01
116
MPI
AX, CL
INT
MNEMONIC OPERAND
MOV
AX, 0AAAA
MOV
CL, 01
ROL
AX, CL
INT
117
MPI
MNEMONIC OPERAND
MOV
AX, 0AAAA
MOV
CL, 01
ROR
AX, CL
INT
10) Write an 8086 assembly language program for shift arithmetic right
operation.
PROCEDURE:
1. Start the program
2. Move the data AAAA to AX register
3. Move the data 01 to CL register
4. Shift the contents of AX register right by the content of CL times. Result will be stored
in AX register.
5. Stop the program by using Interrupt.
ADDRESS OPCODE LABEL
MNEMONIC OPERAND
MOV
AX, 0AAAA
MOV
CL, 01
SAR
AX, CL
INT
11) Write an 8086 assembly language program for shift left operation.
PROCEDURE:
1. Start the program
2. Move the data AAAA to AX register
3. Move the data 01 to CL register
4. Shift the contents of AX register left by the content of CL times. Result will be stored
in AX register.
5. Stop the program by using Interrupt.
118
MPI
MNEMONIC OPERAND
MOV
AX, 0AAAA
MOV
CL, 01
SHL
AX, CL
INT
MNEMONIC OPERAND
MOV
AX, 0AAAA
MOV
CL, 01
SHR
AX, CL
INT
119
MPI
LABEL
TOP:
BELOW:
MNEMONIC OPERAND
MOV
CX,000A
MOV
SI, 3000
MOV
DI, 4000
MOV
AX, [SI]
ADD
SI, 02
CALL
BELOW
MOV
[DI], AX
ADD
DI, 02
DEC
CX
JNZ
TOP
INT
MOV
BX, 0F0F
AND
AX, BX
120
MPI
LABEL
TOP:
MNEMONIC OPERAND
MOV
CX, 000A
MOV
SI, 3000
MOV
DI, 4000
MOV
AX, [SI]
ADD
SI, 02
CALL
BELOW
121
MPI
BELOW:
MOV
[DI], AX
ADD
DI, 02
DEC
CX
JNZ
TOP
INT
MOV
BX, 3030
OR
AX, BX
RET
122
MPI
LABEL
MNEMONIC OPERAND
L 3:
L2:
123
MOV
DX, 0004
MOV
SI, 2102
MOV
DI, 2102
DEC
DX
MOV
CX, DX
MOV
AX, [SI]
ADD
DI, 02
MPI
L1:
CMP
AX, [DI]
JLE
L1
XCHG
AX, [DI]
LOOP
L2
XCHG
AX, [SI]
ADD
SI, 02
MOV
DI, SI
DEC
DX
JNE
L3
INT
124
MPI
LABEL
MNEMONIC OPERAND
L 3:
L2:
L1:
125
MOV
DX, 0004
MOV
SI, 2102
MOV
DI, 2102
DEC
DX
MOV
CX, DX
MOV
AX, [SI]
ADD
DI, 02
CMP
AX, [DI]
JNL
L1
XCHG
AX, [DI]
LOOP
L2
XCHG
AX, [SI]
ADD
SI, 02
MOV
DI, SI
DEC
DX
JNE
L3
INT
MPI