Call Site - Assembler Example

Assembler Example

IBM/360 or Z/Architecture

* (usually) external call.... R13 usually points to a save area for general purpose registers beforehand * and R1 points to a list of addresses of parameters (if any) LA R1,=A(B) point to (address of) variable 'B' L R15,=A(SQR) Load pointer (address constant) to separately compiled/assembled subroutine BALR R14,R15 Go to subroutine, which returns - usually at zero displacement on R14 * internal call (usually much smaller overhead and possibly 'known' parameters) BAL R14,SQR Go to program label and return

Sometimes, as an efficient method of indicating success or otherwise, return may be accomplished by returning at +0 or +4,+8 etc. requiring a small branch table at the return point - to go directly to process the case (as in HLL Switch statement).

BAL R14,SQR Go to program label and return (using offset on R14 as return address) B FAIL (RET+0) - SOMETHING WRONG * (RET+4) - O.K.

Conventionally however, a return code is set in R15 (0=OK, 4= failure, or similar ..) but requiring a separate instruction to test R15 or use directly as a branch index.

Read more about this topic:  Call Site