SlideShare a Scribd company logo
1 of 15
Stacks &
Subroutines
○ The stack is an area of memory
identified by the programmer for
temporary storage of information.
○ The stack is a LIFO (Last In First
Out. ) structure.
○ The stack normally grows backwards
into memory.
○In other words, the programmer
defines the bottom of
and the stack grows
the stack
up into
reducing address range.
The Stack
○ Given that the stack grows backwards into memory, it
is customary to place the bottom of the stack at the end
of memory to keep it as far away from user programs
as possible.
○ In the 8085, the stack is defined by setting the SP
(Stack Pointer) register.
LXI SP, FFFFH
○ This sets the Stack Pointer to location FFFFH (end of
memory for the 8085).
The Stack
○ Information is saved on the stack by
PUSHing it on.
○It is retrieved from the stack by POPing it
off.
○ The 8085 provides two instructions: PUSH
and POP for storing information on the stack
and retrieving it back.
○ Both PUSH and POP work with register
pairs ONLY.
Saving Information on the
Stack
The PUSH Instruction
●PUSH B/D/H/PSW
○Decrement SP
○ Copy the contents of register B to the memory location
pointed to by SP
○Decrement SP
○ Copy the contents of register C to the memory location
pointed to by SP
The POP Instruction
●POP B/D/H/PSW
○ Copy the contents of the memory location pointed to by the
SP to register E
○Increment SP
○ Copy the contents of the memory location pointed to by the
SP to register D
○Increment SP
○ 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
the stack and then the pointer is incremented.
○ The SP pointer always points to “the top of the
stack”.
Operation of the Stack
● The order of PUSHs and POPs must be opposite of each
other in order to retrieve information back into its original
location.
PUSH B
PUSH D
...
POP D
POP B
● Reversing the order of the POP instructions
result in the exchange of the contents of BC and DE.
will
LIFO
Cautions with PUSH and
POP
● PUSH and POP should be used in opposite
order.
● There has to be as many POP’s as there are
PUSH’s.
● If not, the RET statement will pick up the
wrong information from the top of the stack and
the program will fail.
● It is not advisable to place PUSH or POP
inside a loop.
Program to Reset and display
Flags
○Clear all Flags.
○Load 00H in the accumulator, and
demonstrate that the zero flag is not affected
by data transfer instruction.
○Logically OR the accumulator with itself to
set the Zero flag, and display the flag at
PORT1 or store all flags on the stack.
○ A subroutine is a group of instructions that will be used
repeatedly in different locations of the program.
○ Rather than repeat the same instructions several times,
they can be grouped into a subroutine that is called from the
different locations.
○ In Assembly language,asubroutineccanc exist
anywhere in the code.
○ However, it is customary to place subroutines separately
from the main program.
Subroutines
○ The 8085 has two instructions for dealing
with subroutines.
○ The CALL instruction is used to redirect
program execution to the subroutine.
○ The RTE instruction is used to return the
execution to the calling routine.
Subroutines
The CALL Instruction
●CALL 4000H
○3-byte instruction.
○ Push the address of the instruction immediately following the
CALL onto the stack and decrement the stack pointer register by
two.
○ Load the program counter with the 16-bit address supplied
with the CALL instruction.
○Jump Unconditionally to memory location.
The CALL Instruction
●RTE
○1-byte instruction
○ Retrieve the return address from the top of the stack and
increments stack pointer register by two.
○Load the program counter with the return address.
○Unconditionally returns from a subroutine.
The RTE Instruction

More Related Content

Similar to Stacks & Subroutines.ppt.pptx

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 InstructionsZeeshan Ahmed
 
Stack in microprocessor 8085(presantation)
Stack in microprocessor 8085(presantation)Stack in microprocessor 8085(presantation)
Stack in microprocessor 8085(presantation)Safin Biswas
 
(a)Suppose the main memory of the Pep8 were completely filled with .docx
(a)Suppose the main memory of the Pep8 were completely filled with .docx(a)Suppose the main memory of the Pep8 were completely filled with .docx
(a)Suppose the main memory of the Pep8 were completely filled with .docxajoy21
 
Central processing unit
Central processing unitCentral processing unit
Central processing unitHeman Pathak
 
3-addressingmodes-181203034235.pptx
3-addressingmodes-181203034235.pptx3-addressingmodes-181203034235.pptx
3-addressingmodes-181203034235.pptxMdAsaduzzaman257266
 
Basic programming of 8085
Basic programming of 8085 Basic programming of 8085
Basic programming of 8085 vijaydeepakg
 
instruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptinstruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptssuser2b759d
 
Stack in 8085 microprocessor
Stack in 8085 microprocessorStack in 8085 microprocessor
Stack in 8085 microprocessorhepzijustin
 
Hardware interfacing basics using AVR
Hardware interfacing basics using AVRHardware interfacing basics using AVR
Hardware interfacing basics using AVRMohamed Abdallah
 
Introduction to debugging linux applications
Introduction to debugging linux applicationsIntroduction to debugging linux applications
Introduction to debugging linux applicationscommiebstrd
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086aviban
 

Similar to Stacks & Subroutines.ppt.pptx (20)

Lec04
Lec04Lec04
Lec04
 
Lec04
Lec04Lec04
Lec04
 
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
 
