SlideShare a Scribd company logo
Stack & Subroutines
                      Company
                        LOGO
The stack
   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.


www.themeart.com                                       2
The stack
   The stack normally grows backwards into
    memory.
   The stack can be initialized anywhere in the
    user memory map , but stack is initialized at the
    highest memory location so that there will not
    be any interface with the program.
   In 8085 microprocessor system the beginning of
    the stack is defined in the program by using the
    instruction
    LXI SP,16 bit.
   The LXI SP,a 16 bit state that load the 16 bit
    address into the stack pointer register.
www.themeart.com                                        3
Information is stored and retrieved
          from the stack
•The 8085 provide two instruction PUSH & POP for storing infor
mation on the stack and retrieving it back.

•Information in the register pairs stored on the stack in reverse
order by using the instruction PUSH.

• Information retrieved 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.

•Information in the stack location may not be destroyed until
new information is stored in that memory location
www.themeart.com                                                    4
The PUSH Instruction

2000 LXI SP,2099H    Load the stack pointer register with the addre
                     ss 2099.
2003 LXI H ,42F2H    Loads data in the HL register pair.

2006 PUSH H          The content of the HL register pair pushed int
                     o stack.
2007 DELAY COUNTER
200F
2010 POP H           Saved data in stack pointer register to HL regi
                     ster pair.




 www.themeart.com                                                      5
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.                         8085 Register
                                                                      F
                                               A
   The stack pointer register is again        B                      C
                                                                      E
                                               D
     decremented by one to 2097H,and H 42                    F2       L
                                              SP        2097
     the contents of the L register are                Memory
    copied to memory location 2097H.
   The contents of the register pair                    F2     2097
                                                         42     2098
     HL are not destroyed ; however                       X     2099

     HL is made available for delay
     counter.                        Contents on the stack &in the register
                                          after the PUSH instruction
www.themeart.com                                                              6
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.                                             8085 Register

   The contents of the top of the stack A    B
                                                                       F
                                                                       C
     (now it is 2098H) are copied in the D                             E
                                              H    42         F2       L
     H register,and the stack pointer is SP            2099

     incremented by one.                              MEMORY
   The contents of memory location
                                                          F2       2097
    2097H and 2098 are not destroyed                      42      2098
    until some other data bytes are                       X       2099

    stored in these location. Contentsafterthe stack and in the registers
                                       on
                                            the POP instruction
www.themeart.com                                                            7
Operation of the stack
   During pushing, the stack operates in a “decrement
    then store” style.
    The stack pointer is decremented first, then the
    information is placed on the stack.
    During poping, 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’’.


www.themeart.com                                         8
PUSH PSW Register Pair
     PUSH PSW (1 Byte Instruction)          A        Flag
      Decrement SP
      Copy the contents of
                                         12           80
       register A to the memory
       location pointed to by SP
     Decrement SP
     Copy the contents of
      Flag register to the memory     FFFB
                                      FFFC
       location pointed to by SP
                                      FFFD       80
                                      FFFE       12
                                      FFFF


www.themeart.com                                             9
Pop PSW Register Pair
     POP PSW (1 Byte Instruction)    A   FLAG
     Copy the contents of the       12    80
      memory location pointed to
      by the SP to Flag register
     Increment SP
     Copy the contents of the
                                   FFFB
      memory location pointed to   FFFC
      by the SP to register A      FFFD   80
                                   FFFE   12
     Increment SP                 FFFF


www.themeart.com                                 10
Subroutines
     A subroutine is group of instruction written sepa
      rately from the main program to perform a func
      tion that occurs repeatedly in the main program
      .
     When a main program calls a subroutine the pro
      gram execution is transferred to the subroutine
      after the completion of the subroutine ,the prog
      ram execution returns to the main program.
     The microprocessor uses the stack to store the r
      eturn address of the subroutine.


www.themeart.com                                          11
Subroutines
   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 t
    he main program at the end of the subro
    utine .




www.themeart.com                                  12
The CALL instruction
   CALL ,16 bit
   Call subroutine in conditionally 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.


www.themeart.com                                  13
The RET instruction
   Return unconditionally from the subrouti
    ne.
   This instruction locates the return addre
    ss on the top of the stack and transfers t
    he program execution back to the calling
    program.




www.themeart.com                                 14
General characteristics of CALL
       & RTE instruction
  1. The CALL instructions are 3-byte instruc
     tion; the second byte specifies the low
     order byte ,and the third byte specifies
     the high order byte of the subroutine
     address.
  2. The return instruction are 1-byte instruc
     tions.
  3. A CALL instruction must be used in
     conjunction with a return instruction in
     the subroutine .
