adapted for 2/4 code generation, and also fixed some bugs

This commit is contained in:
ceriel 1988-03-18 14:23:04 +00:00
parent fd467fd63d
commit 33f80c6eef
10 changed files with 100 additions and 22 deletions

View file

@ -29,6 +29,7 @@ transfer.e
store.c
confarray.c
load.c
blockmove.c
stackprio.c
ChkCards.e
EM.e

View file

@ -44,13 +44,13 @@ IMPLEMENTATION MODULE Storage;
CONST
UNIT = SIZE(ALIGNTYPE);
USED = BucketPtr(1);
VAR
FreeLists: ARRAY[0..NLISTS] OF BucketPtr; (* small blocks *)
Llist: BucketPtr; (* others *)
Compacted: BOOLEAN; (* avoid recursive reorganization *)
FirstBlock: BucketPtr;
USED: ADDRESS;
PROCEDURE MyAllocate(size: CARDINAL) : ADDRESS;
VAR nu : INTEGER;
@ -187,7 +187,7 @@ IMPLEMENTATION MODULE Storage;
BEGIN
IF (a = NIL) THEN RETURN; END;
p := a - UNIT;
IF (p^.BNEXT # USED) THEN RETURN; END;
IF (p^.BNEXT # BucketPtr(USED)) THEN RETURN; END;
WITH p^ DO
IF BSIZE <= NLISTS THEN
BNEXT := FreeLists[BSIZE];
@ -283,9 +283,10 @@ IMPLEMENTATION MODULE Storage;
END;
Llist := NIL;
brk := sbrk(0);
brk := sbrk(UNIT - INTEGER(brk MOD UNIT));
brk := sbrk(UNIT - brk MOD UNIT);
FirstBlock := sbrk(0);
Compacted := FALSE;
USED := 1;
END InitStorage;
BEGIN

View file

@ -16,6 +16,7 @@ DEFINITION MODULE Traps;
in loop
*)
ERRCARDUVFL = 69; (* CARDINAL underflow *)
ERRINTERNAL = 70; (* Internal error; should not happen *)
TYPE TrapHandler = EM.TrapHandler;

View file

@ -10,9 +10,9 @@ DEFINITION MODULE Unix;
(* Type needed for Signal *)
TYPE SignalPrc = PROCEDURE(INTEGER):INTEGER;
CONST
SIGDFL = SignalPrc(0);
SIGIGN = SignalPrc(1);
ILLBREAK = ADDRESS(-1);
SIGDFL = SignalPrc(NIL);
SIGIGN = SignalPrc(NIL+1);
ILLBREAK = ADDRESS(NIL-1);
VAR errno: INTEGER;
(* Possible values of errno: *)
@ -93,7 +93,7 @@ DEFINITION MODULE Unix;
PROCEDURE ptrace(request, pid, addr, data: WORD) : INTEGER;
PROCEDURE read(fildes: INTEGER;
buf: ADDRESS;
nbyte: INTEGER) : INTEGER;
nbyte: CARDINAL) : INTEGER;
PROCEDURE setuid(uid: INTEGER) : INTEGER;
PROCEDURE setgid(gid: INTEGER) : INTEGER;
PROCEDURE signal(sig: INTEGER;

23
lang/m2/libm2/blockmove.c Normal file
View file

@ -0,0 +1,23 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: block moves
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
#if EM_WSIZE==EM_PSIZE
typedef unsigned pcnt;
#else
typedef unsigned long pcnt;
#endif
_blockmove(siz, dst, src)
pcnt siz;
register char *dst, *src;
{
while (siz--) *dst++ = *src++;
}

View file

@ -46,6 +46,7 @@ static struct errm {
{ M2_UOVFL, "cardinal overflow"},
{ M2_FORCH, "Warning: FOR-loop control variable was changed in the body"},
{ M2_UUVFL, "cardinal underflow"},
{ M2_INTERNAL, "internal error; ask an expert for help"},
{ -1, 0}
};

View file

@ -10,6 +10,12 @@
*/
#include <m2_traps.h>
#if EM_WSIZE==EM_PSIZE
typedef unsigned pcnt;
#else
typedef unsigned long pcnt;
#endif
struct descr {
char *addr;
int low;
@ -24,7 +30,7 @@ char *
_new_stackptr(pdescr, a)
register struct descr *pdescr;
{
unsigned int size = (((pdescr->highminlow + 1) * pdescr->size +
pcnt size = (((pdescr->highminlow + 1) * pdescr->size +
(EM_WSIZE - 1)) & ~(EM_WSIZE - 1));
if (ppdescr >= &descrs[10]) {
@ -43,7 +49,7 @@ _copy_array(p, a)
register char *p;
{
register char *q;
register unsigned int sz;
register pcnt sz;
char dummy;
ppdescr--;

View file

@ -23,9 +23,10 @@
exa _MainLB
exa _StackSize
exp $_catch
inp $trap_handler
_handler
bss EM_PSIZE,0,0
con $_catch
_environ
bss EM_PSIZE,0,0
_argv
@ -45,16 +46,6 @@ _StackSize
mainroutine
bss 2*EM_PSIZE,0,0
inp $trap_handler
pro $trap_handler,0
lol 0 ; trap number
lae _handler
loi EM_PSIZE
cai
asp EM_WSIZE
rtt
end 0
exp $m_a_i_n
pro $m_a_i_n, STACKSIZE
@ -99,3 +90,15 @@ mainroutine
loc 0 ; should not get here
ret EM_WSIZE
end
pro $trap_handler,0
lol 0 ; trap number
lae _handler
loi EM_PSIZE
cai
lpi $trap_handler
sig
asp EM_PSIZE+EM_WSIZE
rtt
end 0

View file

@ -8,11 +8,33 @@
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
#include <m2_traps.h>
#if EM_WSIZE==EM_PSIZE
typedef unsigned pcnt;
#else
typedef long pcnt;
#endif
_load(siz, addr, p)
register char *addr;
register int siz;
register pcnt siz;
{
/* Make sure, that a value with a size that could have been
handled by the LOI instruction ends up at the same place,
where it would, were the LOI instruction used.
*/
register char *q = (char *) &p;
char t[4];
if (siz < EM_WSIZE && EM_WSIZE % siz == 0) {
/* as long as EM_WSIZE <= 4 ... */
if (siz != 2) TRP(M2_INTERNAL); /* internal error */
q = &t[0];
}
while (siz--) *q++ = *addr++;
if (q - t == 2) {
*((unsigned *)(&p)) = *((unsigned short *) (&t[0]));
}
}

View file

@ -8,11 +8,31 @@
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
#include <m2_traps.h>
#if EM_WSIZE==EM_PSIZE
typedef unsigned pcnt;
#else
typedef long pcnt;
#endif
_store(siz, addr, p)
register char *addr;
register int siz;
register pcnt siz;
{
/* Make sure, that a value with a size that could have been
handled by the LOI instruction is handled as if it was
loaded with the LOI instruction.
*/
register char *q = (char *) &p;
char t[4];
if (siz < EM_WSIZE && EM_WSIZE % siz == 0) {
/* as long as EM_WSIZE <= 4 ... */
if (siz != 2) TRP(M2_INTERNAL); /* internal error */
*((unsigned short *) (&t[0])) = *((unsigned *) q);
q = &t[0];
}
while (siz--) *addr++ = *q++;
}