{File name LispStkScan.mc Description: DandeLion InterLisp Emulator StkScan Author: Charnley Last modified: Charnley 2-May-84 12:09:41 Created: 2-May-84 11:42:53 } {- - - - - - - - - - - - - - - - - - - - - - - - - - 57 STKSCAN 0 0 \STKSCAN TOS is VAR. NO! -- If TOS is not litatom, punt. Returns 24 bit pointer to cell where VAR is bound. NO! -- Note: must check VAR=NIL, and return pointer to NIL's value cell. (Free variable lookup algorithm fails if given NIL, at least on Dorado.) If variable was bound on stack, the value returned will be a pointer into stack space. If variable is not bound, value will be pointer to top level value cell. - - - - - - - - - - - - - - - - - - - - - - - - - -} @STKSCAN: opcode[57'b], {free var lookup on tos, which is an atom} { look up variable in current frame; fill in binding pointer (chaining not implemented) This code assumes that NAMETABLE is contiguous in real memory {either it is on the stack, or within a code header which is non-page crossing} on Entry: c1 uTOS restored to TOS if fault uTOSH restored to TOSH if fault PV current frame (point to PV region) Q {uChain} (odd) stack pointer to variable to be looked up (Pv + ib + 1) rhTT, TT virtual address of name table (usually function header) L3 caller's return link at[L3, 10, fvCaller] also used with fvfixup after fault uses during subroutine: rhRx, Rx real address of name table PV frame extension pointers (point to PV region)(travel up alinks) uPV save local PV TOS used uChain TOSH{chain} rhTOSH nRhS {set once at odd time; must be left}{*} used with TOSH{chain} uName TOSH{name} _ [UvCL + T/2 {- UvCL.nlocals} + UvCL.fvaroffset] ntSize, offset, L0, L1 on Return: c1 preserves S, PV, PC, L2, uTOS, uTOSH smashes TOS, TOSH {but preserved in uTOS, uTOSH} rhTT, TT virtual address of free value @(chain) filled in binding pointer L1 binding type{fvStack, fvGlobal} Dispatch pending on Fault: TOS _ uTOS, TOSH _ uTOSH, PV _ uPV } { INITIALIZE: uTOS _ TOS uTOSH _ TOSH TOSH _ name {from TOS} uChain _ 0 uPV _ PV L3 _ L3.StkScan enter at newFrame: c1 } uPV _ PV, L3 _ L3.StkScan, c1; uTOSH _ TOSH, c2; uTOS _ TOSH _ TOS, c3; uChain _ 0, c1; , c2; CALL[newFrame], c3; Q _ rhTT, CANCELBR[$, 0F], c1, at[L3.StkScan, 10, fvCaller]; TOSH _ Q, c2; TOS _ TT, GOTO[evalEND], c3; PV _ uPV, GOTO[NoFixes], c3, at[L3.StkScan, 10, fvfixup]; { E N D }