www.themeart.com                                 15
Necessary steps to implement
          a subroutine

   The stack pointer register must be initiali
    zed ,preferably at the highest memory lo
    cation of the R/W memory.
   The call instruction should be used in the
    main program accompanied by the RET i
    nstruction in the subroutine.




www.themeart.com                                  16
Conditional CALL and RTE Instructions
      The 8085 supports conditional CALL and co
       nditional RTE instructions.
      – The same conditions used with conditional
       JUMP instructions can be used.
      – CC, call subroutine if Carry flag is set.
      – CNC, call subroutine if Carry flag is not set
      – RC, return from subroutine if Carry flag is
       set
      – RNC, return from subroutine if Carry flag
         is not set.
www.themeart.com                                        17
www.themeart.com   18

More Related Content

What's hot

Microcontroller pic 16f877 addressing modes instructions and programming
Microcontroller pic 16f877 addressing modes instructions and programmingMicrocontroller pic 16f877 addressing modes instructions and programming
Microcontroller pic 16f877 addressing modes instructions and programming
Nilesh Bhaskarrao Bahadure
 
Stack
StackStack
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
Gopikrishna Madanan
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAnuj Modi
 
8085 interfacing with memory chips
8085 interfacing with memory chips8085 interfacing with memory chips
8085 interfacing with memory chips
Srikrishna Thota
 
Presentation on 8086 Microprocessor
Presentation  on   8086 MicroprocessorPresentation  on   8086 Microprocessor
Presentation on 8086 Microprocessor
Nahian Ahmed
 
8237 dma controller
8237 dma controller8237 dma controller
8237 dma controllerTech_MX
 
8086-microprocessor
8086-microprocessor8086-microprocessor
8086-microprocessor
jhcid
 
Memory reference instruction
Memory reference instructionMemory reference instruction
Memory reference instruction
Sanjeev Patel
 
Stack Operations
Stack Operations Stack Operations
Stack Operations
RidaZaman1
 
30. 8086 microprocessor pipelined architecture
30. 8086 microprocessor pipelined architecture30. 8086 microprocessor pipelined architecture
30. 8086 microprocessor pipelined architecture
sandip das
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
deval patel
 
Programming with 8085-Microprocessor and interfacing
Programming with 8085-Microprocessor and interfacingProgramming with 8085-Microprocessor and interfacing
Programming with 8085-Microprocessor and interfacingAmitabh Shukla
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
Shehrevar Davierwala
 
8086 pin details
8086 pin details8086 pin details
8086 pin details
AJAL A J
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
Mahalakshmiv11
 
8086 MICROPROCESSOR
8086 MICROPROCESSOR8086 MICROPROCESSOR
8086 MICROPROCESSOR
Akhila Rahul
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 80869840596838
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
Asif Iqbal
 
Introduction to 8085 microprocessor
Introduction to 8085 microprocessorIntroduction to 8085 microprocessor
Introduction to 8085 microprocessor
kunj desai
 

What's hot (20)

Microcontroller pic 16f877 addressing modes instructions and programming
Microcontroller pic 16f877 addressing modes instructions and programmingMicrocontroller pic 16f877 addressing modes instructions and programming
Microcontroller pic 16f877 addressing modes instructions and programming
 
Stack
StackStack
Stack
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
8085 interfacing with memory chips
8085 interfacing with memory chips8085 interfacing with memory chips
8085 interfacing with memory chips
 
Presentation on 8086 Microprocessor
Presentation  on   8086 MicroprocessorPresentation  on   8086 Microprocessor
Presentation on 8086 Microprocessor
 
8237 dma controller
8237 dma controller8237 dma controller
8237 dma controller
 
8086-microprocessor
8086-microprocessor8086-microprocessor
8086-microprocessor
 
Memory reference instruction
Memory reference instructionMemory reference instruction
Memory reference instruction
 
Stack Operations
Stack Operations Stack Operations
Stack Operations
 
30. 8086 microprocessor pipelined architecture
30. 8086 microprocessor pipelined architecture30. 8086 microprocessor pipelined architecture
30. 8086 microprocessor pipelined architecture
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
 
Programming with 8085-Microprocessor and interfacing
Programming with 8085-Microprocessor and interfacingProgramming with 8085-Microprocessor and interfacing
Programming with 8085-Microprocessor and interfacing
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
8086 pin details
8086 pin details8086 pin details
8086 pin details
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
8086 MICROPROCESSOR
8086 MICROPROCESSOR8086 MICROPROCESSOR
8086 MICROPROCESSOR
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
 
