MICROPROCESSOR: Simulate the program and find the final answer. Identify the purpose of the Program. a. Program No. 1 1. LXI H, 6000H :"Initialize pointer l to first number" 2. LXI D, 6l00H :"Initialize pointer2 to second number" 3. LXI B, 6200H :"Initialize pointer3 to result" 4. STC 5. CMC :"Carry = 0" 6. BACK: LDAX D :"Get the digit" 7. ADD M :"Add two digits" 8. DAA :"Adjust for decimal" 9. STAX.B :"Store the result" 10. INX H :" Increment pointer 1" 11. INX D :"Increment pointer2" 12. INX B :"Increment result pointer" 13. MOV A, L 14. CPI 06H :"Check for last digit" 15. JNZ BACK :"If not last digit repeat" 16. HLT :"Terminate program execution" a. Program No. 2 1. LXI H, 2200H :"Initialize memory pointer l" 2. LXI D, 2300H :"Initialize memory pointer2" 3. MVI C, 32H :"Initialize counter" 4. BACK:MOV A, M :"Get the number" 5. ANI 0lH :"Check for even number" 6. J NZ SKIP :"If ODD, don't store" 7. MOV A, M :"Get the number" 8. STAX D :"Store the number in result list" 9. INX D :"Increment pointer 2" 10. SKIP: INX H :"Increment pointer l" 11. DCR C :"Decrement counter" 12. JNZ BACK :"If not zero, repeat" 13. HLT :"Stop a. Program No. 3 2. LDA 2200H 3. MOV C, A :"Initialize counter" 4. LXI H, 2201H :"Initialize pointer" 5. MVI E, 00 :"Sum low = 0" 6. MOV D, E : "Sum high = 0" 7. BACK: MOV A, M :"Get the number" 8. ANI 0lH :"Mask Bit 1 to Bit7" 9. JZ SKIP :"Don't add if number is even" 10. MOV A, E :"Get the lower byte of sum" 11. ADD M :"Sum = sum + data" 12. MOV E, A :"St ore result in E register" 13. JNC SKIP 14. INR D :"Add carry to MSB of SUM" 15. SKIP: INX H :"Increment pointer"
MICROPROCESSOR:
Simulate the program and find the final answer. Identify the purpose of the Program.
a. Program No. 1
1.
LXI H, 6000H :"Initialize pointer l to first number"
2.
LXI D, 6l00H :"Initialize pointer2 to second number"
3.
LXI B,
6200H :"Initialize pointer3 to result"
4.
STC
5.
CMC :"Carry = 0"
6.
BACK: LDAX D :"Get the digit"
7.
ADD M :"Add two digits"
8.
DAA :"Adjust for decimal"
9.
STAX.B :"Store the result"
10.
INX H :"
Increment pointer 1"
11.
INX D :"Increment pointer2"
12.
INX B :"Increment result pointer"
13.
MOV A, L
14.
CPI 06H :"Check for last digit"
15.
JNZ BACK :"If not last digit repeat"
16.
HLT :"Terminate program
execution"
a.
Program No. 2
1.
LXI H, 2200H :"Initialize memory pointer l"
2.
LXI D, 2300H :"Initialize memory pointer2"
3.
MVI C, 32H :"Initialize counter"
4.
BACK:MOV A, M :"Get the number"
5.
ANI 0lH :"Check for even number"
6.
J
NZ SKIP :"If ODD, don't store"
7.
MOV A, M :"Get the number"
8.
STAX D :"Store the number in result list"
9.
INX D :"Increment pointer 2"
10.
SKIP: INX H :"Increment pointer l"
11.
DCR C
:"Decrement counter"
12.
JNZ BACK :"If not zero, repeat"
13.
HLT :"Stop
a.
Program No. 3
2.
LDA 2200H
3.
MOV C, A :"Initialize counter"
4.
LXI H, 2201H :"Initialize pointer"
5.
MVI E, 00 :"Sum low = 0"
6.
MOV D, E :
"Sum high = 0"
7.
BACK: MOV A, M :"Get the number"
8.
ANI 0lH :"Mask Bit 1 to Bit7"
9.
JZ SKIP :"Don't add if number is even"
10.
MOV A, E :"Get the lower byte of sum"
11.
ADD M :"Sum = sum + data"
12.
MOV E, A :"St
ore result in E register"
13.
JNC SKIP
14.
INR D :"Add carry to MSB of SUM"
15.
SKIP: INX H :"Increment pointer"
Step by step
Solved in 3 steps