Stack in microprocessor 8085(presantation)
Stack in microprocessor 8085(presantation)Stack in microprocessor 8085(presantation)
Stack in microprocessor 8085(presantation)
 
class-Stacks.pptx
class-Stacks.pptxclass-Stacks.pptx
class-Stacks.pptx
 
module-2.pptx
module-2.pptxmodule-2.pptx
module-2.pptx
 
(a)Suppose the main memory of the Pep8 were completely filled with .docx
(a)Suppose the main memory of the Pep8 were completely filled with .docx(a)Suppose the main memory of the Pep8 were completely filled with .docx
(a)Suppose the main memory of the Pep8 were completely filled with .docx
 
Central processing unit
Central processing unitCentral processing unit
Central processing unit
 
Subroutine
SubroutineSubroutine
Subroutine
 
3-addressingmodes-181203034235.pptx
3-addressingmodes-181203034235.pptx3-addressingmodes-181203034235.pptx
3-addressingmodes-181203034235.pptx
 
Basic programming of 8085
Basic programming of 8085 Basic programming of 8085
Basic programming of 8085
 
Chapter 5 notes
Chapter 5 notesChapter 5 notes
Chapter 5 notes
 
Lecture5
Lecture5Lecture5
Lecture5
 
Lecture5(1)
Lecture5(1)Lecture5(1)
Lecture5(1)
 
Topic 1
Topic 1Topic 1
Topic 1
 
instruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptinstruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.ppt
 
Stack in 8085 microprocessor
Stack in 8085 microprocessorStack in 8085 microprocessor
Stack in 8085 microprocessor
 
Hardware interfacing basics using AVR
Hardware interfacing basics using AVRHardware interfacing basics using AVR
Hardware interfacing basics using AVR
 
Introduction to debugging linux applications
Introduction to debugging linux applicationsIntroduction to debugging linux applications
Introduction to debugging linux applications
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 

Recently uploaded

Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 

Recently uploaded (20)

Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 

Stacks & Subroutines.ppt.pptx

  • 2. ○ The stack is an area of memory identified by the programmer for temporary storage of information. ○ The stack is a LIFO (Last In First Out. ) structure. ○ The stack normally grows backwards into memory. ○In other words, the programmer defines the bottom of and the stack grows the stack up into reducing address range. The Stack
  • 3. ○ Given that the stack grows backwards into memory, it is customary to place the bottom of the stack at the end of memory to keep it as far away from user programs as possible. ○ In the 8085, the stack is defined by setting the SP (Stack Pointer) register. LXI SP, FFFFH ○ This sets the Stack Pointer to location FFFFH (end of memory for the 8085). The Stack
  • 4. ○ Information is saved on the stack by PUSHing it on. ○It is retrieved from the stack by POPing it off. ○ The 8085 provides two instructions: PUSH and POP for storing information on the stack and retrieving it back. ○ Both PUSH and POP work with register pairs ONLY. Saving Information on the Stack
  • 5. The PUSH Instruction ●PUSH B/D/H/PSW ○Decrement SP ○ Copy the contents of register B to the memory location pointed to by SP ○Decrement SP ○ Copy the contents of register C to the memory location pointed to by SP
  • 6. The POP Instruction ●POP B/D/H/PSW ○ Copy the contents of the memory location pointed to by the SP to register E ○Increment SP ○ Copy the contents of the memory location pointed to by the SP to register D ○Increment SP
  • 7. ○ 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 the stack and then the pointer is incremented. ○ The SP pointer always points to “the top of the stack”. Operation of the Stack
  • 8. ● The order of PUSHs and POPs must be opposite of each other in order to retrieve information back into its original location. PUSH B PUSH D ... POP D POP B ● Reversing the order of the POP instructions result in the exchange of the contents of BC and DE. will LIFO
  • 9. Cautions with PUSH and POP ● PUSH and POP should be used in opposite order. ● There has to be as many POP’s as there are PUSH’s. ● If not, the RET statement will pick up the wrong information from the top of the stack and the program will fail. ● It is not advisable to place PUSH or POP inside a loop.
  • 10. Program to Reset and display Flags ○Clear all Flags. ○Load 00H in the accumulator, and demonstrate that the zero flag is not affected by data transfer instruction. ○Logically OR the accumulator with itself to set the Zero flag, and display the flag at PORT1 or store all flags on the stack.
  • 11. ○ A subroutine is a group of instructions that will be used repeatedly in different locations of the program. ○ Rather than repeat the same instructions several times, they can be grouped into a subroutine that is called from the different locations. ○ In Assembly language,asubroutineccanc exist anywhere in the code. ○ However, it is customary to place subroutines separately from the main program. Subroutines
  • 12. ○ The 8085 has two instructions for dealing with subroutines. ○ The CALL instruction is used to redirect program execution to the subroutine. ○ The RTE instruction is used to return the execution to the calling routine. Subroutines
  • 13. The CALL Instruction ●CALL 4000H ○3-byte instruction. ○ Push the address of the instruction immediately following the CALL onto the stack and decrement the stack pointer register by two. ○ Load the program counter with the 16-bit address supplied with the CALL instruction. ○Jump Unconditionally to memory location.
  • 15. ●RTE ○1-byte instruction ○ Retrieve the return address from the top of the stack and increments stack pointer register by two. ○Load the program counter with the return address. ○Unconditionally returns from a subroutine. The RTE Instruction