Introduction to 8085 microprocessor
Introduction to 8085 microprocessorIntroduction to 8085 microprocessor
Introduction to 8085 microprocessor
 

Similar to Stack in microprocessor 8085(presantation)

B sc e 5.2 mp unit 2 soft ware(alp)
B sc e 5.2 mp unit 2 soft ware(alp)B sc e 5.2 mp unit 2 soft ware(alp)
B sc e 5.2 mp unit 2 soft ware(alp)
MahiboobAliMulla
 
Lecture 05 NOP and Stack Group of Instructions
Lecture 05 NOP and Stack Group of InstructionsLecture 05 NOP and Stack Group of Instructions
Lecture 05 NOP and Stack Group of Instructions
Zeeshan Ahmed
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
deval patel
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
milandhara
 
Microprocessor and Microcontroller lec4
Microprocessor and Microcontroller lec4Microprocessor and Microcontroller lec4
Microprocessor and Microcontroller lec4
Ameen San
 
03 addr mode & instructions
03 addr mode & instructions03 addr mode & instructions
03 addr mode & instructions
ShubhamBakshi14
 
Embedded C programming session10
Embedded C programming  session10Embedded C programming  session10
Embedded C programming session10
Keroles karam khalil
 
Stacks & Subroutines.ppt.pptx
Stacks & Subroutines.ppt.pptxStacks & Subroutines.ppt.pptx
Stacks & Subroutines.ppt.pptx
ssuserdcfc6d
 
C programming session10
C programming  session10C programming  session10
C programming session10
Keroles karam khalil
 
Lec04
Lec04Lec04
Lec04
Lec04Lec04
Instructionset8085
Instructionset8085Instructionset8085
Instructionset8085Fawad Pathan
 
Basic programming of 8085
Basic programming of 8085 Basic programming of 8085
Basic programming of 8085 vijaydeepakg
 
8085 instruction set
8085 instruction set8085 instruction set
8085 instruction set
JLoknathDora
 
8085 is details
8085 is details8085 is details
8085 is details
soumyaranjan panda
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
ssuser47c811
 
8051 Programming (1).pptx
8051 Programming (1).pptx8051 Programming (1).pptx
8051 Programming (1).pptx
DhyeayaParmar
 
4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx
ISMT College
 
T imingdiagram
T imingdiagramT imingdiagram
T imingdiagram
puja00
 
8085 instruction set
8085 instruction set8085 instruction set

Similar to Stack in microprocessor 8085(presantation) (20)

B sc e 5.2 mp unit 2 soft ware(alp)
B sc e 5.2 mp unit 2 soft ware(alp)B sc e 5.2 mp unit 2 soft ware(alp)
B sc e 5.2 mp unit 2 soft ware(alp)
 
Lecture 05 NOP and Stack Group of Instructions
Lecture 05 NOP and Stack Group of InstructionsLecture 05 NOP and Stack Group of Instructions
Lecture 05 NOP and Stack Group of Instructions
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Microprocessor and Microcontroller lec4
Microprocessor and Microcontroller lec4Microprocessor and Microcontroller lec4
Microprocessor and Microcontroller lec4
 
03 addr mode & instructions
03 addr mode & instructions03 addr mode & instructions
03 addr mode & instructions
 
Embedded C programming session10
Embedded C programming  session10Embedded C programming  session10
Embedded C programming session10
 
Stacks & Subroutines.ppt.pptx
Stacks & Subroutines.ppt.pptxStacks & Subroutines.ppt.pptx
Stacks & Subroutines.ppt.pptx
 
C programming session10
C programming  session10C programming  session10
C programming session10
 
Lec04
Lec04Lec04
Lec04
 
Lec04
Lec04Lec04
Lec04
 
Instructionset8085
Instructionset8085Instructionset8085
Instructionset8085
 
Basic programming of 8085
Basic programming of 8085 Basic programming of 8085
Basic programming of 8085
 
8085 instruction set
8085 instruction set8085 instruction set
8085 instruction set
 
8085 is details
8085 is details8085 is details
8085 is details
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
8051 Programming (1).pptx
8051 Programming (1).pptx8051 Programming (1).pptx
8051 Programming (1).pptx
 
4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx
 
T imingdiagram
T imingdiagramT imingdiagram
T imingdiagram
 
8085 instruction set
8085 instruction set8085 instruction set
8085 instruction set
 

Recently uploaded

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 

Recently uploaded (20)

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 

