Latest

6/recent/ticker-posts

SOLUTION OF CHAPTER 6 RAMESH GAONKAR- INTRODUCTION TO 8085 INSTRUCTIONS

 SECTION:6.1

1. Specify the contents of the registers and the flag status as the following instructions are executed.

    B     C    D    S     Z    CY

MVI A,00H

MVI B,F8H

MOV C,A

MOV D,B

HLT

Solution:

A=00H

B=F8H

C=00H

D=F8H

S=NA

Z=NA

CY=NA

3.Write the instructions to load the hexadecimal number 65H in register C, and 92H in the accumulator A. Display the number 65H at PORT0 and 92H at PORT1.

Solution:

MVI C,65H

MVI A,92H

OUT PORT1

MOV A,C

OUT PORT0

HLT

4. Write instructions to read the data at input PORT 07H and at PORT 08H. Display the input data from PORT 07H at output PORT 00H, and store the input data from PORT 08H in register B.

Solution:

IN 07H

OUT 00H

IN 08H

MOV B,A

HLT

5. Specify the output at PORT1 if the following program is executed.

MVI B,82H

MOV A,B

MOV C,A

MVI D,37H

OUT PORT1

HLT

Solution:

82 H (because only the contents of accumulator register is displayed in the output port.)

6. If the switch S7 of the input PORT0 connected to the data line D7 is at logic 1 and 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



Solution: Accumulator content in binary will be=(10000000)2

                                                                             =80 H

7. Specify the output at PORT1 and the contents of register B after executing the instruction in assignment 6.

Solution:

PORT1= 80H

B= 80H

SECTION 6.2: ARITHMETIC OPERATIONS

8. Specify the register contents and the flag status as the following instructions are executed.

INITIAL CONTENTS

A        B        S        Z        CY

00     FF        0        1       0

MVI A,F2H

MVI B,7AH

ADD B

OUT PORT0

HLT

Solution:

                            A            B           S        Z          CY

MVI A,F2H       F2H        FF        NA      NA       NA

MVI B,7AH      F2           7A        NA      NA       NA

ADD B              6C           7A          0          0          1

OUT PORT0     6C           7A       NA       NA       NA

HLT

9. What operation can be performed using the instruction ADD A?

Solution: ADD A  instruction will double the contents of accumulator i.e. it will add the contents of accumulator to itself.

10. What operation can be performed by using the instruction SUB A? Specify the status Z and CY?

Solution: The instruction SUB A will subtract the contents of accumulator from itself, i.e. will clear the accumulator. CY=0 and Z=1.

11. Specify the register contents and the flag status as the following instructions are executed.

Initial conditions

A        C        S        Z        CY

XX     XX      0        0          0

MVI A,5EH

ADI A2H

MOV C,A

HLT

Solution:

                            A             C                S            Z            CY

MVI A,5EH        5E           XX            NA         NA          NA

ADI A2H            00            XX            NA           1            1

MOV C,A            00           00              NA          NA        NA

HLT

13. Write a program using the ADI instruction to add the two hexadecimal numbers 3A H and 48H and to display the answer at an output port.

Solution:

MVI A, 3AH

ADI 48H

OUT PORT1

HLT

14. Write instructions to

a. load 00H  in the accumulator.

b. decrement the accumulator.

c. display the answer.

Solution:

a. 

MVI A,00H

b.

DCR A

c. 

OUT PORT 1

OUTPUT PORT will display the answer as FF H.


15. The following instructions subtract two unsigned numbers. Specify the contents of register A and the status of the S and CY flags. Explain the significance of the sign flag if it is set.

MVI A,F8H

SUI 69H

Solution:  F8- 69 = 95 H

        A will contain 95H.

                 S=1

                CY=0

Sign flag signifies the sign of the result and carry flag signifies borrow here.


16. Specify the register contents and 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

HLT

Solution:

                        A           B            S                Z                CY

SUB A            00                          0                1                0

MOV B,A       00          00            NA            NA            NA    

DCR B            00          FF            1                0                NA

INR B             00          00             0                1                NA

SUI 01H          FF         00             1                0                1

HLT


18. Write a program to 

    a. Clear the accumulator.

    b. add 47 H (Use ADI instruction)

    c. subtract 92H

    d. add 64H

    e. display the results after subtracting 92 H and after adding 64H.

    Specify the answers you would expect at the output ports.

Solution: 

SUB A            //clear accumulator

ADI 47H        // add 47H to accumulator

SUI 92H        //subtract 92H from the accumulator

ADI 64 H        //add 64H to the accumulator.

OUT PORT1

47 H            = 0 1 0 0 0 1 1 1

                        +

2's comp      =0 1  1 0 1 1 1 0

of 92H

                    =1 0 1 1 0 1 0 1 = B5H ( with borrow flag set)

                        +

64 H            =0 1 1 0 0 1 0 0 

                    =0 0 0 1 1 0 0 1 =19H ( with carry flag set which deletes the borrow flag)

So, PORT0 will output B5 H and PORT 1 will output 19H.


19. Specify the reason for clearing the accumulator before adding the number 47 H directly to the accumulator in Assignment 18.

Solution:  It is required to clear the accumulator before starting any operation as there may be residual content in the accumulator which will alter the result.






Post a Comment

0 Comments