8085

 

 

1.     What is Stack? Explain about stack in 8085.

·       The stack is a group of memory location in the R/W memory that is used for temporary storage of binary information during the execution of a program

·       The stack is a LIFO structure. – Last In First Out.

·       The starting location of the stack is defined by loading a 16 bit address into the stack pointer that spaced is reserved, usually at the top of the memory map

 

Stack in 8085

 

·       In 8085 microprocessor system the beginning of the stack is defined in the program by using the instruction  LXI SP,<16 bit>

·       The 8085 provide two instruction PUSH & POP for storing information on the stack and retrieving it back.

PUSH  <Reg Pair>    :   Stores content of register pair on to stack 

POP     <Reg Pair>    :   Retrieves content from top of the stack in to register pair

 

PUSH     H

 

·       The stack pointer is decremented by one to 2098 H , and the contents of the H register are copied to memory location 2098H.

·       The stack pointer register is again decremented by one to 2097H, and the contents of the L register are copied to memory location 2097H.

·       The contents of the register pair HL are not destroyed ; however HL is made available for delay counter.

POP    H


·       The contents of the top of the stack location shown by the stack pointer are copied in the L register and the stack pointer register is incremented by one to 2098 H.

·       The contents of the top of the stack  (now it is 2098H) are copied in the  H register, and the stack pointer is  incremented by one.

·       The contents of memory location  2097H and 2098 are not destroyed  until some other data bytes are  stored in these location.

Operation of the stack

·       During PUSH, the stack operates in a “decrement then store” style. The stack pointer is decremented first, then the information is placed on the stack.

·       During POP, the stack operates in a “use then increment” style. The information is retrieved from the top of the stack and then the pointer is incremented.

·       The SP pointer always points to “the top of the stack’’

 

1.     What is subroutine? Explain implementation of subroutines in 8085.

 

·       A subroutine is group of instruction written separately from the main program to perform a function that occurs repeatedly in the main program.

·       When a main program calls a subroutine the program execution is transferred to the subroutine after the completion of the subroutine ,the program execution returns to the main program.

·       The microprocessor uses the stack to store the return address of the subroutine.

Subroutines in 8085:

·       The 8085 has two instructions for dealing with subroutines.

·       The CALL instruction is used to redirect program execution to the subroutine.

·       The RET instruction is used to return to the main program at the end of the subroutine

 

TThe CALL instruction

CALL    <16-bit address of subroutine>

 

·       Call subroutine located at the memory address specified by the 16 bit operand.

·       This instruction places the address of the next instruction on the stack and transfer the

program execution to the subroutine address.

The RET instruction

 

RET

 

·       Return unconditionally from the subroutine.

·       This instruction locates the return address on the top of the stack and transfers the program execution back to the calling program.




Comments

Popular posts from this blog

PROGRAMMER'S MODEL OF 8086

8086 Main Features