Stack in microprocessor 8085(presantation)

  • 1. Stack & Subroutines Company LOGO
  • 2. The stack  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. www.themeart.com 2
  • 3. The stack  The stack normally grows backwards into memory.  The stack can be initialized anywhere in the user memory map , but stack is initialized at the highest memory location so that there will not be any interface with the program.  In 8085 microprocessor system the beginning of the stack is defined in the program by using the instruction  LXI SP,16 bit.  The LXI SP,a 16 bit state that load the 16 bit address into the stack pointer register. www.themeart.com 3
  • 4. Information is stored and retrieved from the stack •The 8085 provide two instruction PUSH & POP for storing infor mation on the stack and retrieving it back. •Information in the register pairs stored on the stack in reverse order by using the instruction PUSH. • Information retrieved 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. •Information in the stack location may not be destroyed until new information is stored in that memory location www.themeart.com 4
  • 5. The PUSH Instruction 2000 LXI SP,2099H Load the stack pointer register with the addre ss 2099. 2003 LXI H ,42F2H Loads data in the HL register pair. 2006 PUSH H The content of the HL register pair pushed int o stack. 2007 DELAY COUNTER 200F 2010 POP H Saved data in stack pointer register to HL regi ster pair. www.themeart.com 5
  • 6. 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. 8085 Register F A  The stack pointer register is again B C E D decremented by one to 2097H,and H 42 F2 L SP 2097 the contents of the L register are Memory copied to memory location 2097H.  The contents of the register pair F2 2097 42 2098 HL are not destroyed ; however X 2099 HL is made available for delay counter. Contents on the stack &in the register after the PUSH instruction www.themeart.com 6
  • 7. 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. 8085 Register  The contents of the top of the stack A B F C (now it is 2098H) are copied in the D E H 42 F2 L H register,and the stack pointer is SP 2099 incremented by one. MEMORY  The contents of memory location F2 2097 2097H and 2098 are not destroyed 42 2098 until some other data bytes are X 2099 stored in these location. Contentsafterthe stack and in the registers on the POP instruction www.themeart.com 7
  • 8. Operation of the stack  During pushing, the stack operates in a “decrement then store” style.  The stack pointer is decremented first, then the information is placed on the stack.  During poping, 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’’. www.themeart.com 8
  • 9. PUSH PSW Register Pair  PUSH PSW (1 Byte Instruction) A Flag  Decrement SP  Copy the contents of 12 80 register A to the memory location pointed to by SP  Decrement SP  Copy the contents of Flag register to the memory FFFB FFFC location pointed to by SP FFFD 80 FFFE 12 FFFF www.themeart.com 9
  • 10. Pop PSW Register Pair  POP PSW (1 Byte Instruction) A FLAG  Copy the contents of the 12 80 memory location pointed to by the SP to Flag register  Increment SP  Copy the contents of the FFFB memory location pointed to FFFC by the SP to register A FFFD 80 FFFE 12  Increment SP FFFF www.themeart.com 10
  • 11. Subroutines  A subroutine is group of instruction written sepa rately from the main program to perform a func tion that occurs repeatedly in the main program .  When a main program calls a subroutine the pro gram execution is transferred to the subroutine after the completion of the subroutine ,the prog ram execution returns to the main program.  The microprocessor uses the stack to store the r eturn address of the subroutine. www.themeart.com 11
  • 12. Subroutines  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 t he main program at the end of the subro utine . www.themeart.com 12
  • 13. The CALL instruction  CALL ,16 bit  Call subroutine in conditionally 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. www.themeart.com 13
  • 14. The RET instruction  Return unconditionally from the subrouti ne.  This instruction locates the return addre ss on the top of the stack and transfers t he program execution back to the calling program. www.themeart.com 14
  • 15. General characteristics of CALL & RTE instruction 1. The CALL instructions are 3-byte instruc tion; the second byte specifies the low order byte ,and the third byte specifies the high order byte of the subroutine address. 2. The return instruction are 1-byte instruc tions. 3. A CALL instruction must be used in conjunction with a return instruction in the subroutine . www.themeart.com 15
  • 16. Necessary steps to implement a subroutine  The stack pointer register must be initiali zed ,preferably at the highest memory lo cation of the R/W memory.  The call instruction should be used in the main program accompanied by the RET i nstruction in the subroutine. www.themeart.com 16
  • 17. Conditional CALL and RTE Instructions  The 8085 supports conditional CALL and co nditional RTE instructions. – The same conditions used with conditional JUMP instructions can be used. – CC, call subroutine if Carry flag is set. – CNC, call subroutine if Carry flag is not set – RC, return from subroutine if Carry flag is set – RNC, return from subroutine if Carry flag is not set. www.themeart.com 17