int main() { VAL one; VAL two; VAL three; VAL four,five,six,seven,eight,nine,ten; VAL tmp; VM_init(); one = MKCON1(1,MKCON0(0)); two = MKCON1(1,one); three = MKCON1(1,two); four = MKCON1(1,three); five = MKCON1(1,four); six = MKCON1(1,five); seven = MKCON1(1,six); eight = MKCON1(1,seven); nine = MKCON1(1,eight); ten = MKCON1(1,nine); tmp = _EVM_testval(); shownat(tmp); printf("\n"); return 0; }
VMPTR_TYPE VM_alloc(long s, int zero) { VMHEAD HUGE *h; VMPTR p; register char HUGE *t; FNAME(VM_alloc); TEST(fun, 0); #if (defined(__TURBOC__) || defined(_MSC_VER)) && defined(USE_MALLOC) if (s > 65534U) return(0); #endif if (s > MAXSALOC || s < 1L) return(0); if (DMhandle == -1 && VM_init()) return(0); d_compact(); TEST(fun, 1); if (!(p.i = vmget_head())) return(0); if (s <= IMSIZE) { h = &VMbase[p.p.b][p.p.l]; h->type = MT_IMEDIATE; VMlive++; if (zero) memset((char HUGE *) &h->mru_link, 0, IMSIZE); TEST(fun, 2); return(p.i); } /* &VMbase[x][y] cannot be done before rmalloc() bacause rmalloc may change the address of VMbase[x] during compact() */ t = rmalloc((MAX_SIZ_TYP) s); h = &VMbase[p.p.b][p.p.l]; h->mem = t; if (!h->mem) { vmfree_head(p.i); TEST(fun, 3); return(0); } h->type = MT_MEMORY; vm_link(h, p.i); h->size = s; h->diskadd = -1L; VMtotal += s; VMlive++; TEST(fun, 4); if (zero) { for (t=h->mem ; s-- ; ) *t++ = '\0'; h->type |= MT_DIRTY; } return(p.i); }
int main() { VAL f; VAL one; VAL two; VAL three; VAL four; VAL tmp; VAL* args; VM_init(); one = MKCON1(1,MKCON0(0)); two = MKCON1(1,one); three = MKCON1(1,two); four = MKCON1(1,three); args = MKARGS(6); args[0] = four; args[1] = two; args[2] = four; args[3] = two; args[4] = four; args[5] = three; tmp = CLOSUREN(ADDER,6,args,6); // tmp = _EVM_plus(two,two); shownat(tmp); printf("\n"); // tmp = CLOSUREADD1(tmp,three); // shownat(tmp); // printf("\n"); // tmp = eval(CLOSUREADD1(tmp,two)); shownat(eval(tmp)); printf("\n"); return 0; }
int VM_rest(char *f) { short mb; register int i, b; VMPTR p; int h, s = (sizeof(VMHEAD) * VMLEGSIZ); VMHEAD HUGE *v; char HUGE *t; FNAME(VM_rest); TEST(fun, 0); VM_end(); VM_init(); h = OPEN(f, O_RDONLY | O_BINARY); if (h == -1) return(1); if (sizeof(VMfree) != read(h, (char *) &VMfree, sizeof(VMfree))) { rest_clean(1, h, -1, -1); return(2); } if (sizeof(mb) != read(h, (char *) &mb, sizeof(mb))) { rest_clean(1, h, -1, -1); return(2); } for (i=0 ; i != mb ; ++i) { VMbase[i] = (VMHEAD HUGE *) rmalloc((MAX_SIZ_TYP) s); if (!VMbase[i]) { rest_clean(2, h, -1, -1); return(3); } if (s != read(h, (char HUGE *) VMbase[i], s)) { rest_clean(2, h, -1, -1); return(2); } } for (b=0 ; b != mb ; ++b) { v = VMbase[b]; for (i=b?0:1 ; i != VMLEGSIZ ; ++i) { if (v[i].type != MT_NOTUSED && !(v[i].type & MT_IMEDIATE)) VMtotal += v[i].size; if (v[i].type != MT_NOTUSED && (!(v[i].type & MT_DISK) || v[i].diskadd != -1L)) VMlive++; if (v[i].type & MT_MEMORY || v[i].type & MT_DISK && v[i].diskadd != -1L) { v[i].type = MT_MEMORY | MT_DIRTY; if (!(t = rmalloc(v[i].size))) { rest_clean(3, h, b, i); return(3); } /* this must be done because rmalloc calls compact which may change the address of VMbase[x] */ v = VMbase[b]; v[i].mem = t; if ((long) v[i].size != longread(h, v[i].mem, (long) v[i].size)) { rest_clean(3, h, b, i+1); return(2); } p.p.b = b; p.p.l = i; vm_link(&v[i], p.i); v[i].diskadd = -1L; } } } if (-1 == close(h)) error(fun, "close"); TEST(fun, 1); return(0); }