{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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 Document Right 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)?
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.

{[ snackBarMessage ]}