From 68d4a61bf1cf321cc03ce45d0082c28de986ffce Mon Sep 17 00:00:00 2001 From: Larry Masinter Date: Sat, 15 May 2021 12:21:06 -0700 Subject: [PATCH] WIP: make variable types in simulate_unbind match OP_unbind --- src/mvs.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/mvs.c b/src/mvs.c index 90592d9..8d60b5c 100644 --- a/src/mvs.c +++ b/src/mvs.c @@ -69,6 +69,8 @@ newframe: fnhead = (struct fnhead *)FuncObj; pc = (ByteCode *)PC + 3; /* to skip the miscn opcode we're in now */ } else { + unbind_count = 0; /* different frame */ + fnhead = (struct fnhead *)Addr68k_from_LADDR(POINTERMASK & SWA_FNHEAD((int)caller->fnheader)); pc = (ByteCode *)fnhead + (caller->pc); } @@ -271,23 +273,25 @@ LispPTR make_value_list(int argcount, LispPTR *argarray) { void simulate_unbind(FX2 *frame, int unbind_count, FX2 *returner) { int unbind; - LispPTR *stackptr = (LispPTR *)(Stackspace + frame->nextblock); + LispPTR *stack_pointer = (LispPTR *)(Stackspace + frame->nextblock); for (unbind = 0; unbind < unbind_count; unbind++) { - register int value; - register LispPTR *lastpvar; - int bindnvalues; - for (; ((int)*--stackptr >= 0);) - ; /* find the binding mark */ - value = (int)*stackptr; - lastpvar = (LispPTR *)((DLword *)frame + FRAMESIZE + 2 + GetLoWord(value)); - ; - bindnvalues = (~value) >> 16; - for (value = bindnvalues; --value >= 0;) { *--lastpvar = 0xffffffff; } - /* This line caused \NSMAIL.READ.HEADING to smash memory, */ - /* so I removed it 21 Jul 91 --JDS. This was the only */ - /* difference between this function and the UNWIND code */ - /* in inlineC.h */ - /* MAKEFREEBLOCK(stackptr, (DLword *)stackptr-nextblock); */ + register LispPTR value; + register LispPTR *ppvar; + register DLword num; + register DLword i; + + /* now, stack_pointer points the latter part in slot */ + for (; !(*--stack_pointer & 0x80000000);) + ; /* scan (until MSB == 1) */ + + value = *stack_pointer; + num = (DLword) ~(value >> 16); + ppvar = (LispPTR *)((DLword *)frame + FRAMESIZE + 2 + GetLoWord(value)); + + value = 0xffffffff; + for (i = 0; i < num; i++) { *--ppvar = value; } + + /* MAKEFREEBLOCK(stack_pointer, (DLword *)stack_pointer-nextblock); */ } if (returner) returner->fast = 0; /* since we've destroyed contiguity */