Program No.
1 :
a) Program Name : Write a program that subtracts the number stored in 2021 from the number stored
in 2020. Store the absolute difference in memory location 2022 as result.
b) Enter the program on the microprocessor kit.
c) Execute the program for a positive as well as negative difference. Write the contents of data memory
loction before and after execution as well as the contents of the register used in the program afeter
execution and also the bit contents of all five flags individually. Verify the results.
Start
>
Load accumulator from memory
location 2000 H
>
Subtract 2021 H from
accumulator
>if N
A>0 > Store oH in A
Y
>
Store value of A in location 2022 H
>
Stop
Program :
Memory Label Instruction Opcode Comments
Addess
2000 LXI H 2020 H 21,00,20 Load 2000 H in H-L pair
2003 MOV A, M 7E Store M in A
2004 INX H 23 Increment H-L pair
2005 SUB M 96 Sum M from A
2006 JC neg DA,0D,20 Jump to neg if carry
2009 pos STA 2022 H 32,22,20 Store A at 2022 H
200C HLT 76 Stop
200D neg SUB A 97 Move 00 h in A
200E JMP pos C3,09,20 Jump to pos
Output : Memory Location Data
2020 CD H
2021 AB H
Result : 2022 22 H
Program No 2 :
Program Name : A block of data is stored in memory location from 2020 H to 2023 H.Write a progarm to
find the greatest number from this block using Linear Search.Store the result immediately after the end
of the block.
b) Execute the same on the microprocessor kit.
c) Execute the same. Write the contents of data memory locationsbefore and after execution as well as
the contents of the registers used in the program after execution and also the bit contents of all five
flags individually. Verify the result.
Flowchart :
Start
>
Initialize H-l pair
>
Get count in C
>
Get first No. in accumulator
>
>
Yes Is No. in
accumulator >
next No.
No
>
Get large No. in accumulator
>
>
Decrement count
>
> No Is count = 0
Yes
>
Store Result
>
Stop
Program :
Memory Label Instruction Opcode Comments
Addess
2000 LXI H,2020 H 21,20,20 Load 2000 H in H-L pair
2003 MOV C , M 4E Count in register C
2004 INX H 23 Incrment H-L pair
2005 MOV A, M 7E Get number in acumulator from memory
2006 DCR C 0D Decrement Reg. C
2007 loop INX H 23 Incrment H-L pair
2008 CMP M BE Compare next no with previous no.
is next no > previous number
2009 JNC ahead D2,0D,20 No. Large no. is in the accumlator
go to the next label ahead
200C MOV A, M 7E Yes. Get large no. in accumulator
200D ahead DCR C 0D Decremnet count
200E JNZ loop C2,07,20
2011 STA 2120 H 32,20,21 Store the result in 2120 H
2014 HLT CF Stop
Output : Memory Location Data
2020 03
2021 40
2022 65
2023 75
Result : 2120 75
Program No 3 :
Program Name : A block of data is stored in memory location from 2020 H to 2023 H.Write a progarm to
find the smallest number from this block using Linear Search.Store the result immediately after the end
of the block.
b) Execute the same on the microprocessor kit.
c) Execute the same. Write the contents of data memory locationsbefore and after execution as well as
the contents of the registers used in the program after execution and also the bit contents of all five
flags individually. Verify the result.
Start
>
Initialize H-l pair
>
Get count in C
>
Get first No. in accumulator
>
>
Yes Is No. in
accumulator <
next No.
No
>
Get large No. in accumulator
>
>
Decrement count
>
> No Is count = 0
Yes
>
Store Result
>
Stop
Program :
Memory Label Instruction Opcode Comments
Addess
2000 LXI H,2020 H 21,20,20 Load 2000 H in H-L pair
2003 MOV C , M 4E Count in register C
2004 INX H 23 Incrment H-L pair
2005 MOV A, M 7E Get number in acumulator from memory
2006 DCR C 0D Decrement Reg. C
2007 loop INX H 23 Incrment H-L pair
2008 CMP M BE Compare next no with previous no.
is next no > previous number
2009 JC ahead DA,0D,20 No. Large no. is in the accumlator
go to the next label ahead
200C MOV A, M 7E Yes. Get large no. in accumulator
200D ahead DCR C 0D Decremnet count
200E JNZ loop C2,07,20
2011 STA 2120 H 32,20,21 Store the result in 2120 H
2014 HLT CF Stop
Output : Memory Location Data
2020 03
2021 15
2022 11
2023 12
Result : 2120 11
Program No 4 :
Program Name : A block of data is stored in memory location from 2021 H. The length of the block is
stored at 2020 H. Write a progarm that sorts the given data in ascending order.
b) Execute the same on the microprocessor kit.
c) Execute the same. Write the contents of data memory locations before and after execution as well as
the contents of the registers used in the program after execution and also the bit contents of all five
flags individually. Verify the result.
Program :
Memory Label Instruction Opcode Comments
Addess
2000 Sort LXI H,2020 H 21,20,20 Load 2000 H in H-L pair
2003 MOV C , M 4E Get no. in register C
2004 DCR C 0D Decrement Reg. C
2005 MVI B, 00 H 06,00 Get number in acumulator from memory
2007 INX H 23 Incrment H-L pair
2008 pass MOV A M 7E Get no. in accumulator
2009 INX H 23 Increment H-L pair
200A CMP M BE Compare next no with greatest no.
in accumulator
200B JC ahead DA,15,20 No. greatest no. is in the accumlator
go to the next label ahead
200E MOV D, M 56 Get no. in reg, D
200F MOV M ,A 77 Store in accumulator
2010 DCX H B Decrement H-L pair
2011 MOV M, D 72 Get contents of register D in memory
2012 INX H 23 Increment H-L pair
2013 MVI B, 01 H 06,01 Get next no. in reg. B
2015 ahead DCR C 0D Decrement reg. C
2016 JNZ pass C2,08,20 No. Jump to take next no.
2019 DCE B 05 Decrement reg. C
201A JZ sort CA,00,20
201D HLT CF Stop
Output : Memory Location Data Output
2020 05
2021 12 04
2022 54 12
2023 04 45
2024 A9 54
2025 45 A9
Program No 5 :
Program Name : A block of data is stored in memory location from 2021 H. The length of the block is
stored at 2020 H. Write a progarm that sorts the given data in descending order.
b) Execute the same on the microprocessor kit.
c) Execute the same. Write the contents of data memory locations before and after execution as well as
the contents of the registers used in the program after execution and also the bit contents of all five
flags individually. Verify the result.
Program :
Memory Label Instruction Opcode Comments
Addess
2000 Sort LXI H,2020 H 21,20,20 Load 2000 H in H-L pair
2003 MOV C , M 4E Get no. in register C
2004 DCR C 0D Decrement Reg. C
2005 MVI B, 00 H 06,00 Get number in acumulator from memory
2007 INX H 23 Incrment H-L pair
2008 pass MOV A M 7E Get no. in accumulator
2009 INX H 23 Increment H-L pair
200A CMP M BE Compare next no with smallest no.
in accumulator
200B JNC ahead DA,15,20 No. Smallest no. is in the accumlator
go to the next label ahead
200E MOV D, M 56 Get no. in reg, D
200F MOV M ,A 77 Store in accumulator
2010 DCX H B Decrement H-L pair
2011 MOV M, D 72 Get contents of register D in memory
2012 INX H 23 Increment H-L pair
2013 MVI B, 01 H 06,01 Get next no. in reg. B
2015 ahead DCR C 0D Decrement reg. C
2016 JNZ pass C2,08,20 No. Jump to take next no.
2019 DCE B 05 Decrement reg. C
201A JZ sort CA,00,20
201D HLT CF Stop
Output : Memory Location Data Output
2020 03
2021 11 14
2022 14 11
2023 01 01
Program No 6 :
Program Name : Write a progarm that multiplies two 1 byte hex nubers stored in consecutive memory
location starting from 2020 H. Store the 2 byte result in consecutive memory location starting from
2022 H begining with lower order byte.
b) Execute the same on the microprocessor kit.
c) Execute the same. Write the contents of data memory locations before and after execution as well as
the contents of the registers used in the program after execution and also the bit contents of all five
flags individually. Verify the result.
Start
>
Load B with value of location 2020 H
>
Initialize H-L pair by 2021 H & A, C with 00 H
>
>
>
Add contents of 2021 H in accumulator
>
Add acrry to C & decrement B by 1
>
N
if B >0 >
Y
>
Store A, C i.e result in memory
>
Stop
Memory Label Instruction Opcode Comments
Addess
2000 Start LXI H,2020 H 21,20,20 Load 2020 H in h-L pair
2003 MOV B, M 46 Load B by M
2004 INX H 23 Increment H-L pair
2005 MVI C, 00 H 0E Initialize C by 00 H
2007 SUB A 97 Initialize A by 00 H
2008 repeat ADD M 86 Add M in A
2009 JNC next D2 Jump to next if not carry
200C INR C 0C Increment Reg. C
200D next DCR B 05 Decrement Reg. B
200E JNZ repeat C2,08,20 Jump to repeat if not zero
2011 INX H 23 Increment H-L pair
2012 MOV M, A 77 Move A in memory
2013 INX H 23 Increment H-L pair
2014 MOV M , C 71 Move C in memory
2015 HLT 76 Stop
Output : Memory Location Data
2020 02 H
2021 02 H
Result 2022 04 H
2023 00 H
Program No 7:
Program Name : Write a progarm that divides two 1 byte hex numbers where the dividend is stored in
2020 H and divisor is stored in 2021 H. Store the quotient and the reminder in th next memory location
respectively.
b) Execute the same on the microprocessor kit.
c) Execute the same. Write the contents of data memory locations before and after execution as well as
the contents of the registers used in the program after execution and also the bit contents of all five
flags individually. Verify the result.
Start
>
Load A with value of location 2020 H
>
Store 0H in B & 2021 H in H-L pair
>
>
>
Subtract value of memory from A
>
N
if A < 0 > Increment B
Y
>
Add M in A
>
Store quotient & reminder in memory
>
Stop
Memory Label Instruction Opcode Comments
Addess
2000 Start LXI H,2020 H 21,20,20 Load 2020 H in h-L pair
2003 MOV A, M 7E Load A by M
2004 INX H 23 Increment H-L pair
2005 MVI B, 00 H 0E Initialize B by 00 H
2007 minus SUB M 96 Subtract m from A
2008 JC end DA,0F,20 Jump to end if carry
200B INR B 04 Increment Reg. B
200C JMP minus C3,07,20 Jump to minus
200F end ADD M 86 Add M in Reg. A
2010 INX H 23 Increment H-L pair
2011 MOV M , B 70 Move contents of B to M register
2012 INX H 23 Increment H-L pair
2013 MOV M , A 77 Move A in memory
2014 HLT 76 Stop
Output : Memory Location Data
2020 05 H
2021 02 H
Result 2022 02 H
2023 01 H