.TITLE ACRET$ C register restore with AST support .IDENT "V2.1" .ENABL LC ;+ ; ; Index ASTs in RSX ; Index C register save and restore with RSX AST's ; Index C program execution environment with RSX AST's ; ; Usage ; ; AST entry ; mov r0,$$asr0 ; mov r1,$$asr1 ; clr -(sp) ; jsr r5,csv$ ; ... ; jmp acret$ ; ; Description ; ; C program Run-time Environment with RSX AST's ; ; Each C subroutine starts with a call to CSV$ and exits by ; jumping to CRET$. Upon exit, the stack need not be equal ; to its value on entrance. This version preserves R0, and R1 so ; that AST's will work. ; ; During the execution of all C subroutines, register R5 ; points to the current "environment." Within a subroutine, ; it appears as follows: ; ; _______________ ; | | ; SP -> | 1st loc. var. | -12(R5) C$AUTO-2(R5) ; |_______________| ; | | ; | Profile ptr | -10(R5) ; |_______________| ; | | ; | Saved R2 | -6(R5) ; |_______________| ; | | ; | Saved R3 | -4(R5) ; |_______________| ; | | ; | Saved R4 | -2(R5) ; |_______________| ; | | ; R5 -> | Saved R5 | ; |_______________| ; | | ; | Return add. | +2(R5) ; |_______________| ; | | ; | First arg. | +4(R5) C$PMTR+0(R5) ; |_______________| ; | | ; | Second arg. | +6(R5) C$PMTR+2(R5) ; |_______________| ; ; Within a subroutine, Registers R0-R4 and the top of the ; stack, (sp) are available for use. Registers R0 and R1 ; are not preserved by subroutines and may be used to pass ; a return value. ; ; R5 must not be modified by a subroutine. All variable ; addressing must be done by offsets to R5. Subroutine ; arguments must be accessed by reference to C$PMTR. ; Subroutine local variables must be accessed by reference ; to C$AUTO. This permits modification of calling sequences ; without rewriting all subroutines. ; ; [end] ;- ; ; Edit history ; 000001 RBD From old CSV.MAC. ; 000002 11-Mar-82 MM Added Whitesmith's entries ; V1.3 19-Oct-82 RBD Changed P-sections for new compiler. Documentation. ; V1.4 19-Jan-02 BQT Changed for I/D space and new stack layout. ; V2.0 31-Jan-02 BQT Changed since compiler now generates calls to ACSV ; when told to compile for ast. ; V2.1 02-Feb-02 BQT Changed compiler to use normal (P)CSV$ on entry. ; We now only need ACRET$ ; ; If C$PMTR/C$AUTO are undefined, just define them ; .iif ndf C$PMTR C$PMTR = 4 ;formal[n] @ c$pmtr+(r5) .iif ndf C$AUTO C$AUTO = -10 ;local[n] @ c$auto-(r5) .globl C$PMTR, C$AUTO .iif ne C$PMTR-4 .error Bad definition of C$PMTR .iif ne C$AUTO+10 .error Bad definition of C$AUTO ; ; By defining C$PMTR and C$AUTO as local symbols, the task ; builder need not do so much work .mcall astx$s .psect c$data,d,rw $$ASR0:: .WORD 0 ; Preserved R0. $$ASR1:: .WORD 0 ; Preserved R1. .PSECT C$CODE,i,ro ;03 ; ; Pop stuff to return. ; ACRET$:: MOV R5,R1 MOV -(R1),R4 MOV -(R1),R3 MOV -(R1),R2 MOV R5,SP MOV (SP)+,R5 TST (SP)+ ASL R0 ADD R0,SP MOV $$ASR0,R0 MOV $$ASR1,R1 ASTX$S ; .END