adapted for 2/4 code generation, and also fixed some bugs
This commit is contained in:
parent
fd467fd63d
commit
33f80c6eef
|
@ -29,6 +29,7 @@ transfer.e
|
||||||
store.c
|
store.c
|
||||||
confarray.c
|
confarray.c
|
||||||
load.c
|
load.c
|
||||||
|
blockmove.c
|
||||||
stackprio.c
|
stackprio.c
|
||||||
ChkCards.e
|
ChkCards.e
|
||||||
EM.e
|
EM.e
|
||||||
|
|
|
@ -44,13 +44,13 @@ IMPLEMENTATION MODULE Storage;
|
||||||
|
|
||||||
CONST
|
CONST
|
||||||
UNIT = SIZE(ALIGNTYPE);
|
UNIT = SIZE(ALIGNTYPE);
|
||||||
USED = BucketPtr(1);
|
|
||||||
|
|
||||||
VAR
|
VAR
|
||||||
FreeLists: ARRAY[0..NLISTS] OF BucketPtr; (* small blocks *)
|
FreeLists: ARRAY[0..NLISTS] OF BucketPtr; (* small blocks *)
|
||||||
Llist: BucketPtr; (* others *)
|
Llist: BucketPtr; (* others *)
|
||||||
Compacted: BOOLEAN; (* avoid recursive reorganization *)
|
Compacted: BOOLEAN; (* avoid recursive reorganization *)
|
||||||
FirstBlock: BucketPtr;
|
FirstBlock: BucketPtr;
|
||||||
|
USED: ADDRESS;
|
||||||
|
|
||||||
PROCEDURE MyAllocate(size: CARDINAL) : ADDRESS;
|
PROCEDURE MyAllocate(size: CARDINAL) : ADDRESS;
|
||||||
VAR nu : INTEGER;
|
VAR nu : INTEGER;
|
||||||
|
@ -187,7 +187,7 @@ IMPLEMENTATION MODULE Storage;
|
||||||
BEGIN
|
BEGIN
|
||||||
IF (a = NIL) THEN RETURN; END;
|
IF (a = NIL) THEN RETURN; END;
|
||||||
p := a - UNIT;
|
p := a - UNIT;
|
||||||
IF (p^.BNEXT # USED) THEN RETURN; END;
|
IF (p^.BNEXT # BucketPtr(USED)) THEN RETURN; END;
|
||||||
WITH p^ DO
|
WITH p^ DO
|
||||||
IF BSIZE <= NLISTS THEN
|
IF BSIZE <= NLISTS THEN
|
||||||
BNEXT := FreeLists[BSIZE];
|
BNEXT := FreeLists[BSIZE];
|
||||||
|
@ -283,9 +283,10 @@ IMPLEMENTATION MODULE Storage;
|
||||||
END;
|
END;
|
||||||
Llist := NIL;
|
Llist := NIL;
|
||||||
brk := sbrk(0);
|
brk := sbrk(0);
|
||||||
brk := sbrk(UNIT - INTEGER(brk MOD UNIT));
|
brk := sbrk(UNIT - brk MOD UNIT);
|
||||||
FirstBlock := sbrk(0);
|
FirstBlock := sbrk(0);
|
||||||
Compacted := FALSE;
|
Compacted := FALSE;
|
||||||
|
USED := 1;
|
||||||
END InitStorage;
|
END InitStorage;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -16,6 +16,7 @@ DEFINITION MODULE Traps;
|
||||||
in loop
|
in loop
|
||||||
*)
|
*)
|
||||||
ERRCARDUVFL = 69; (* CARDINAL underflow *)
|
ERRCARDUVFL = 69; (* CARDINAL underflow *)
|
||||||
|
ERRINTERNAL = 70; (* Internal error; should not happen *)
|
||||||
|
|
||||||
TYPE TrapHandler = EM.TrapHandler;
|
TYPE TrapHandler = EM.TrapHandler;
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ DEFINITION MODULE Unix;
|
||||||
(* Type needed for Signal *)
|
(* Type needed for Signal *)
|
||||||
TYPE SignalPrc = PROCEDURE(INTEGER):INTEGER;
|
TYPE SignalPrc = PROCEDURE(INTEGER):INTEGER;
|
||||||
CONST
|
CONST
|
||||||
SIGDFL = SignalPrc(0);
|
SIGDFL = SignalPrc(NIL);
|
||||||
SIGIGN = SignalPrc(1);
|
SIGIGN = SignalPrc(NIL+1);
|
||||||
ILLBREAK = ADDRESS(-1);
|
ILLBREAK = ADDRESS(NIL-1);
|
||||||
|
|
||||||
VAR errno: INTEGER;
|
VAR errno: INTEGER;
|
||||||
(* Possible values of errno: *)
|
(* Possible values of errno: *)
|
||||||
|
@ -93,7 +93,7 @@ DEFINITION MODULE Unix;
|
||||||
PROCEDURE ptrace(request, pid, addr, data: WORD) : INTEGER;
|
PROCEDURE ptrace(request, pid, addr, data: WORD) : INTEGER;
|
||||||
PROCEDURE read(fildes: INTEGER;
|
PROCEDURE read(fildes: INTEGER;
|
||||||
buf: ADDRESS;
|
buf: ADDRESS;
|
||||||
nbyte: INTEGER) : INTEGER;
|
nbyte: CARDINAL) : INTEGER;
|
||||||
PROCEDURE setuid(uid: INTEGER) : INTEGER;
|
PROCEDURE setuid(uid: INTEGER) : INTEGER;
|
||||||
PROCEDURE setgid(gid: INTEGER) : INTEGER;
|
PROCEDURE setgid(gid: INTEGER) : INTEGER;
|
||||||
PROCEDURE signal(sig: INTEGER;
|
PROCEDURE signal(sig: INTEGER;
|
||||||
|
|
23
lang/m2/libm2/blockmove.c
Normal file
23
lang/m2/libm2/blockmove.c
Normal 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++;
|
||||||
|
}
|
|
@ -46,6 +46,7 @@ static struct errm {
|
||||||
{ M2_UOVFL, "cardinal overflow"},
|
{ M2_UOVFL, "cardinal overflow"},
|
||||||
{ M2_FORCH, "Warning: FOR-loop control variable was changed in the body"},
|
{ M2_FORCH, "Warning: FOR-loop control variable was changed in the body"},
|
||||||
{ M2_UUVFL, "cardinal underflow"},
|
{ M2_UUVFL, "cardinal underflow"},
|
||||||
|
{ M2_INTERNAL, "internal error; ask an expert for help"},
|
||||||
{ -1, 0}
|
{ -1, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,12 @@
|
||||||
*/
|
*/
|
||||||
#include <m2_traps.h>
|
#include <m2_traps.h>
|
||||||
|
|
||||||
|
#if EM_WSIZE==EM_PSIZE
|
||||||
|
typedef unsigned pcnt;
|
||||||
|
#else
|
||||||
|
typedef unsigned long pcnt;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct descr {
|
struct descr {
|
||||||
char *addr;
|
char *addr;
|
||||||
int low;
|
int low;
|
||||||
|
@ -24,7 +30,7 @@ char *
|
||||||
_new_stackptr(pdescr, a)
|
_new_stackptr(pdescr, a)
|
||||||
register struct descr *pdescr;
|
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));
|
(EM_WSIZE - 1)) & ~(EM_WSIZE - 1));
|
||||||
|
|
||||||
if (ppdescr >= &descrs[10]) {
|
if (ppdescr >= &descrs[10]) {
|
||||||
|
@ -43,7 +49,7 @@ _copy_array(p, a)
|
||||||
register char *p;
|
register char *p;
|
||||||
{
|
{
|
||||||
register char *q;
|
register char *q;
|
||||||
register unsigned int sz;
|
register pcnt sz;
|
||||||
char dummy;
|
char dummy;
|
||||||
|
|
||||||
ppdescr--;
|
ppdescr--;
|
||||||
|
|
|
@ -23,9 +23,10 @@
|
||||||
exa _MainLB
|
exa _MainLB
|
||||||
exa _StackSize
|
exa _StackSize
|
||||||
exp $_catch
|
exp $_catch
|
||||||
|
inp $trap_handler
|
||||||
|
|
||||||
_handler
|
_handler
|
||||||
bss EM_PSIZE,0,0
|
con $_catch
|
||||||
_environ
|
_environ
|
||||||
bss EM_PSIZE,0,0
|
bss EM_PSIZE,0,0
|
||||||
_argv
|
_argv
|
||||||
|
@ -45,16 +46,6 @@ _StackSize
|
||||||
mainroutine
|
mainroutine
|
||||||
bss 2*EM_PSIZE,0,0
|
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
|
exp $m_a_i_n
|
||||||
pro $m_a_i_n, STACKSIZE
|
pro $m_a_i_n, STACKSIZE
|
||||||
|
|
||||||
|
@ -99,3 +90,15 @@ mainroutine
|
||||||
loc 0 ; should not get here
|
loc 0 ; should not get here
|
||||||
ret EM_WSIZE
|
ret EM_WSIZE
|
||||||
end
|
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
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,33 @@
|
||||||
Author: Ceriel J.H. Jacobs
|
Author: Ceriel J.H. Jacobs
|
||||||
Version: $Header$
|
Version: $Header$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <m2_traps.h>
|
||||||
|
|
||||||
|
#if EM_WSIZE==EM_PSIZE
|
||||||
|
typedef unsigned pcnt;
|
||||||
|
#else
|
||||||
|
typedef long pcnt;
|
||||||
|
#endif
|
||||||
|
|
||||||
_load(siz, addr, p)
|
_load(siz, addr, p)
|
||||||
register char *addr;
|
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;
|
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++;
|
while (siz--) *q++ = *addr++;
|
||||||
|
if (q - t == 2) {
|
||||||
|
*((unsigned *)(&p)) = *((unsigned short *) (&t[0]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,31 @@
|
||||||
Author: Ceriel J.H. Jacobs
|
Author: Ceriel J.H. Jacobs
|
||||||
Version: $Header$
|
Version: $Header$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <m2_traps.h>
|
||||||
|
|
||||||
|
#if EM_WSIZE==EM_PSIZE
|
||||||
|
typedef unsigned pcnt;
|
||||||
|
#else
|
||||||
|
typedef long pcnt;
|
||||||
|
#endif
|
||||||
|
|
||||||
_store(siz, addr, p)
|
_store(siz, addr, p)
|
||||||
register char *addr;
|
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;
|
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++;
|
while (siz--) *addr++ = *q++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue