subroutines - CSE 379 Subroutines Subroutines Why use...

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

View Full Document Right Arrow Icon
CSE 379 Subroutines Subroutines Why use subroutines? Readability Simplifies Design Simplifies Testing Modularity Ease of Modification Code Reuse Terminology Subroutine Routine called by higher level routine Function Subroutine which returns a value Procedure Subroutine which carries out operation on data passed to routine Calling a Subroutine Branch with Link (BL) Syntax BL label PC = label Range: ± 4 MB lr (r14) = Address of instruction after BL Example BL strcpy Task Transfer control to the label identified by BL The address of the instruction following the branch and link is loaded into the link register (lr) Note lr is the same as r14 Returning from a Subroutine Copy the value from the link register into the program counter Example: MOV pc, lr
Background image of page 1

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

View Full DocumentRight Arrow Icon
Example .. BL evaluate ; Branch .. .. evaluate . . ; Beginning of Routine .. MOV pc, lr ; Return Branch vs. Branch with Link What is the difference between B cc and BL (where cc = condition code)? Are they interchangeable?
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 11/03/2011 for the course CSE 380 at SUNY Buffalo.

Page1 / 4

subroutines - CSE 379 Subroutines Subroutines Why use...

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

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