Please refer to slides and Primer boards lessons
- If the switch S7 of the input PORT0 connected to the data line D7 is at logic 1 and the other switches are at logic 0, specify the contents of the accumulator when the instruction IN PORT0 is executed.
MVI A,9FH
IN PORT0
MOV B,A
OUT PORT1
HLT - Specify the output at PORT1 and the contents of the register B after executing the instructions in Problem #1.
- Specify the register contents and the flag status as the following instructions are executed.
A C S Z CY
XX XX 0 0 0
MVI A,5EH
ADI A2H
MOV C,A - Specify the register contents and the flag status as the following instructions are executed.
A B S Z CY
XX XX X X X
SUB A
MOV B,A
DCR B
INR B
SUI 01H - Write a program to
a. clear the accumulator
b. add 47H (use ADI instruction)
c. subtract 92H
d. add 64H
e. display the results after subtracting 92H and after adding 64H - Specify the register contents and the flag status as the following instructions are executed
A B S Z CY
XX XX 0 0 0
XRA A
MVI B,4AH
SUI 4FH
ANA B - What is the output at PORT1 when the following instructions are executed?
MVI A,8FH
ADI 72H
JC DSPLAY
OUT PORT1
HLT
DSPLAY: XRA A
OUT PORT1
HLT
Answers.
- The data on A after the instruction IN PORT0 is executed will be the same as the data read on PORT0. Thus, the data on A will be equal to 80H.
- The data on register A will be copied to register B. So, the data on register B will be 80H. After the instruction OUT PORT1, the data on Register A will be outputted in PORT1. Thus, PORT1 would also show 80H or 1000 0000.
- A C S Z CY
XX XX 0 0 0
MVI A,5EH 5EH xx 0 0 0
ADI A2H 00H xx 0 1 1
MOV C,A 00H 00H 0 1 1 - A B S Z CY
XX XX X X X
SUB A 00H XX 0 1 0
MOV B,A 00H 00H 0 1 0
DCR B 00H FFH 1 0 1
INR B 00H 00H 0 1 0
SUI 01H FFH 00H 1 0 1 - SUB A
ADI 47H
SUI 92H
OUT PORT0
ADI 64H
OUT PORT0
HLT - A B S Z CY
XX XX 0 0 0
XRA A 00H XX 0 1 0
MVI B,4AH 00H 4AH 0 1 0
SUI 4FH C0H 4AH 1 0 1
ANA B 40H 4AH 0 0 0 - The Carry flag will be set after the instruction ADI 72H, so when the JC DISPLAY is executed it will jump to DISPLAY. XRA A will reset the accumulator. Thus, the output in PORT1 will be 00H.