Understanding Assembly Language Parameter Passing Mechanisms
| Location | Label | Instruction | Comment |
|---|---|---|---|
| ORG 200 | Program starts at 200 | ||
| 200 | LDA X | Load first operand into AC | |
| 201 | BSA OR | Branch to subroutine OR | |
| 202 | HEX 3AF6 | Second operand stored here | |
| 203 | STA Y | Subroutine returns here | |
| 204 | HLT | ||
| 205 | X, | HEX 7B95 | First operand stored here |
| 206 | Y, | HEX 0 | Result stored here |
| 207 | OR, | HEX 0 | Subroutine OR |
| 208 | CMA | Complement first operand | |
| 209 | STA TMP | Store in temporary location | |
| 20A | LDA OR I | Load second operand | |
| 20B | CMA | Complement second operand | |
| 20C | AND TMP | AND complemented operands | |
| 20D | CMA | Complement again to get OR | |
| 20E | ISZ OR | Increment return address | |
| 20F | BUN OR I | Return to main program | |
| 210 | TMP, | HEX 0 | Temporary storage |
| END |
The subroutine accesses parameters through memory addresses. Changes made in the subroutine affect the original data.
Stores the return address in the first location of the subroutine and jumps to the next location to begin execution.
Uses the 'I' suffix to access data indirectly through pointers, enabling flexible parameter passing.
Click the buttons below to see how the subroutine execution affects memory locations:
This subroutine implements the OR operation using De Morgan's Law:
The algorithm: