{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

param_passing - University of Florida EEL 4744 Drs E M...

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

View Full Document Right Arrow Icon
University of Florida EEL 4744 Drs. E. M. Schwartz &A. Antonio Arroyo Department of Electrical & Computer Engineering 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 ...
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern