Param_passing - University of Florida EEL 4744 Drs E M Schwartz&A Antonio Arroyo Professors in ECE Department of Electrical Computer Engineering

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
EEL 4744 Drs. E. M. Schwartz Professors in ECE Page 1/5 PARAMETER PASSING 15-Mar-01 11:29 AM PARAMETER PASSING METHODS How do you pass parameters between the subroutines (or interrupts) and the main routine or other subroutines? 1. Pass the parameter(s) (data or pointer) in the internal registers. 2. Pass the parameter(s) immediately after the call instruction, i.e. in the program memory space. (This requires that the parameter(s) be fixed at assembler time.) 3. Pass a pointer to the location of the parameter(s) immediately after the call instruction. 4. Pass the parameter(s) on the stack prior to the call. (PSH) 5. Pass a pointer to parameter(s) on the stack prior to the call. (PSH) The Problem: Find the average of two numbers Solution 1: Pass the parameter(s) in the internal registers. Solution 1a: Pass the parameter data in the internal registers. ORG $B600 ;Start program at $B600 START: LDS #$0041 ;initialize stack pointer LDAA #$37 ;Load data in the A and B LDAB #$A3 ; registers JSR AVG ;Call the subroutine AVG to ; get average ... ******************************************************* * Get average of inputs in accumulators A and B * Output in accumulator A AVG: ABA ;A=A+B ASRA ;Shift A right by 1 bit ; (divide by 2) keeping ; bit 7 (for sign ; extension) RTS Solution 1b: Pass the parameters addresses in internal pointer registers. ORG $0000 DATA: FCB $37, $A3 ORG $B600 ;Start program at $B600 START: LDS #$0041 ;initialize stack pointer LDX #DATA ;Load X index reg. with ; address of data JSR AVG1 ;Call the subroutine AVG1 ; to get average ... ***************************************************** * Get average of two data bytes in successive memory
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/13/2011 for the course EEL 4744c taught by Professor Staff during the Fall '09 term at University of Florida.

Page1 / 5

Param_passing - University of Florida EEL 4744 Drs E M Schwartz&A Antonio Arroyo Professors in ECE Department of Electrical Computer Engineering

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online