Latest

6/recent/ticker-posts

SOLUTION OF CHAPTER 9 OF RAMESH GAONKAR'S 8085 MICROPROCESSOR- STACKS AND SUBROUTINE



1. Check the appropriate answer of the following:

a. A stack is-

    1. an 8 bit register in microprocessor.

    2. a 16 bit register in microprocessor.

    3. a set of memory location in R/W memory reserved for storing information temporarily during the                 execution of a program.

    4. a 16 bit memory address stored in the program counter.

Ans: 3. a set of memory location R/W memory reserved for storing information temporarily during the execution of a program.

 b. A stack pointer is -

    1. a 16 bit register in a microprocessor that indicates the beginning of a stack memory.

    2. a register that decodes and executes 16 bit arithmetic expressions.

    3. the first memory location where a subroutine address is stored.

    4. a register where flag bits are stored.

Ans: 1. a 16 bit register in a microprocessor that indicates the beginning of a stack memory.

e. Whenever the POP H instruction is executed

    1. data bytes in HL pair are stored on the stack.

    2. two data bytes at the top of the stack are transferred to HL register pair.

    3. two data bytes at the top of the stack are transferred to program counter.

    4. two data bytes from HL register that were previously stored on the stack are transferred back to the     HL register.

Ans: 2. two data bytes at the top of the stack are transferred to HL register pair. ( Don't get confused with 4 th option) 

2. Read the following program and answer the following questions:

    Line No.     Mnemonics

    1                  LXI SP,0400H

    2                   LXI B,2055 H

    3                   LXI H, 22FF H

    4                    LXI D, 2090 H

    5                    PUSH H

    6                    PUSH B

    7                    MOV A,L

    

    20                    POP H

a) What is stored in the stack pointer register after the execution of line 1?

Ans:     The initial address of stack 0400 H will be stored in the stack pointer.

b) What is the memory location of the stack where the first data byte gets stored?

Ans:     03FF

c) What is stored in memory location 03FE H when line 5 PUSH H is executed?

Ans:     22 H of 22FF H i.e., the high order data bytes will be stored .

d) After the execution line 6, PUSH B , What is the address in the stack pointer register, and what is stored in stack memory location 03FD H?

Ans:        The address will be 00FA H after the execution of line 6. FF H i.e. the low order bytes of HL pair is stored in the location 03FD H.

e) Specify the contents of HL pair after the execution of line 20 POP H.

Ans: HL pair will contain 2055 H.

3. The following program has a delay subroutine located at location 2060H. Read the program and answer the questions given at the end of the program. 

memory locations        mnemonics

2000                            LXI SP,20CD H    ->main program

2003                            LXI H,0008H

2006                            MVI B,0FH

2008                            CALL 2060H

200B                            OUT 01H

                                    DCR B

        

                                    COND

2060                            PUSH H        : delay subroutine

2061                            PUSH B

                                    MVI B,05H

                                    LXI H,COUNT


                                    POP B

                                    POP H

                                    RET

a. When the execution of the CALL instruction located at 2008-200A H    is completed, list the contents stored at 20CC H and 20CB H, the contents of the program counter, and the contents of the stack pointer register.

Ans: The address in the program counter will be stored on the stack, SO

         20CC will contain 20H

        20CB will contain 0B H.

The program counter will have the same address as the stack and the contents of the stack pointer will be incremented to 20CB H.     

b. List the stack locations and their contents after the execution of the instructions    PUSH H and PUSH B in the subroutine.

Ans: 20CA H=00 H (H)

        20C9 H=08 H(L)

        20C8 H=0FH (B)

        20C7 H=XX (C)

c. List the contents of the stack pointer register after the execution of the instruction PUSH B located at 2061 H.

Ans: Stack pointer will contain 20C7H

d. List the contents of the stack pointer register after the execution of the instruction RET in the subroutine.

Ans: Stack pointer will contain 20CD H.







Post a Comment

0 Comments