.TITLE AddVersion3 ; Program to calculate the expression S = A + B A: .LONG 3 ; Initialize A B: .LONG 7 ; Initialize B S: .BLKL 1 ; Save room for S ArgList: .ADDRESS A ; Argument list passing .ADDRESS B ; A, B, and S .ADDRESS S ; by reference ; Subroutine Add(X, Y, Sum) for calculating Sum = X + Y ; Assumes an argument list ; Parameter Displacement Use Passed by X = 0 ; Input Reference Y = 4 ; Input Reference Sum = 8 ; Output Reference ; Destroys R2 and R3 Add: POPL R3 ; Pop return address POPL R2 ; Pop address of argument ; list into R2 ADDL3 @X(R2), @Y(R2), @Sum(R2) ; Sum <-- X + Y PUSHL R3 ; Push return address RSB ; Return from subroutine ; The main program: .Entry ByReferenceInMemory, 0 ; Call Sum (A, B, S) PUSHAL ArgList ; Push address of the argument ; list onto stack BSBB Add ; Call the subroutine $EXIT_S .END ByReferenceInMemory