:TITLE[Bindings.0mc...June 9, 1982 2:51 PM, van Melle]; ******** * BIND byte 1 (lspLN) = n,v Byte2 (lspL2) = N * n = number of PVARS bound to NIL * v = number of PVARS bound to values popped off stack * N => last PVAR is stored into slot N lspBind: loadpage[pgBind], opcode[021]; gotop[.+1]; onpage[pgBind]; T ← NextData[IBuf]; lspLN ← T; T ← NextData[IBuf]; lspL2 ← T; * LN = 0,0,n,v T ← (ldf[lspLN, 10, 4]) - 1; * T ← n-1 lspL4 ← T; T ← (ldf[lspLN, 14, 4]) - 1; * T ← v-1 lspL3 ← T; T ← lspL2 ← lsh[lspL2, 1], task; * N*2 lspL0 ← 0C; * T0←NIL lspL1 ← 0C, call[.+1]; * T0←NIL lspBNil: lspL4 ← (lspL4) - 1, goto[lspBNilFin, R<0]; PStore2[lspEp, lspL0]; * Push NIL T ← (Form-2[AllOnes]) + T, return; * T ← T-2, return to lspBNil lspBNilFin: * Odd placement lspBVal: *** this loop may need tasking lspL3 ← (lspL3) - 1, goto[lspBValFin, R<0]; PStore2[lspEp, Stack]; * Pop Stack into next pvar StkState ← rcy[StkState, 1], goto[lspBVal1, Reven]; loadpage[pgHStack]; callp[HStkUndFlw]; * Assumes T undisturbed!!! lspBVal1: T ← (Form-2[AllOnes]) + T, goto[lspBVal]; * T ← T-2 lspBValFin: T ← (ldf[lspLN, 10, 4]); T ← (ldf[lspLN, 14, 4]) + T, task; * T ← n+v Stack&+1 ← (zero) - T - 1; * push -(n+v) -1 T ← lspL2; Stack&+1 ← T, goto[PushLBL]; * push 2*N ****** * UNBIND, DUNBIND lspDUnBind: * unbind, discard value loadpage[pgBind], opcode[023]; lspL0 ← (unboundPvar), gotop[lspUnbPop0]; lspUnBind: * unbind, preserve TOS loadpage[pgBind],opcode[022]; T ← Stack&-1; onpage[pgBind]; lspL1 ← T; * Pop TOS into L0,1 T ← Stack&-1; lspL0 ← T, goto[lspUnbPop]; lspUnbPop: * Pop check StkState ← rcy[StkState, 1], goto[lspUnbPop0, R Even]; loadpage[pgHStack]; callp[HStkUndFlw]; lspUnbPop0: MNBR ← Stack&-1; * offset of last var to unbind T ← (Stack&-1) + 1, goto[lspUnbPop, R>=0]; * T ← #vars to unbind; if non-negative, this was not a * binding mark, so keep popping until it is lspL2 ← T; T ← MNBR; lspLN ← (unboundPvar), call[.+1]; lspUnbPop2: lspL2 ← (lspL2) + 1, goto[lspUnbPop3, R>=0]; PStore1[lspEp, lspLN]; T ← (Form-2[AllOnes]) + T, return; * T ← T-2, return to lspUnbPop2 lspUnbPop3: T ← lspL0, skip[R>=0]; goto[PopLBL]; Stack&+1 ← T; * Push L0,1 back on T ← lspL1; Stack&+1 ← T, goto[nxiLBL]; * no overflow possible, since we popped at least one thing :END[Bindings];