0% found this document useful (0 votes)
3 views14 pages

12 Parameter Passing

The document discusses techniques for passing parameters to subroutines in digital electronics and microprocessors, specifically using the 8085 microprocessor. It includes exercises for writing main programs that perform arithmetic operations and utilize memory locations, along with explanations of instructions like LDA, STA, and stack operations. Additionally, it covers the use of the stack for managing data with PUSH and POP instructions, and the handling of interrupt service routines.

Uploaded by

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

12 Parameter Passing

The document discusses techniques for passing parameters to subroutines in digital electronics and microprocessors, specifically using the 8085 microprocessor. It includes exercises for writing main programs that perform arithmetic operations and utilize memory locations, along with explanations of instructions like LDA, STA, and stack operations. Additionally, it covers the use of the stack for managing data with PUSH and POP instructions, and the handling of interrupt service routines.

Uploaded by

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

DIGITAL ELECTRONICS AND

MICROPROCESSORS

Passing parameters to
subroutines

By Ashok Ranade
Techniques
Exercise 1
Write the main program which passes two numbers stored in B and C
registers to a subroutine which returns the sum of these numbers in D
register and the difference (B-C) in E
Assume that the sum does not exceed a byte and the number in B is
greater than that in C
Program and results
Exercise 2
Write the main program to write two numbers in memory locations 3000H
and 3001H. Then call a subroutine which will calculate the sum and
difference of these numbers and store the result in the locations 4000H and
4001H

LDA - Is for loading the accumulator. i.e) It is used to load the accumulator from
the memory. (Data moves/will be copied from memory to accumulator ).
STA - Is for storing the accumulator value to the memory location((Data moves/will
be copied from accumulator to the memory )
Example 2
Example 3
The main program loads the pointers to memory address 3000H and
4000H. It also loads number of bytes in E register
Subroutine transfers the data from the memory location indicated by the first
pointer to the memory location starting from the address indicated by the
second pointer.

The STAX B instruction in the 8085 microprocessorcopies the contents of the


accumulator into a memory location specified by the contents of the register
pair
The INX B instruction in the 8085 microprocessor increases the BC register
pair by one
Program
Stack
Stack is a part of RAM (Random Access Memory)
It is used as Last – IN-First-Out (LIFO) memory
To make use of stack first Stack pointer is initialized
Usually it is initialized to FFFF
Stack is used in two ways
User – PUSH and POP instructions
System --- When a subroutine is called.
Program
Interrupt Service Routine

Interrupt

Interrupt Service Routine Ends


RET
PUSH and POP instructions

The LXI SP instruction in an 8085


microprocessor loads a 16-bit address into the
stack pointer (SP) register pair:
Program

After PUSH D, SP is decremented by


1 so it becomes 24FF. At this location
03H is stored. Then again it is
decremented by 1 so it becomes
24EF. At this location 45H is stored
Demo for POP operation

When POP D is executed the contents from


the stack are read and loaded into E. Then
stack pointer is incremented and the contents
are read into the register D
And again the stack pointer is incremented

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy