program VarArgsImpl,(0,0,0),(0,0,0),("VarArgsImpl.as",(0,0,0)), VarArgsT
VarArgsT: type proc [] returns []
-- VarArgsImpl.ass
-- NFS 16-Jul-85 16:25:10
-- MEW 18-Jul-85 20:54:52
-- NFS 2-Aug-85 17:15:03
-- Procedures for accessing parameters of functions with variable number of
-- parameters.
-- VaStart returns a pointer to a block containing the parameters.
-- If 1 word is on the stack when function is called, then params. were passed
-- in a frame (more than 12 words of parameters). Otherwise, parameters were
-- passed on the stack. If they were passed on the stack, then it allocates a new
-- frame and copies the contents of the stack to the new frame.
export VarArgs
exportproc VaStart, VarArgs
VaStartT: type proc[] returns[]
VaStart: entry 18, VaStartT
stack: var stacktype, 224, 0
stacktype: type array indextype of CARDINAL
indextype: type subrange [0,14] of CARDINAL
stateword: var statetype, 16, 224
statetype: type record[(break, CARDINAL, 0, 8), (sp, CARDINAL, 8, 8)]
dsk [lf+0]
load 1
lea [lf+0]
read.f [8:8]14 -- Get stack ptr.
jumpn fp1 -- jump if params. passed on stack
-- params already in frame
load [lf+0] -- Get ptr. to param. frame..
jump fp2
-- params on stack
fp1: af 12 -- Allocate frame for params.
store [lf+16] -- Save ptr. to param. frame beyond params.
lea [lf+0] -- Load ptr. to params. dumped in local frame
load 12 -- Load No. of words to copy to param frame
load [lf+16] -- Load ptr. to param. frame
blt -- Copy params from local frame to param frame
load [lf+16] -- Put ptr. to param frame on stack for efc.
fp2: lp
ret
end
-- VaEnd frees the parameter frame.
exportproc VaEnd, VarArgs
VaEndT: type proc[] returns []
VaEnd: entry 2, VaEndT
dis
ff
load.d 0
ret
end
ret
end;