All Cs 2 Programs
All Cs 2 Programs
All Cs 2 Programs
To find out 2's complement of five numbers stored from memory locations 6000H onwards .store the result from
memory location 6100H.(Before execution store 11H,22H,33H,44H,55H from 6000 to 6004H)
Before Execution:-
After Execution:-
Result:-
Program Executed successfully.
Program 2
To count the number of odd data bytes occurring in a block .Store the result at the memory location
7600H.(Before execution store 01 to 0A from 7501 to 750AH).
Address Label Mnemoics Opcode Comments
2000 start LXI H,7501 21 initialise HL pointer with address 7501H
2001 O1
2002 75
2003 MVIC,0A 0E initialise counter reg c with 0A
2004 0A
2005 MVI B,00H O6 initialise counter reg B with OO
2006 OO
2007 loop MOV A,M 7E get the number in accumalator
2008 RRC 0F Rotate right to determine odd or even
2009 JNC D2 is carry? No jump to next label
200A 0D
200B 20
200C INR B O4 increment odd counter reg B
200D next INX H 23 increment HL pointer
200E DCR C 0D decrement counter reg c
200F JNZ loop C2 is count zero ? No jump to loop
2010 O7
2011 20
2012 MOV A,B 78 get odd count in accumalator
2013 STA 7600H 32 store contents of accumalator to M.L. 7600H
2014 OO
2015 76
2016 End HLT 76 stop processing
Output:-
Before Execution:-
Result:-
Program Executed successfully.
Program 3
To fill the memory block of 10 memory locations starting from 6000H with data 00H and FFH at every alternate
memory locations.
Address Label Mnemoics Opcode Comments
2000 start MVI C,0AH 0E initialise counter reg c by 0AH.
2001 0A
2002 MVI D,00H 16 initialise reg D with immediate data 00H
2003 OO
2004 MVI E,FFH 1E initialise reg E with immediate data FFH
2005 FFH
2006 LXI H,6000H 21 initilse HL pointer with M.L. 6000H
2007 OO
2008 60
2009 loop MOV M,D 72 fill 00H in M.L. pointed byHL pair
200A DCR C 0D decrement counter reg c
200B INX H 23 increment HL pointer
200C MOV M,E 73 fill FFH in M.L. pointed by HL pair
200D INX H 23 increment HL pointer
200E DCR C 0D decrement counter reg c
200F JNZ loop C2 is count zero ? No jump to loop
2010 O9
2011 20
2012 End HLT 76 stop processing
Output:-
After Execution:-
Result:-
Program Executed successfully.
Program 4
To add the three decimal numbers stored in different memory locations . Store the result at memory location
6203H.(Before execution store data 15,25 and 45 at 6200H ,6201H and 6202H respectively).
Address Label Mnemoics Opcode Comments
2000 start LXI H,6200H 21 initialise HL pointer
2001
2002
2003 MOV A,M 7E get first data in acc
2004 INX H 23 increment HL pointer
2005 ADD M 86 add content of memory with accumalator
2006 INX H 23 increment HL pointer
2007 ADD M 86 add content of memory with accumalator
2008 DAA 27 decimally adjust accumalator
2009 INX H 23 increment HL pointer
200A MOV M,A 77 copy the result to the M.L. 6203H
200B end HLT 76 stop the microprocessor
Output:-
Before Execution:-
After Execution:-
Result:-
Program Executed successfully.
Program 5
To multiply two 8 bit number in memory location 6200H and 6201H store two byte result in consecutive memoru
locations starting from 6000H.(Before execution store 09H in 6200H and 0EH 6201H )
After Execution:-
Result:-
Program Executed successfully.
Program 6
To interchange the nibbles of accumalator containing data 96h and store result at 6200H.
Output:-
Before Execution :-
[A]=96H
After Execution :-
[A]=69H
Result :-
To count the no of 1's and 0's in a 8 bit binary number . Store the count of 0's and 1's in M.L. 6001 and 6002H
repectively.
Output:-
Before Execution :-
After Execution :-
Result :-
Program Executed Successfully
Program 8
To fill memory locations starting from 6000 onwards with decimal numbers from 0 to 19.
After Execution:-
Result :-
Program Executed successfully.
Program 9
To transfer data in reverse order stored in consecutive memory location . Store result in next consecutive order memory
location.(Before execution store data in M.L. 6000H to 6009H
Result :-
To find largset number among given block stored from M.L. 6100H .Store the largest number in M.L. 6100H .(Before
execution store data from 6100H to 610AH).
Before Execution :-
After Execution:-
Memory location Data
6100H 11H
Program 11
To find smallest number among given block stored from memory location 6100H.Store the largest number in M.L.
6100H.(Before execution store data from 6100H to 610AH)
Before Execution :-
After Execution:-
Memory location Data
6100H O1H
Result:-
Program Executed successfully
Program 12
To exchange the content of given two blocks . The length of block is stored in M.L. 6100H.(Before execution stored data from 6101H to
6105H and 7101H to 7105H).
Result :-
program executed successfully.
Program 13
To find first occurrence of data O5H in given block.Store the address of this occurrence in HL pair.If the no is not
found then store FFFFH in HL pair . The length of block is stored in memory location 6100H(Before execution store
data from 6100H to6106H).
Address Label Mnemoics Opcode Comments
2000 start LXI H,6100H 21 initialise HL pointer
2001 OO
2002 60
2003 MOV C,M 4E move the length counter in reg c
2004 MVI A,O5 3E Initialise accumalator with O5
2005 O5
2006 INX H 23 increment HL pointer
2007 loop CMP M BE compare contents of HL pointer with accumalator
2008 JZ end CA is equal? Yes jump to end
2009 13
200A 20
200B INX H 23 increment HL pointer
200C DCR C decrement counter register c
200D JNZ loop C2 is zero? No jump to loop
200E O7
200F 20
2010 LXI,FFFFH 21 store HL pair with FFFFH
2011 FF
2012 FF
2013 end HLT 76 stop
output:-
Before Execution
After Execution:-
Memory Location Data
HL->6102H O5H
Result:-
Program Executed successfully.
Program 14
To count the number of times a data is found in a block of memory location starting from address 6100HThe length of
block is stored in memory location 6100.Store occuerrence counter to memory location 7100H.
Output :-
Before Execution:-
Memory Location Data After Execution:-
6100H O6H Memory Location Data
6101H 12H 7100H O3H
6102H 05H
6103H 09H Result:-
6104H 05H Program Executed successfully.
6105H 10H
6106H O5H
Program 15
To count the numbe of even data bytes occurring in a block starting from the memory location 6001 to 600A .Before
execution store data from 6001 to 600AH.
Address Label Mnemoics Opcode Comments
2000 START LXI H,6001 21 initialise HL pointer with m.l.6001
2001 O1
2002 60
2003 MVI C,OAH OE initialise counter register C with data OAH
2004 OA
2005 MVI B,OOH O6 initialise even counter reg B with 00H
2006 OO
2007 LOOP MOV A,M 7E get data in accumalator from memory
2008 RRC OF rorate accumalator content right to count even data byte
2009 JC NEXT OA jump to label next if carry
200A OD
200B 20
200C INR B O4 increment counter register B
200D NEXT INX H 23 increment HL pointer
200E DCR C OD decrement length counter reg c
200F JNZ LOOP C2 jump to label loop if counter not zero
2010 O7
2011 20
2012 MOV A,B 78 get even counter in accumalator
2013 STA 6100 32 Store even counter to memory location 6100H.
2014 OO
2015 61
2016 END HLT 76 stop processing
Output:-
Before Exectuion After Execution:-
Before Execution:-
Result:-
Program executed successfully.