0% found this document useful (0 votes)
25 views

New STACK AND MACROS

This document discusses stacks, push and pop instructions, macros, and macro libraries in 8085 microprocessors. It describes how stacks use LIFO memory locations to temporarily store register data during program execution. Push stores register pairs on the stack, while pop reads them back. Macros allow repetitive code to be defined once and called multiple times by substituting parameters. Macro libraries contain reusable macros stored in external files that can be included in programs.

Uploaded by

mohit mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

New STACK AND MACROS

This document discusses stacks, push and pop instructions, macros, and macro libraries in 8085 microprocessors. It describes how stacks use LIFO memory locations to temporarily store register data during program execution. Push stores register pairs on the stack, while pop reads them back. Macros allow repetitive code to be defined once and called multiple times by substituting parameters. Macro libraries contain reusable macros stored in external files that can be included in programs.

Uploaded by

mohit mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

STACK AND MACROS IN 8085

(UNIT-3)

(SUB: Microprocessor and Interfaces)

PREPARED BY:
ER. MOHIT MISHRA
ASSOCIATE PROFESSOR
COMPUTER SCIENCE DEPARTMENT
TOPIC COVERED

• WHAT IS STACK?
• PUSH AND POP INSTRUCTION
• OPERATION OF THE STACK BY PUSH AND POP
INSTRUCTION
• LOOPING AND COUNTING TECHNIQUES
• DESIGING OF MACRO
• MACRO LIBRARIES
WHAT IS STACK?

• The stack is a group of memory location in the


R/W memory (RAM) that is used for
temporary storage of data during the
execution of a program.
• Address of the stack is stored into the stack
pointer register.
PUSH AND POP INSTRUCTIONS

The 8085 provide two instructions PUSH & POP for


storing information on the stack and reading it back.

• Data in the register pairs stored on the stack by using the


instruction PUSH.
• Data is read from the stack by using the instruction POP.
• PUSH & POP both instruction works with register pairs only.
• The storage and retrieval of the content of registers on the
stack fallows the LIFO(Last-In-First-Out) sequence.
OPERATION OF THE STACK BY PUSH AND POP INSTRUCTION

2000 LXI SP, 2099H ; this instruction define stack

2003 LXI H, 42F2H ; this instruction store 42F2 in to the HL


pair

2006 PUSH H ; store HL pair on to the stack

2010 POP H ; store data from top of the stack to HL pair


For PUSH H:

• The stack pointer is decremented by one to 2098H, 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.
For POP H:

•The stack pointer is decremented by one to 2098H, 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.
LOOPING AND COUNTING TECHNIQUES

• The Programming Technique used to instruct


the microprocessor to repeat task is called
looping. This process is accomplished by using
jump instructions.
• A loop can be classified into two groups:
• Continuous loop- repeats a task continuously
• Conditional loop-repeats a task until certain
data condition are met
CONTINUOUS LOOP(TIMING DELAY LOOP)

• A continuous loop is set up by using the unconditional jump


Instruction shown in the flowchart.
• A program with Continuous loop does not stop repeating the
tasks until the system is reset.
CONDITIONAL LOOP(COUNTER LOOP)

A Conditional loop is setup by the conditional jump instructions.


• These instructions Check flags (zero, carry, etc.) and repeat the specified
task if the conditions are satisfied.
• These loops usually include counting and indexing. Conditional loop is
shown by the Flowchart as follow.

The Flowchart is translated into the program as follows:


1. Counter is setup by loading an appropriate
count in a register.

2. Counting is performed by either incrementing


or decrementing the counter.

3. Loop is set up by a conditional jump instruction.

4. End of counting is indicated by a flag.


MACRO

• A macro is a group of repetitive instructions in a program


which are codified only once and can be used as many times
as necessary.

• At the moment when the macro is executed, each parameter
is substituted by the name or value specified at the time of
the call.

• We can say that a procedure is an extension of a determined


program, while the macro is a module with specific functions
which can be used by different programs.
DESIGING OF MACRO

Parts which make a macro are:

i. Declaration of the macro.

ii. Code of the macro.

iii. Macro termination directive


DESIGING OF MACRO

• Declaration of the macro: Name Of Macro MACRO


[parameter1, parameter2...]

• Even though we have the functionality of the parameters it is


possible to create a macro which does not need them.

• The directive for the termination of the macro is: ENDM


DESIGING OF MACRO

• Declaration of the macro: Name Of Macro MACRO


[parameter1, parameter2...]

• Even though we have the functionality of the parameters it is


possible to create a macro which does not need them.

• The directive for the termination of the macro is: ENDM


MACRO LIBRARIES

• One of the facilities that the use of macros offers is the


creation of libraries, which are groups of macros which can be
included in a program from a different file.
• The creation of these libraries is very simple, we only have to
write a file with all the macros which will be needed and save
it as a text file.
• To call these macros it is only necessary to use the following
instruction Include Name Of The File, on the part of our
program where we would normally write the macros, this is,
at the beginning of our program, before the declaration of the
memory model.

You might also like