Professional Documents
Culture Documents
WAP to add two 16-bit number(4150 H- 4153 H) and store the result in 4160 H - 4162 H
in 8085 p by using(Consider carry)
i) ADD instruction
ii) DAD instruction
(i)ADD INSTRUCTION
MVI C,00 H
LDA 4150 H
MOV B,A
LDA 4152 H
ADD B
STA 4160 H
LDA 4151 H
MOV D,A
LDA 4153 H
ADC D
JNC NEXT
INR C
NEXT: STA 4161 H
MOV A,C
STA 4162 H
HLT
(ii)DAD Instruction
MVI C,00 H
LHLD 4150 H
XCHG
LHLD 4152 H
DAD D
JNC NEXT
INR C
NEXT: SHLD 4160 H
MOV A,C
STA 4162 H
HLT
2. Q2: WAP to add two 8-bit number(4150H & 4151H) and store the result in 4160H &
4161H in 8085 p by using (consider carry)
i) ADD instruction
ii) DAD instruction
iii) SUB instruction
iv) Increment instruction
(i)ADD INSTRUCTION
MVI C,00 H
LDA 4150
MOV B,A
LDA 4151
ADD B
JNC NEXT
INR C
STA 4160 H
MOV A,C
STA 4161H
HLT
(II)USING DAD
LHLD 4150
MOV E,H
MVI D,00
MVI H,00
DAD D
SHLD 4160
HLT
(iii) USING SUB
LDA 4150H
MOV B,A
LDA 4151H
LXI D,00H
CMA
INR A
MOV C,A
MOV A,B
SUB C
JNC CODE
INR D
CODE : STA 4160H
MOV A,D
STA 4161H
HLT
(iv)INCREMENT INSTRUCTION
LXI H,4150H
MOV A,M
INX H
MOV B,M
MVI C,00
AGAIN: INR A
JNZ NEXT
INR C
NEXT: DCR B
JNZ AGAIN
LXI H,4160
MOV M,A
INX H
MOV M,C
HLT
Q3. WAP to add one 16-bit number(4150H-4151H) and one 8-bit number(4152H) and store
the result in 4160H & 4161H in 8085 p by using
i) ADD instruction
ii) DAD instruction
iii) SUB instruction
iv) Increment instruction
(i)ADD instruction
LOOP
SKIP
LDA 4151H
MOV D,A
LDA 4150H
MOV C,A
LDA 4152H
MOV B,A
MOV A,C
INR A
JNC
SKIP
INR D
DEC B
JNZ LOOP
STA 4160H
MOV A,D
STA 4161H
HLT
iv)Using SUB :LDA 4151 H
MOV B,A
LDA 4152H
CMA
INR A
MOV C,A
LDA 4150H
SUB C
JNC SKIP
DCR B
STA 4160
MOV A,B
STA 4161
HLT
Q4 WAP to subtract two 16-bit number(4150 H- 4153 H) and store the result in 4160 H 4161 H in 8085 p by using
i) ADD instruction
ii) DAD instruction
iii) SUB instruction
(i)ADD instruction
LHLD 4150
XCHG
LHLD 4152
MOV A,E
ADD L
STA 4160
MOV A,D
ADC H
STA 4161
HLT
(ii)DAD instruction
LHLD 4150
XCHG
LHLD 4152
DAD D
SHLD 4160
HLT
(ii)SUB Instruction
LHLD 4150
XCHG
LHLD 4152
MOV A,E
CMA
INR A
MOV E,A
MOV A,L
SUB E
STA 4160
MOV A,D
CMA
INR A
MOV D,A
MOV A,H
SUB D
STA 4161
HLT
Q5-WAP to subtract two 8-bit number(4150H & 4151H) and store the result in 4160H in
8085 p by using
i) ADD instruction
ii) DAD instruction
iii) SUB instruction
iv) Increment instruction
(i)ADD instruction
LDA 4151
CMA
INR A
MOV B,A
LDA 4150
ADD B
STA 4160
HLT
(ii)DAD Instruction
LDA 4151
CMA
INR A
MOV E,A
LDA 4150
MOV L,A
MVI H,00
MVI D,00
DAD D
SHLD 4160
HLT
(iii)SUB Instruction
LDA 4151
MOV B,A
LDA 4150
SUB B
STA 4160
HLT
(iv)Increment Instruction
LDA 4150
MOV B,A
LDA 4151
AGAIN:DCR A
DCR B
JNZ AGAIN
STA 4160
HLT
Q6.WAP to subtract 16-bit number(4150H-4151H) from 8-bit number(4152H) and store
the result in 4160H in 8085 p by using
i) ADD instruction
ii) DAD instruction
iii) SUB instruction
iv) Increment instruction
(i)ADD Instruction
LDA 4152
CMA
INR A
MOV E,A
LDA 4153
CMA
INR A
MOV D,A
LDA 4150
ADD E
STA 4160
LDA 4151
ADD D
STA 4161
HLT
(ii)DAD Instruction
LDA 4152
CMA
INR A
MOV E,A
LDA 4153
CMA
INR A
MOV D,A
LHLD 4150
DAD D
SHLD 4160
HLT
(iii)SUB Instruction
LDA 4152
MOV E,A
LDA 4153
MOV D,A
LDA 4150
SUB E
STA 4160
LDA 4151
SBB D
STA 4161
HLT
7.WAP to multiply two 8-bit number(4150H-4151H) and store the result in 4160H & 4161H
in 8085 p by using
i) ADD instruction
ii) without ADD instruction
SUB INSTRUCTION
ADDRESS MNEMONICS
4100
LXI H, 4150
4103
MOV B,M
4104
MVI C,00
4106
INX H
4107
MOV A,M
4108
CMP B
4109
JC 4112
410C
SUB B
410D
INR C
410E
JMP 4108
4112
STA 4160
4115
MOV A,C
4116
STA 4161
4119
HLT
LXI H, 4150
MOV B,M
MVI C,00
INX H
MOV A,M
CMP B
JC LOOP
MOV A,B
CMA
MOV B,A
INR B
MOV A,M
ADD B
INR C
JMP NEXT
STA 4160
MOV A,C
STA 4161
HLT
Q9.WAP to multiply a 16-bit number(4150H-4151H) with a 8-bit number(4153H) and
store the result in 4160H-4162H in 8085 p.
LHLD 4150H
XCHG
LDA 4153H
MOV C,A
LXI
H,0000H
MVI
B,00H
NEXT: DAD
D
JNC
GOTO
INR
B
GOTO: DCR
C
JNZ
NEXT
SHLD 4160H
MOV A,B
STA 4162H
HLT
Q10. WAP to find the 8-bit largest and smallest no. from an array (4150H-4159H) and
store the result in 4160H (largest) and 4161H(smallest) in 8085 p.
LXI H,4150
MVI C,09
MOV D,M//LARGEST
MOV B,M//SMALLEST
GO: MOV A,M
CMP D
JC NEXT
MOV D,M
NEXT:CMP B
JNC GO
MOV B,M
INX H
DCR C
JNZ GO
MOV A,D
STA 4160
MOV A,B
STA 4161
HLT
(OR)
LXI H,4150
MVI C,09
MOV A,M
MVI D,00//LARGEST
MVI B,M//SMALLEST
AGAIN:INX H
CMP M
JNC NEXT
MOV A,M
DCR C
JNZ AGAIN
STA 4160
MOV A,B
STA 4161
HLT
NEXT:MOV D,A
MOV A,M
CMP B
JC REPEAT
MOV B,M
REPEAT:MOV A,D
DCR C
JNZ AGAIN
STA 4160
MOV A,B
STA 4161
HLT
11. WAP to count how many even numbers are present in an array (4150H-4159H) and store
the result in 4160H in 8085 p.
check 0th bit(1st) AND 01(00000001)
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE NO. OF EVEN NO
AGAIN:MOV A,M
ANI 01
JNZ NEXT
INR B
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
HLT
12. WAP to count how many odd numbers are present in an array (4150H-4159H) and store
the result in 4160H in 8085 p.
check 0th bit(1st) AND 01(00000001)
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE NO. OF EVEN NO
AGAIN:MOV A,M
ANI 01
JZ NEXT
INR B
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
HLT
13. WAP to count how many negative numbers are present in an array (4150H-4159H) and
store the result in 4160H in 8085 p.
check 7th bit(8 no.) AND 80(10000000)
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE NO. OF -VE NO
AGAIN:MOV A,M
ANI 80
JZ NEXT
INR B
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
HLT
14. WAP to count how many positive numbers are present in an array (4150H-4159H) and
store the result in 4160H in 8085 p.
check 7th bit(8no.) AND 80(10000001)
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE NO. OF +VE NO
AGAIN:MOV A,M
ANI 80
JNZ NEXT
INR B
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
HLT
15. WAP to count how many numbers are present in an array (4150H-4159H) whose contain
even number of ones and store the result in 4160H in 8085 p.
checking parity flag do some mathematic operation because data transfer no flag
affected
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE NO. OF
AGAIN:MOV A,M
ANI FF
JPO NEXT// JUMP IF PF=0
INR B
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
HLT
16. WAP to count how many numbers are present in an array (4150H-4159H) whose contain
odd number of ones and store the result in 4160H in 8085 p.
checking parity flag do some mathematic operation because data transfer no flag
affected
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE NO. OF
AGAIN:MOV A,M
ANI FF
JPE NEXT// JUMP IF PF=1
INR B
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
HLT
17. WAP to find 55H present in the array(4150H-4159H) or not if present how many times it
is present in the array and store the result in 4160H in 8085 p.
compare with 55h
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE NO. OF
AGAIN:MOV A,M
CPI 55
JNZ NEXT// JUMP IF ZF=0
INR B
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
HLT
18. WAP to count how many numbers are present in the array (4150H-4160H) whose 5th bit is
one and store the result in 4160H in 8085 p.
check 5th bit(6NO.) means AND 20(00100000)
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE NO. OF
AGAIN:MOV A,M
ANI 20
JZ NEXT// JUMP IF ZF=1
INR B
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
HLT
19. WAP to add all the number present in the array (4150H-4160H) and store the result in
4170H &4171H in 8085 p.
LXI H,4150
MVI C,09//COUNTER
MVI B,00//CARRY
MOV A,M
AGAIN:INX H
ADD M
JNC NEXT
INR B
NEXT:DCR C
JNZ AGAIN
STA 4160
MOV A,B
STA 4161
HLT
20. WAP to add all the elements present in the array (4150H-4159H) whose 4 th bit is one and
store the result in 4160H and 4161H in 8085 p.
check 4th bit then add ANI 10(00010000)
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// result
MVI D,00//CARRY
AGAIN:MOV A,M
ANI 10
JZ NEXT// JUMP IF ZF=1
MOV A,M
ADD B
JNC GO
INR D
GO: MOV B,A
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
HLT
21. WAP to find the square of a number which is present in 4150H location and store the
result 4160H & 4161H in 8085 p.
multiply same number
LXI H,4150
MOV B,M
MOV C,B
MVI A,00
MVI D,00
AGAIN:ADD B
JNC GO
INR D
GO:
DCR C
JNZ AGAIN
STA 4160
MOV A,D
STA 4161
HLT
22. WAP to find the cube of a number which is present in 4150H location and store the result
4160H & 4161H in 8085 p.
LXI H,4150
MOV B,M
MOV C,M
MVI A,00
MVI D,00
AGAIN:ADD B
JNC GO
INR D
GO:
DCR C
JNZ AGAIN
MVI A,00
MVI C,M
AGAIN1:ADD B
JNC GO1
INR D
GO1: DCR C
JNZ AGAIN1
STA 4160
MOV A,D
STA 4161
HLT
23. WAP to find the largest number from an array (4150H-4159H) and store the result in
4160H in 8085 p without using CMP instruction.
using SUB instruction
LXI H,4150
MVI C,09
MOV D,M//LARGEST
MOV A,M
GO: INX H
SUB M
JNC NEXT
MOV D,M
NEXT:MOV A,D
DCR C
JNZ GO
MOV A,D
STA 4160
HLT
24. WAP to swap the ten 8-bit data between 4150H-4159H and 4160H-4169H in 8085 p.
LXI H,4150//address of source array
LXI B,4160// address of destination array
MVI C,0A//carry
NEXT:MOV A,M
STAX B
INX H
INX B
DCR C
JNZ NEXT
HLT
25. WAP to count how many numbers are present in the array (4150H-4159H) which is
divisible by four and store the result in 4160H in 8085 p.
IF first two bit zero then divisible by four AND 02(00000011)
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE NO. divisible by 4
AGAIN:MOV A,M
ANI 02
JNZ NEXT
INR B
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
HLT
26. WAP to count how many numbers are present in the array (4150H-4159H) which is
divisible by eight and store the result in 4160H in 8085 p.
IF first three bit zero then divisible by eight AND 07(00000111)
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE NO. divisible by 8
AGAIN:MOV A,M
ANI 07
JNZ NEXT
INR B
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
HLT
27. WAP to count how many numbers are present in the array (4150H-4159H) which is
divisible by sixteen and store the result in 4160H in 8085 p.
IF first four bit zero then divisible by eight AND 0F(00001111)
LXI H,4150
MVI C,0A//COUNTER
HLT
31. WAP to add all the even numbers are present in an array (4150H-4159H) and store the
result in 4160H & 4161H in 8085 p.
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE ADDITION RESULT
MVI D,00// CARRY
AGAIN:MOV A,M
ANI 01
JNZ NEXT
MOV A,M
ADD B
JNC GO
INR D
GO: MOV B,A
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
MOV A,D
STA 4161
HLT
32. WAP to add all the odd numbers are present in an array (4150H-4159H) and store the
result in 4160H & 4161H in 8085 p.
LXI H,4150
MVI C,0A//COUNTER
MVI B,00// STORE ADDITION RESULT
MVI D,00// CARRY
AGAIN:MOV A,M
ANI 01
JZ NEXT
MOV A,M
ADD B
JNC GO
INR D
GO: MOV B,A
NEXT:INX H
DCR C
JNZ AGAIN
MOV A,B
STA 4160
MOV A,D
STA 4161
HLT
33. WAP to add all the negative numbers are present in an array (4150H-4159H) and store the
result in 4160H & 4161H in 8085 p.
LXI H,4150
MVI C,0A//COUNTER