12 Parameter Passing
12 Parameter Passing
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.
Interrupt