Added .align 2. Prevents end of bss to be odd.

Especially important for malloc, it distinguishes between
odd and even word pointers.
This commit is contained in:
em
1985-02-17 01:12:36 +00:00
1706 changed files with 178558 additions and 0 deletions

29
mach/m68k2/Action Normal file
View File

@@ -0,0 +1,29 @@
name "Motorola 68000 assembler"
dir as
end
name "Motorola 68000 2-4 backend"
dir cg
end
name "Motorola 68000 interpreters"
system m68*
dir int
end
name "Motorola 68000 2-4 download program(s)"
failure "Sorry, the m68k? conversion program has to be translated on the target machine"
dir dl
end
name "Motorola 68000 2-4 C libraries"
dir libcc
end
name "Motorola 68000 2-4 EM library"
dir libem
end
name "Motorola 68000 2-4 Pascal library"
dir libpc
end
name "Motorola 68000 2-4 System library"
dir libsys
end
name "Motorola 68000 2-4 Basic library"
dir libbc
end

68
mach/m68k2/README Normal file
View File

@@ -0,0 +1,68 @@
The m68k2 back end is an EM code generator for the
Motorola MC68000. It defines an integer to be 16 bits
and a pointer to be 32 bits.
At present it does not support floating point operations.
(All EM floating point instructions are translated to the
68000 "trap" instruction.)
The m68k2 back end generates code for the ACK 68000 assembler/linker.
(The mnemonics recognized by this assembler can be found in
"as/mach3.c"). As this assembler/linker does not define an
object (.o) format, it can only link assembly files. Consequently,
all library modules are stored as assembly files.
Some parts of the back end are system dependent, i.e. they depend
on the kind of target 68000 system.
- The way to do a Unix system call may vary from system to system.
For every system call you need to have an assembly routine that
passes the arguments and the system call number to Unix.
These routines should be put in the library file "lib/tail_mon".
The distribution contains a tail_mon file tailored for
UniSoft Unix (see directory "libsys").
Beware that several Unix systems (e.g. UniSoft Unix) use 4-byte
integers, whereas the m68k2 back end produces code for 2-byte
integers. In this case all system calls having an "int" parameter
should convert their parameters to "long"s.
- Most systems require some sort of "test for enough stack space"
at the beginning of every procedure, to get around the "back up"
problem. E.g. UniSoft Unix requires a "tst.b N(sp)" instruction
This instruction is generated by the routines "prolog()" and
"save" in "cg/mach.c".
- The output of the ACK 68000 assembler/linker is an a.out file that
has a different format as an a.out file on your system. (As most
68000 systems have different a.out formats, there is no such thing
as "the" 68000 a.out format). So a program is needed to convert the
ACK a.out format (i.e. a series of "emitrecs" as defined in
"as/frame.c") to your a.out format (as defined in
"/usr/include/a.out.h"). The 1-page program "dl/cv.c" does
the job for UniSoft Unix. It probably need only be slightly
modified for your system. Note that the program
generates no text or bss segments, but only a data segment.
If your target 68000 does not run Unix, but is e.g. a stand alone
68000, you will need a program to download the ACK a.out file.
The program "dl/dl.c" produces Intel Hex format on standard output
from an a.out file.
- The EM runtime start-off ("libem/head_em.s") may have to be modified.
It should call the procedure _m_a_i_n with parameters (argc,argv,envp).
Usually, Unix will put these on top of the stack before starting
the program. Note, however, that for 4-byte systems Unix will provide
a 4-byte argc, while _m_a_i_n expects a 2-byte argc; so the value
must be shortened to 2 bytes.
The head_em also does a brk() system call to allocate the bss.
(The size of the bss cannot be obtained from an ACK a.out file).
The m68k2 code generator translates most EM instructions in line.
For some complex EM instructions it uses assembly routines (stored in the
library "libem/libem_s.a").
The generated code does not check for array bound errors, overflow in
arithmetic operations or division by zero (the latter will cause a hardware
trap).
The code generator has the following register conventions:
a7: stack pointer
a6: local base pointer
a0,a1,d0,d1,d2: scratch registers
(d0 is also used for 2/4 bytes function results;
d0 and d1 are used for 8 bytes function results)
a2-a5,d3-d7: register variables.

223
mach/m68k2/cg/mach.c Normal file
View File

@@ -0,0 +1,223 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
/*
* machine dependent back end routines for the Motorola 68000
*/
con_part(sz,w) register sz; word w; {
while (part_size % sz)
part_size++;
if (part_size == TEM_WSIZE)
part_flush();
if (sz == 1) {
w &= 0xFF;
if (part_size == 0)
w <<= 8;
part_word |= w;
} else {
assert(sz == 2);
part_word = w;
}
part_size += sz;
}
con_mult(sz) word sz; {
if (sz != 4)
fatal("bad icon/ucon size");
fprintf(codefile,".long %s\n",str);
}
con_float() {
static int been_here;
if (argval != 4 && argval != 8)
fatal("bad fcon size");
fprintf(codefile,".long\t");
if (argval == 8)
fprintf(codefile,"F_DUM,");
fprintf(codefile,"F_DUM\n");
if ( !been_here++)
{
fprintf(stderr,"Warning : dummy float-constant(s)\n");
}
}
#ifdef REGVARS
regscore(off,size,typ,score,totyp)
long off;
{
if (score == 0) return -1;
switch(typ) {
case reg_float:
return -1;
case reg_pointer:
if (size != 4 || totyp != reg_pointer) return -1;
score *= 2;
break;
case reg_loop:
score += 5;
/* fall through .. */
case reg_any:
if (size != 2 || totyp == reg_pointer) return -1;
break;
}
if (off >= 0) {
/* parameters must be initialised with an instruction
* like "move.w 4(a6),d0", which costs 2 words.
*/
score -= 2;
}
score -= 1; /* take save/restore into account */
return score;
}
struct regsav_t {
char *rs_reg; /* e.g. "a3" or "d5" */
long rs_off; /* offset of variable */
int rs_size; /* 2 or 4 bytes */
} regsav[9];
int regnr;
i_regsave()
{
regnr = 0;
}
#define MOVEM_LIMIT 2
/* If #registers to be saved exceeds MOVEM_LIMIT, we
* use the movem instruction to save registers; else
* we simply use several move.l's.
*/
save()
{
register struct regsav_t *p;
if (regnr > MOVEM_LIMIT) {
fprintf(codefile,"movem.l ");
for (p = regsav; ;) {
fprintf(codefile,"%s",p->rs_reg);
if (++p == &regsav[regnr]) break;
putc('/',codefile);
}
fprintf(codefile,",-(sp)\n");
} else {
for (p = regsav; p < &regsav[regnr]; p++) {
fprintf(codefile,"move.l %s,-(sp)\n",p->rs_reg);
}
}
/* initialise register-parameters */
for (p = regsav; p < &regsav[regnr]; p++) {
if (p->rs_off >= 0) {
fprintf(codefile,"move.%c %ld(a6),%s\n",
(p->rs_size == 4 ? 'l' : 'w'),
p->rs_off,
p->rs_reg);
}
}
}
restr()
{
register struct regsav_t *p;
if (regnr > MOVEM_LIMIT) {
fprintf(codefile,"movem.l (sp)+,");
for (p = regsav; ;) {
fprintf(codefile,"%s",p->rs_reg);
if (++p == &regsav[regnr]) break;
putc('/',codefile);
}
putc('\n',codefile);
} else {
for (p = &regsav[regnr-1]; p >= regsav; p--) {
fprintf(codefile,"move.l (sp)+,%s\n",p->rs_reg);
}
}
fprintf(codefile,"unlk a6\n");
fprintf(codefile,"rts\n");
}
f_regsave()
{
save();
}
regsave(str,off,size)
char *str;
long off;
{
assert (regnr < 9);
regsav[regnr].rs_reg = str;
regsav[regnr].rs_off = off;
regsav[regnr++].rs_size = size;
fprintf(codefile, "!Local %ld into %s\n",off,str);
}
regreturn()
{
restr();
}
#endif
prolog(nlocals) full nlocals; {
fprintf(codefile,"tst.b -%D(sp)\nlink\ta6,#-%D\n",nlocals+40,nlocals);
}
mes(type) word type ; {
int argt ;
switch ( (int)type ) {
case ms_ext :
for (;;) {
switch ( argt=getarg(
ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) {
case sp_cend :
return ;
default:
strarg(argt) ;
fprintf(codefile,".define %s\n",argstr) ;
break ;
}
}
default :
while ( getarg(any_ptyp) != sp_cend ) ;
break ;
}
}
char *segname[] = {
".text", /* SEGTXT */
".data", /* SEGCON */
".data", /* SEGROM */
".bss" /* SEGBSS */
};

28
mach/m68k2/cg/mach.h Normal file
View File

@@ -0,0 +1,28 @@
#define ex_ap(y) fprintf(codefile,".extern %s\n",y)
#define in_ap(y) /* nothing */
#define newilb(x) fprintf(codefile,"%s:\n",x)
#define newdlb(x) fprintf(codefile,"%s:\n",x)
#define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y)
#define newlbss(l,x) fprintf(codefile,"%s:.space\t%D\n",l,x);
#define pop_fmt "(sp)+"
#define cst_fmt "%D"
#define off_fmt "%D"
#define ilb_fmt "I%03x%x"
#define dlb_fmt "_%d"
#define hol_fmt "hol%d"
#define loc_off "%d(a6)"
#define arg_off "8+%d(a6)"
#define hol_off "%d+hol%d"
#define con_cst(x) fprintf(codefile,".short\t%d\n",x)
#define con_ilb(x) fprintf(codefile,".long\t%s\n",x)
#define con_dlb(x) fprintf(codefile,".long\t%s\n",x)
#define modhead ""
#define id_first '_'
#define BSS_INIT 0

2752
mach/m68k2/cg/table Normal file

File diff suppressed because it is too large Load Diff

21
mach/m68k2/dl/Makefile Normal file
View File

@@ -0,0 +1,21 @@
CFLAGS=-O
cv: cv.o
$(CC) -o cv -n cv.o
install: ins_cv
ins_cv: cv
../../install cv
cmp: cmp_cv
cmp_cv: cv
-../../compare cv
opr:
make pr | opr
pr:
@pr `pwd`/cv.c
clean:
-rm -f *.o *.old cv

71
mach/m68k2/dl/cv.c Normal file
View File

@@ -0,0 +1,71 @@
static char rcsid[] = "$Header$";
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include <stdio.h>
#include <a.out.h>
/*
* NOTE: Beware that the a.out.h file included here should be the a.out.h
* file of the TARGET machine, not of the SOURCE machine.
*/
struct bhdr s_exec;
main(argc,argv) char **argv; {
unsigned short losh,hish;
long addr,maxaddr;
short count;
maxaddr=0;
if (argc != 3) {
fprintf(stderr,"Usage: %s VU-a.out Bleasdale-a.out\n",argv[0]);
exit(-1);
}
if (freopen(argv[1],"r",stdin)==NULL) {
perror(argv[1]);
exit(-1);
}
if (freopen(argv[2],"w",stdout)==NULL) {
perror(argv[2]);
exit(-1);
}
while (fread(&hish,sizeof(short),1,stdin)==1) {
if (fread(&losh,sizeof(short),1,stdin)!=1)
exit(fprintf(stderr,"foo\n"));
addr=losh+(((long)hish)*65536L);
addr -= 0x20000; /* entry point is 0x20000 on Bleasdale */
if (fread(&count,sizeof(short),1,stdin)!=1)
exit(fprintf(stderr,"bar\n"));
fseek(stdout,addr+sizeof(s_exec),0);
while (count--) {
putchar(getchar());
addr++;
}
if (addr>maxaddr)
maxaddr = addr;
}
s_exec.fmagic = FMAGIC;
s_exec.dsize = maxaddr;
s_exec.entry = 0x20000;
fseek(stdout,0L,0);
fwrite(&s_exec,sizeof(s_exec),1,stdout);
chmod(argv[2],0755);
return 0;
}

106
mach/m68k2/dl/dl.c Normal file
View File

@@ -0,0 +1,106 @@
static char rcsid[] = "$Header$";
#define MAXBYTE 24
#include <stdio.h>
char hex[] = "0123456789ABCDEF";
FILE *fp, *fopen();
char **s;
int bytes, bytcnt, checksum;
long pc;
main (argc,argv)
int argc;
char *argv[];
{
if (argc != 2) fatal ("usage: %s filename\n",argv[0]);
if ((fp = fopen (*++argv,"r")) == NULL)
fatal ("can't open %s\n",*argv);
else {
s = argv;
convert ();
fclose (fp);
}
}
convert ()
{
int c;
do
{
pc = getword ();
pc = (pc << 16) | getword ();
bytes = getword ();
while (bytes != 0)
{
bytcnt = (bytes < MAXBYTE) ? bytes : MAXBYTE;
bytes -= bytcnt;
checksum = 0;
if (pc > 0xffffL) S2record (); else S1record ();
}
c = getc (fp);
ungetc (c, fp);
}
while (c != EOF);
printf ("S9030000FC\n");
}
S2record ()
{
printf ("S2");
bytcnt += 4;
outbyte (bytcnt);
outbyte (pc);
record ();
}
S1record ()
{
printf ("S1");
bytcnt += 3;
outbyte (bytcnt);
record ();
}
record ()
{
outbyte (pc << 8);
outbyte (pc << 16);
while (bytcnt != 0)
{
outbyte (getbyte ());
pc ++;
}
outbyte (~checksum);
putchar ('\n');
putchar (0);
putchar (0);
}
outbyte (b)
int b;
{
checksum = (checksum + b) & 0377;
putchar (hex[(b>>4) & 017]);
putchar (hex[b & 017]);
-- bytcnt;
}
getword ()
{
int c;
c = getbyte ();
return ((getbyte () << 8) | c );
}
getbyte ()
{
int c;
if ((c = getc (fp)) == EOF) fatal ("end of %s\n",*s);
return (c);
}
fatal (s,a)
{
printf (s,a);
exit (-1);
}

20
mach/m68k2/libbc/Makefile Normal file
View File

@@ -0,0 +1,20 @@
MAKEFILE=../../proto/libg/Makefile
MACHDEF="MACH=m68k2" "SUF=s"
BCDEF="PREF=bc" "SUB=" "SRC=lang/basic/lib"
install:
make -f $(MAKEFILE) $(BCDEF) $(MACHDEF) tailcp
cmp:
make -f $(MAKEFILE) $(BCDEF) $(MACHDEF) tail
-../../compare head_bc
-../../compare tail_bc
clean:
-rm -f *.old *.[ce$(SUF)] tail* head*
opr:
make pr | opr
pr:
@pr Makefile

2
mach/m68k2/libbc/compmodule Executable file
View File

@@ -0,0 +1,2 @@
${MACH?} -I../../../h ${MACHFL?} $1 1>&2
echo `basename $1 $2`.s

37
mach/m68k2/libcc/Makefile Normal file
View File

@@ -0,0 +1,37 @@
MAKEFILE=../../proto/libg/Makefile
MACHDEF="MACH=m68k2" "SUF=s"
STDIO="PREF=cc" "SUB=.1s" "SRC=lang/cem/libcc/stdio"
GEN="PREF=cc" "SUB=.2g" "SRC=lang/cem/libcc/gen"
MON="PREF=mon" "SRC=lang/cem/libcc/mon"
install: cpstdio cpgen
cpstdio:
make -f $(MAKEFILE) $(STDIO) $(MACHDEF) tailcp
cpgen:
make -f $(MAKEFILE) $(GEN) $(MACHDEF) cp
cpmon:
make -f $(MAKEFILE) $(MON) $(MACHDEF) tailcp
cmp: cmpstdio cmpgen cmpmon
cmpstdio:
make -f $(MAKEFILE) $(STDIO) $(MACHDEF) tail
-../../compare tail_cc.1s
cmpgen:
make -f $(MAKEFILE) $(GEN) $(MACHDEF) head
-../../compare head_cc
make -f $(MAKEFILE) $(GEN) $(MACHDEF) tail
-../../compare tail_cc.2g
cmpmon:
make -f $(MAKEFILE) $(MON) $(MACHDEF) tail
-../../compare tail_mon
clean:
-rm -f *.old *.[ce$(SUF)] tail* head*
opr:
make pr | opr
pr:
@pr Makefile

2
mach/m68k2/libcc/compmodule Executable file
View File

@@ -0,0 +1,2 @@
${MACH?} -I../../../h ${MACHFL?} $1 1>&2
echo `basename $1 $2`.s

34
mach/m68k2/libem/LIST Normal file
View File

@@ -0,0 +1,34 @@
libem_s.a
ara.s
cvf.s
cii.s
cmi.s
cmp.s
cmu.s
csa.s
csb.s
cuu.s
exg.s
inn.s
los.s
rck.s
ret.s
set.s
sts.s
nop.s
mon.s
dvi.s
dvu.s
mli.s
mlu.s
shp.s
sig.s
cms.s
gto.s
fat.s
trp.s
dia.s
printf.s
lxl.s
lxa.s
lpb.s

19
mach/m68k2/libem/Makefile Normal file
View File

@@ -0,0 +1,19 @@
install:
../../install head_em.s head_em
../../install libem_s.a tail_em.rt
../../install end.s end_em.s
cmp:
-../../compare head_em.s head_em
-../../compare libem_s.a tail_em.rt
-../../compare end.s end_em.s
clean :
opr :
make pr | opr
pr:
@pr `pwd`/head_em.s
@arch pv libem_s.a | pr -h `pwd`/libem_s.a
@pr `pwd`/end.s

5
mach/m68k2/libem/READ_ME Normal file
View File

@@ -0,0 +1,5 @@
The original EM library routines saved all registers
(including scratch registers) in global data; hence they
were not reentrant.
The new routines do not save registers d0,d1,d2,a0 and a1.
They are reentrant.

83
mach/m68k2/libem/ara.s Normal file
View File

@@ -0,0 +1,83 @@
.define .sar
.define .lar
.define .aar
!register usage:
! a0 : descriptor address
! d0 : index
! a1 : base address
.text
.aar:
move.l (sp)+,d2 ! return address
move.l (sp)+,a0
move.w (sp)+,d0
move.l (sp)+,a1
sub (a0),d0 ! index - lower bound : relative index
!chk 2(a0),d0
!blt 9f
!cmp 2(a0),d0
!bgt 9f
mulu 4(a0),d0 ! total # bytes
add d0,a1 ! address of element
move.l a1,-(sp)
move.l d2,-(sp)
rts
.lar:
move.l (sp)+,d2 ! return address
move.l (sp)+,a0
move.w (sp)+,d0
move.l (sp)+,a1
sub (a0),d0
!chk 2(a0),d0
!blt 9f
!cmp 2(a0),d0
!bgt 9f
move 4(a0),d1
mulu d1,d0
add d0,a1
add d1,a1
asr #1,d1
bne 3f
clr d1
move.b -(a1),d1
move d1,-(sp)
bra 4f
3:
move -(a1),-(sp)
sub #1,d1
bgt 3b
4:
move.l d2,-(sp)
rts
!9:
!move.w #EARRAY,-(sp)
!jmp .fat
.sar:
move.l (sp)+,d2
move.l (sp)+,a0
move.w (sp)+,d0
move.l (sp)+,a1
sub (a0),d0
!chk 2(a0),d0
!blt 9b
!cmp 2(a0),d0
!bgt 9b
move 4(a0),d1
mulu d1,d0
add d0,a1
asr #1,d1
bne 3f
move (sp)+,d1
move.b d1,(a1)
bra 4f
3:
move (sp)+,(a1)+
sub #1,d1
bgt 3b
4:
move.l d2,-(sp)
rts

21
mach/m68k2/libem/cii.s Normal file
View File

@@ -0,0 +1,21 @@
.define .cii
.text
.cii:
move.l (sp)+,a0 ! return address
move (sp)+,d0 ! destination size
sub (sp)+,d0 ! destination - source size
bgt 1f
sub d0,sp ! pop extra bytes
bra 3f
1:
move (sp),d1
ext.l d1
swap d1
asr #1,d0
2:
move.w d1,-(sp)
sub #1,d0
bgt 2b
3:
jmp (a0)

18
mach/m68k2/libem/cmi.s Normal file
View File

@@ -0,0 +1,18 @@
.define .cmi, .cmi_
! NUM == 4
! result in d1
.text
.cmi:
.cmi_:
move.l (sp)+,a0
move.l #1,d1
move.l (sp)+,d0
cmp.l (sp)+,d0
bne 1f
clr d1
1:
ble 2f
neg d1
2:
jmp (a0)

15
mach/m68k2/libem/cmp.s Normal file
View File

@@ -0,0 +1,15 @@
.define .cmp
.text
.cmp:
move.l (sp)+,a0 ! return address
move.l #1,d1
move.l (sp)+,d0
cmp.l (sp)+,d0
bne 1f
clr d1
1:
bcs 2f
neg d1
2:
jmp (a0)

23
mach/m68k2/libem/cms.s Normal file
View File

@@ -0,0 +1,23 @@
.define .cms
! d0 contains set size
.text
.cms:
move.l (sp)+,d2 ! return address
move.l sp,a0
move.l sp,a1
add d0,a1
move.w d0,d1
asr #1,d0
1:
cmp (a0)+,(a1)+
bne 2f
sub #1,d0
bgt 1b
2:
asl #1,d1
add d1,sp
move.w d0,-(sp)
move.l d2,-(sp)
rts

27
mach/m68k2/libem/cmu.s Normal file
View File

@@ -0,0 +1,27 @@
.define .cmu
! d0 : # bytes of 1 block
.text
.cmu:
move.l (sp)+,d2 ! reta
move.l sp,a0 ! top block
move.l sp,a1
move.l d2,-(sp)
add d0,a1 ! lower block
move d0,d2
asr #1,d0
move.l #1,d1 ! greater
1:
cmp (a0)+,(a1)+
bne 2f
sub #1,d0
bgt 1b
clr d1 ! equal
2:
bcc 3f
neg d1 ! less
3:
move.l (sp)+,a0
asl #1,d2
add d2,sp ! new sp
jmp (a0)

4
mach/m68k2/libem/compmodule Executable file
View File

@@ -0,0 +1,4 @@
if m68k2 -c $1 1>&2
then echo `basename $1 $2`.s
else exit 1
fi

26
mach/m68k2/libem/csa.s Normal file
View File

@@ -0,0 +1,26 @@
.define .csa
.text
.csa:
move.l (sp)+,a0 ! case descriptor
move (sp)+,d0 ! index
move.l (a0)+,a1 ! default address
sub (a0)+,d0 ! index - lower bound
blt 1f
cmp (a0)+,d0 ! rel. index <-> upper - lower bound
bgt 1f
asl #2,d0
add d0,a0
move.l (a0),d1 ! test jump address
move.l d1,d0
beq 1f
move.l d1,a1
bra 3f
1:
move.l a1,d0 ! test default jump address
beq 2f
3:
jmp (a1)
2:
move.w #ECASE,-(sp)
jmp .fat

24
mach/m68k2/libem/csb.s Normal file
View File

@@ -0,0 +1,24 @@
.define .csb
.text
.csb:
move.l (sp)+,a0 ! case descriptor
move (sp)+,d0 ! index
move.l (a0)+,a1 ! default jump address
move.w (a0)+,d1 ! # entries
beq 2f
1:
cmp (a0)+,d0
beq 3f
tst.l (a0)+ ! skip jump address
sub #1,d1
bgt 1b
2:
move.l a1,d1 ! default jump address
bne 4f
move.w #ECASE,-(sp)
jmp .fat
3:
move.l (a0)+,a1 ! get jump address
4:
jmp (a1)

21
mach/m68k2/libem/cuu.s Normal file
View File

@@ -0,0 +1,21 @@
.define .ciu
.define .cui
.define .cuu
.text
.ciu:
.cui:
.cuu:
move.l (sp)+,a0 ! return address
move (sp)+,d0 ! destination size
sub (sp)+,d0
bgt 1f
sub d0,sp
jmp (a0)
1:
asr #1,d0
2:
clr -(sp)
sub #1,d0
bgt 2b
jmp (a0)

15
mach/m68k2/libem/cvf.s Normal file
View File

@@ -0,0 +1,15 @@
.define .cfi,.cif,.cfu,.cuf,.cff
.text
! this is a dummy float conversion routine
.cfi:
.cif:
.cfu:
.cuf:
.cff:
move.l (sp)+,a0 ! return address
move (sp)+,d0 ! destination size
sub (sp)+,d0 ! diff. in sizes
sub d0,sp
jmp (a0)

37
mach/m68k2/libem/dia.s Normal file
View File

@@ -0,0 +1,37 @@
.define .diagnos
space = 040
del = 0177
.text
.diagnos:
move.w hol0,-(sp)
move.l hol0+FILN_AD,d2
beq 1f
move.l d2,a0
move.l #40,d0
3:
move.b (a0)+,d1
beq 2f
cmp.b #del,d1
bge 1f
cmp.b #space,d1
blt 1f
sub #1,d0
bgt 3b
clr.b (a1)
2:
move.l d2,-(sp)
pea fmt
jsr _printf
add #10,sp
jmp _printf
1:
move.l #unknwn,d2
bra 2b
.data
fmt: .asciz "%s, line %d: "
unknwn: .asciz "unknown file"
.align 2

38
mach/m68k2/libem/dvi.s Normal file
View File

@@ -0,0 +1,38 @@
.define .dvi
! signed long divide
.text
.dvi:
move.l (sp)+,a0 ! return address
move.l (sp)+,d0
move.l (sp)+,d1
move.l d3,-(sp) ! save d3 and d4
move.l d4,-(sp)
clr.l d4
tst.l d0 ! divisor
bpl 1f
neg.l d0
not d4
1:
tst.l d1 ! dividend
bpl 2f
neg.l d1
not d4
swap d4
not d4
swap d4
2:
move.l d1,-(sp)
move.l d0,-(sp)
jsr .dvu
tst d4
beq 5f
neg.l d1 ! quotient
5:
tst.l d4
bpl 6f
neg.l d2 ! remainder
6:
move.l (sp)+,d4 ! restore d4 and d3
move.l (sp)+,d3
jmp (a0)

34
mach/m68k2/libem/dvu.s Normal file
View File

@@ -0,0 +1,34 @@
.define .dvu
! unsigned long divide
! register usage:
! : d0 divisor
! d1 dividend
! exit : d1 quotient
! d2 remainder
.text
.dvu:
move.l (sp)+,a1 ! return address
move.l (sp)+,d0
move.l (sp)+,d1
move.l d3,-(sp) ! save d3
tst.l d0
bne 0f
move.l (sp)+,d3
move.w #EIDIVZ,-(sp)
jsr .trp
0:
clr.l d2
move.l #32,d3
3:
lsl.l #1,d1
roxl.l #1,d2
cmp.l d0,d2
blt 4f
sub.l d0,d2
add #1,d1
4:
sub #1,d3
bgt 3b
move.l (sp)+,d3
jmp (a1)

14
mach/m68k2/libem/end.s Normal file
View File

@@ -0,0 +1,14 @@
.define endtext,enddata,endbss,_etext,_edata,_end
.text
.align 2
endtext:
_etext:
.data
.align 2
enddata:
_edata:
.bss
.align 2
endbss:
_end:

23
mach/m68k2/libem/exg.s Normal file
View File

@@ -0,0 +1,23 @@
.define .exg
! d0 : exchange size in bytes
.text
.exg:
move.l (sp)+,d2 ! return address
move.l sp,a1
sub.w d0,sp
move.l sp,a0
move.w d0,d1
1:
move.w (a1)+,(a0)+
sub #1,d0
bgt 1b
move.l sp,a1
asr #1,d1
1:
move.w (a1)+,(a0)+
sub #1,d1
bgt 1b
move.l a1,sp
move.l d2,-(sp)
rts

6
mach/m68k2/libem/fat.s Normal file
View File

@@ -0,0 +1,6 @@
.define .fat
.text
.fat:
jsr .trp
jmp EXIT

75
mach/m68k2/libem/gto.s Normal file
View File

@@ -0,0 +1,75 @@
.define .gto
.extern .gto
.gto:
! nonlocal goto
! the argument on the stack is a pointer to a GTO-descriptor containing:
! - the new local base
! - the new stackpointer
! - the new program counter
!
! The main task of the GTO instruction is to restore the registers
! used for local variables. It uses a word stored in each stackframe,
! indicating how many data -and address registers the procedure of
! that stackframe has.
move.l (sp)+,a0
add.l #8,a0 ! a0 now points to new local base entry
! of the descriptor
cmp.l (a0),a6 ! GTO within same procedure?
beq noregs
move.l d0,savd0 ! gto may not destroy the return area
move.l d1,savd1
1:
tst.l (a6)
beq err
unlk a6
move.w (sp)+,d0 ! word indicating which regs. were saved
jsr restr
cmp.l (a0),a6
bne 1b
move.l savd0,d0
move.l savd1,d1
noregs:
move.l -4(a0),sp
move.l -8(a0),a0 ! new program counter
jmp (a0)
err:
move.w #EBADGTO,-(sp)
jmp .fat
restr:
! restore the registers. Note that scratch register a0 may
! not be changed here. d0 contains (8*#addr.regs + #data regs.)
! note that registers are assigned in the order d7,d6 .. and
! a5,a4...
move.l (sp)+,d2 ! return address; can't use a0 here
move.w d0,d1
and.l #7,d0 ! #data registers
asl.l #1,d0 ! * 2
lea etabd,a1
sub.l d0,a1
jmp (a1)
move.l (sp)+,d3
move.l (sp)+,d4
move.l (sp)+,d5
move.l (sp)+,d6
move.l (sp)+,d7
etabd:
and.l #070,d1
asr.l #2,d1 ! # address registers
lea etaba,a1
sub.l d1,a1
jmp (a1)
move.l (sp)+,a2
move.l (sp)+,a3
move.l (sp)+,a4
move.l (sp)+,a5
etaba:
move.l d2,a1
jmp (a1) ! return
.data
savd0: .long 0
savd1: .long 0
.text

29
mach/m68k2/libem/inn.s Normal file
View File

@@ -0,0 +1,29 @@
.define .inn
! d0 : set size in bytes
! d1 : bitnumber
.text
.inn:
move.l (sp)+,d2 ! return address
move.w (sp)+,d1
move.l sp,a1
add d0,a1
move.l sp,a0
move.l d2,-(sp)
move d1,d2
asr #3,d2
bchg #0,d2
cmp d0,d2
bcc 1f
add d2,a0
btst d1,(a0)
beq 1f
move.l #1,d0
bra 2f
1:
clr d0
2:
move.l (sp)+,a0
move.l a1,sp
jmp (a0)

24
mach/m68k2/libem/los.s Normal file
View File

@@ -0,0 +1,24 @@
.define .los
! d0 : # bytes
! a0 : source address
.text
.los:
move.l (sp)+,a1
move.w (sp)+,d0
move.l (sp)+,a0
cmp #1,d0
bne 1f
clr d0
move.b (a0),d0
move.w d0,-(sp)
bra 3f
1:
add d0,a0
asr #1,d0
2:
move -(a0),-(sp)
sub #1,d0
bgt 2b
3:
jmp (a1)

18
mach/m68k2/libem/lpb.s Normal file
View File

@@ -0,0 +1,18 @@
.define .lpb
.extern .lpb
.lpb:
! convert local to argument base
! should not destroy register d2 (used by lxa/lxl)
move.l (sp)+,a1 ! return address
move.l (sp)+,a0 ! local base
move.w 4(a0),d0 ! register save word
move.w d0,d1
and.l #7,d0 ! #data registers
and.l #070,d1
asr.l #3,d1 ! #address registers
add.w d1,d0
asl.l #2,d0 ! 4 * #registers
add.w #10,d0 ! reg. save word, lb, pc
add.l d0,a0
jmp (a1)

18
mach/m68k2/libem/lxa.s Normal file
View File

@@ -0,0 +1,18 @@
.define .lxa
.extern .lxa
.lxa:
! #levels (>= 0) on stack
move.l (sp)+,a0 ! return address
move.w (sp)+,d2
move.l a0,-(sp)
move.l a6,a0
1:
move.l a0,-(sp)
jsr .lpb
sub #1,d2
blt 2f
move.l (a0),a0
bra 1b
2:
rts

16
mach/m68k2/libem/lxl.s Normal file
View File

@@ -0,0 +1,16 @@
.define .lxl
.extern .lxl
.lxl:
! #levels on stack (> 0)
move.l (sp)+,a0 ! return address
move.w (sp)+,d2 ! d2 is not destroyed by .lpb
move.l a0,-(sp)
sub.w #1,d2
move.l a6,a0
1:
move.l a0,-(sp)
jsr .lpb
move.l (a0),a0
dbf d2,1b
rts ! result in a0

30
mach/m68k2/libem/mli.s Normal file
View File

@@ -0,0 +1,30 @@
.define .mli
.text
.mli:
move.l (sp)+,a0
move.l (sp)+,d1
move.l (sp)+,d0
move.l d5,-(sp)
clr d5
tst.l d0
bpl 1f
neg.l d0
not d5
1:
tst.l d1
bpl 2f
neg.l d1
not d5
2:
move.l d0,-(sp)
move.l d1,-(sp)
jsr .mlu
tst d5
beq 3f
neg.l d1
negx.l d0
3:
move.l (sp)+,d5
jmp (a0)

37
mach/m68k2/libem/mlu.s Normal file
View File

@@ -0,0 +1,37 @@
.define .mlu
! entry : d0 multiplicand
! d1 multiplier
! exit : d0 high order result
! d1 low order result
.text
.mlu:
move.l (sp)+,a1
move.l (sp)+,d1
move.l (sp)+,d0
movem.l d3/d4/d6,-(sp)
move.l d1,d3
move.l d1,d2
swap d2
move.l d2,d4
mulu d0,d1
mulu d0,d2
swap d0
mulu d0,d3
mulu d4,d0
clr.l d6
swap d1
add d2,d1
addx.l d6,d0
add d3,d1
addx.l d6,d0
swap d1
clr d2
clr d3
swap d2
swap d3
add.l d2,d0
add.l d3,d0
movem.l (sp)+,d3/d4/d6
jmp (a1)

12
mach/m68k2/libem/mon.s Normal file
View File

@@ -0,0 +1,12 @@
.define .mon
.text
.mon:
move.l (sp)+,a0
pea fmt
jsr .diagnos
add #6,sp
jmp EXIT
.data
fmt: .asciz "system call %d not implemented"
.align 2

13
mach/m68k2/libem/nop.s Normal file
View File

@@ -0,0 +1,13 @@
.define .nop
.text
.nop:
move.w hol0,-(sp)
pea fmt
jsr .diagnos
add #6,sp
rts
.data
fmt: .asciz "test %d\n"
.align 2

185
mach/m68k2/libem/printf.s Normal file
View File

@@ -0,0 +1,185 @@
.define _printn
.define _printf
.text
_putchar:
move.w #1,-(sp)
pea 7(sp)
move.w #1,-(sp)
jsr _write
add.l #8,sp
rts
_printf:
link a6,#-12
.data
_12:
.short 28786
.short 26990
.short 29798
.short 11875
.short 0
.text
pea 8+4(a6)
move.l (sp)+,-6(a6)
I004:
move.l 8+0(a6),-(sp)
move.l (sp),-(sp)
move.l (sp)+,a0
add #1,a0
move.l a0,-(sp)
move.l (sp)+,8+0(a6)
move.l (sp)+,a0
clr d0
move.b (a0),d0
move.w d0,-(sp)
move.w (sp),-(sp)
move.w (sp)+,-2(a6)
move.w #37,-(sp)
move.w (sp)+,d0
cmp (sp)+,d0
beq I005
move.w -2(a6),-(sp)
tst (sp)+
beq I002
move.w -2(a6),-(sp)
jsr _putchar
add #2,sp
jmp I004
I005:
move.l 8+0(a6),-(sp)
move.l (sp),-(sp)
move.l (sp)+,a0
add #1,a0
move.l a0,-(sp)
move.l (sp)+,8+0(a6)
move.l (sp)+,a0
clr d0
move.b (a0),d0
move.w d0,-(sp)
move.w (sp)+,-2(a6)
move.w -2(a6),-(sp)
move.w #100,-(sp)
move.w (sp)+,d0
cmp (sp)+,d0
beq I008
move.w -2(a6),-(sp)
move.w #117,-(sp)
move.w (sp)+,d0
cmp (sp)+,d0
bne I007
I008:
move.l -6(a6),-(sp)
move.l (sp)+,a0
add #2,a0
move.l a0,-(sp)
move.l (sp),-(sp)
move.l (sp)+,-6(a6)
move.l (sp)+,a0
move.w -2(a0),-(sp)
move.w (sp)+,-8(a6)
move.w -2(a6),-(sp)
move.w #100,-(sp)
move.w (sp)+,d0
cmp (sp)+,d0
bne I009
move.w -8(a6),-(sp)
tst (sp)+
bge I009
move.w #0,-(sp)
move.w -8(a6),-(sp)
move.w (sp)+,d0
move.w (sp)+,d1
sub d0,d1
move.w d1,-(sp)
move.w (sp)+,-8(a6)
move.w #45,-(sp)
jsr _putchar
add #2,sp
I009:
move.w -8(a6),-(sp)
jsr _printn
add #2,sp
jmp I004
I007:
move.w -2(a6),-(sp)
move.w #115,-(sp)
move.w (sp)+,d0
cmp (sp)+,d0
bne I004
move.l -6(a6),-(sp)
move.l (sp)+,a0
add #4,a0
move.l a0,-(sp)
move.l (sp),-(sp)
move.l (sp)+,-6(a6)
move.l (sp)+,a0
move.l -4(a0),-(sp)
move.l (sp)+,-12(a6)
I00c:
move.l -12(a6),-(sp)
move.l (sp),-(sp)
move.l (sp)+,a0
add #1,a0
move.l a0,-(sp)
move.l (sp)+,-12(a6)
move.l (sp)+,a0
clr d0
move.b (a0),d0
move.w d0,-(sp)
move.w (sp),-(sp)
move.w (sp)+,-2(a6)
tst (sp)+
beq I004
move.w -2(a6),-(sp)
jsr _putchar
add #2,sp
jmp I00c
I002:
unlk a6
rts
_printn:
link a6,#-2
.data
_15:
.short 12337
.short 12851
.short 13365
.short 13879
.short 14393
.short 0
.text
move.w 8+0(a6),-(sp)
move.w #10,-(sp)
move.w (sp)+,d0
clr.l d1
move.w (sp)+,d1
divu d0,d1
move.w d1,-(sp)
move.w (sp),-(sp)
move.w (sp)+,-2(a6)
tst (sp)+
beq I013
move.w -2(a6),-(sp)
jsr _printn
add #2,sp
I013:
pea _15
move.w 8+0(a6),-(sp)
move.w #10,-(sp)
move.w (sp)+,d0
clr.l d1
move.w (sp)+,d1
divu d0,d1
swap d1
move.w d1,-(sp)
move.w (sp)+,d0
ext.l d0
add.l (sp)+,d0
move.l d0,-(sp)
move.l (sp)+,a0
clr d0
move.b (a0),d0
move.w d0,-(sp)
jsr _putchar
add #2,sp
unlk a6
rts

16
mach/m68k2/libem/rck.s Normal file
View File

@@ -0,0 +1,16 @@
.define .rck
.text
.rck:
move.l (sp)+,a1
move.l (sp)+,a0 ! descriptor address
move.w (sp),d0
cmp (a0),d0
blt 1f
cmp 2(a0),d0
ble 2f
1:
move.w #ERANGE,-(sp)
jsr .trp
2:
jmp (a1)

25
mach/m68k2/libem/ret.s Normal file
View File

@@ -0,0 +1,25 @@
.define .ret
.text
.ret:
beq 3f
cmp #2,d0
bne 1f
move (sp)+,d0
bra 3f
1:
cmp #4,d0
bne 2f
move.l (sp)+,d0
bra 3f
2:
cmp #8,d0
bne 4f
move.l (sp)+,d0
move.l (sp)+,d1
3:
unlk a6
rts
4:
move.w #EILLINS,-(sp)
jmp .fat

27
mach/m68k2/libem/set.s Normal file
View File

@@ -0,0 +1,27 @@
.define .set
! d0 : setsize in bytes
! d1 : bitnumber
.text
.set:
move.l (sp)+,a0
move.w (sp)+,d1
move.w d0,d2
asr #1,d2
1:
clr -(sp)
sub #1,d2
bgt 1b
move.l sp,a1 ! set base
move.w d1,d2
asr #3,d2
bchg #0,d2
cmp d0,d2
bcs 1f
move.w #ESET,-(sp)
move.l a0,-(sp)
jmp .trp
1:
add d2,a1
bset d1,(a1)
jmp (a0)

24
mach/m68k2/libem/shp.s Normal file
View File

@@ -0,0 +1,24 @@
.define .strhp
.text
.strhp:
move.l (sp)+,a0
move.l (sp)+,d0 ! heap pointer
move.l d0,.reghp
cmp.l .limhp,d0
bmi 1f
add.l #0x400,d0
and.l #~0x3ff,d0
move.l d0,.limhp
move.l a0,-(sp)
move.l d0,-(sp)
jsr _brk
tst.l (sp)+
move.l (sp)+,a0
tst.w d0
bne 2f
1:
jmp (a0)
2:
move.w #EHEAP,-(sp)
jmp .fat

9
mach/m68k2/libem/sig.s Normal file
View File

@@ -0,0 +1,9 @@
.define .sig
.text
.sig:
move.l (sp)+,a0
move.l (sp)+,a1 ! trap pc
move.l .trppc,-(sp)
move.l a1,.trppc
jmp (a0)

22
mach/m68k2/libem/sts.s Normal file
View File

@@ -0,0 +1,22 @@
.define .sts
! d0 : # bytes
! a0 : destination address
.text
.sts:
move.l (sp)+,a1
move.w (sp)+,d0
move.l (sp)+,a0
cmp #1,d0
bne 1f
move.w (sp)+,d0
move.b d0,(a0)
bra 3f
1:
asr #1,d0
2:
move.w (sp)+,(a0)+
sub #1,d0
bgt 2b
3:
jmp (a1)

36
mach/m68k2/libem/trp.s Normal file
View File

@@ -0,0 +1,36 @@
.define .trp
.text
.trp:
move.l (sp)+,a1 ! return address
move.w (sp)+,d0 ! error number
move.l a1,-(sp)
move.w d0,-(sp)
cmp #16,d0
bcc 1f
cmp #8,d0
bcc 4f
btst d0,.trpim
bra 5f
4:
btst d0,.trpim+1
5:
bne 3f
1:
move.l .trppc,a0
move.l a0,d0
beq 9f
clr.l .trppc
jsr (a0)
3:
add #2,sp
rts
9:
pea fmt
jsr .diagnos
jmp EXIT
.data
.rettrp: .long 0
fmt: .asciz "trap %d called\n"
.align 2

20
mach/m68k2/libpc/Makefile Normal file
View File

@@ -0,0 +1,20 @@
MAKEFILE=../../proto/libg/Makefile
MACHDEF="MACH=m68k2" "SUF=s"
PCDEF="PREF=pc" "SUB=" "SRC=lang/pc/libpc"
install:
make -f $(MAKEFILE) $(PCDEF) $(MACHDEF) cp
cmp:
make -f $(MAKEFILE) $(PCDEF) $(MACHDEF) all
-../../compare head_pc
-../../compare tail_pc
clean:
-rm -f *.old *.[ce$(SUF)] tail* head*
opr:
make pr | opr
pr:
@pr Makefile

2
mach/m68k2/libpc/compmodule Executable file
View File

@@ -0,0 +1,2 @@
${MACH?} -I../../../h ${MACHFL?} $1 1>&2
echo `basename $1 $2`.s

45
mach/m68k2/libsys/LIST Normal file
View File

@@ -0,0 +1,45 @@
tail_mon.a
exit.s
_exit.s
access.s
alarm.s
chdir.s
chmod.s
chroot.s
close.s
creat.s
execl.s
execve.s
fork.s
getegid.s
getgid.s
getpid.s
getuid.s
stty.s
gtty.s
ioctl.s
kill.s
link.s
lseek.s
mknod.s
mount.s
nice.s
open.s
pause.s
read.s
setgid.s
setuid.s
stat.s
stime.s
sync.s
time.s
times.s
umount.s
unlink.s
write.s
brk.s
wait.s
fstat.s
signal.s
call.s
cleanup.s

View File

@@ -0,0 +1,11 @@
# $Header$
install:
../../install tail_mon.a tail_mon
clean :
opr :
make pr | opr
pr:
@ar pv tail_mon.a

View File

@@ -0,0 +1,6 @@
.define __exit
.extern __exit
.text
__exit: move.w #0x1,d0
move.w 4(sp),a0
trap #0

View File

@@ -0,0 +1,8 @@
.define _access
.extern _access
.text
_access: move.w #0x21,d0
move.l 4(sp),a0
move.w 8(sp),d1
ext.l d1
jmp callc

View File

@@ -0,0 +1,9 @@
.define _alarm
.extern _alarm
.text
_alarm: clr.l d0
move.w 4(sp),d0
move.l d0,a0
move.w #0x1B,d0
trap #0
rts

26
mach/m68k2/libsys/brk.s Normal file
View File

@@ -0,0 +1,26 @@
.define _brk
.define _sbrk
.extern _brk
.extern _sbrk
.text
_sbrk: move.l nd,a0
add.w 4(sp),a0
move.w #0x11,d0
trap #0
bcs lcerror
move.l nd,d0
move.l d0,a0
add.w 4(sp),a0
move.l a0,nd
rts
lcerror: jmp cerror
_brk: move.w #0x11,d0
move.l 4(sp),a0
trap #0
bcs lcerror
move.l 4(sp),nd
clr.l d0
rts
.data
nd: .long endbss
.text

28
mach/m68k2/libsys/call.s Normal file
View File

@@ -0,0 +1,28 @@
.define call
.define callc
.define calle
.define cerror
.define _errno
.extern call
.extern callc
.extern calle
.extern cerror
.extern _errno
.text
call: trap #0
bcs cerror
rts
callc:
trap #0
bcs cerror
clr.l d0
rts
calle:
trap #0
cerror:
move.w d0,_errno
move.l #-1,d0
rts
.bss
_errno: .space 4
.text

View File

@@ -0,0 +1,6 @@
.define _chdir
.extern _chdir
.text
_chdir: move.w #0xC,d0
move.l 4(sp),a0
jmp callc

View File

@@ -0,0 +1,8 @@
.define _chmod
.extern _chmod
.text
_chmod: move.w #0xF,d0
move.l 4(sp),a0
move.w 8(sp),d1
ext.l d1
jmp callc

View File

@@ -0,0 +1,6 @@
.define _chroot
.extern _chroot
.text
_chroot: move.w #0x3D,d0
move.l 4(sp),a0
jmp callc

View File

@@ -0,0 +1,8 @@
.define __cleanup
.extern __cleanup
.text
__cleanup:
tst.b -40(sp)
link a6,#-0
unlk a6
rts

View File

@@ -0,0 +1,6 @@
.define _close
.extern _close
.text
_close: move.w #0x6,d0
move.w 4(sp),a0
jmp callc

View File

@@ -0,0 +1,8 @@
.define _creat
.extern _creat
.text
_creat: move.w #0x8,d0
move.l 4(sp),a0
move.w 8(sp),d1
ext.l d1
jmp call

11
mach/m68k2/libsys/execl.s Normal file
View File

@@ -0,0 +1,11 @@
.define _execl
.extern _execl
_execl: link a6,#0
tst.b -132(sp)
move.l _environ,-(sp)
pea 12(sp)
move.l 8(a6),-(sp)
jsr _execve
add.l #0xC,sp
unlk a6
rts

View File

@@ -0,0 +1,8 @@
.define _execve
.extern _execve
.text
_execve: move.w #0x3B,d0
move.l 4(sp),a0
move.l 8(sp),d1
move.l 12(sp),a1
jmp calle

12
mach/m68k2/libsys/exit.s Normal file
View File

@@ -0,0 +1,12 @@
.define _exit
.extern _exit
.text
_exit:
tst.b -40(sp)
link a6,#-0
jsr __cleanup
move.w 8(a6),-(sp)
jsr __exit
add.l #2,sp
unlk a6
rts

13
mach/m68k2/libsys/fork.s Normal file
View File

@@ -0,0 +1,13 @@
.define _fork
.extern _fork
.text
_fork: move.w #0x2,d0
trap #0
bra 1f
bcc 2f
jmp cerror
1:
!move.l d0,p_uid
clr.l d0
2:
rts

View File

@@ -0,0 +1,6 @@
.define _fstat
.extern _fstat
_fstat: move.w #0x1C,d0
move.w 4(sp),a0
move.l 6(sp),d1
jmp callc

View File

@@ -0,0 +1,7 @@
.define _getegid
.extern _getegid
.text
_getegid: move.w #0x2F,d0
trap #0
move.l d1,d0
rts

View File

@@ -0,0 +1,6 @@
.define _getgid
.extern _getgid
.text
_getgid: move.w #0x2F,d0
trap #0
rts

View File

@@ -0,0 +1,6 @@
.define _getpid
.extern _getpid
.text
_getpid: move.w #0x14,d0
trap #0
rts

View File

@@ -0,0 +1,6 @@
.define _getuid
.extern _getuid
.text
_getuid: move.w #0x18,d0
trap #0
rts

13
mach/m68k2/libsys/gtty.s Normal file
View File

@@ -0,0 +1,13 @@
.define _gtty
.extern _gtty
.text
_gtty:
tst.b -40(sp)
link a6,#-0
move.l 10(a6),-(sp)
move.w #29704,-(sp)
move.w 8(a6),-(sp)
jsr _ioctl
add.l #8,sp
unlk a6
rts

View File

@@ -0,0 +1,86 @@
.define CERASE,CKILL,CSTOP,CSTART
.define .lino,.filn
.define F_DUM,EXIT
.define begtext,begdata,begbss
.define EARRAY,ERANGE,ESET,EIDIVZ,EHEAP,EILLINS,ECASE,EBADGTO
.define hol0,.reghp,.limhp,.trpim,.trppc
.define LINO_AD,FILN_AD
! EM runtime start-off for the Bleasdale 68000 system
CERASE = 010
CKILL = 030
CSTART = 021
CSTOP = 023
F_DUM = 0
LINO_AD = 0
FILN_AD = 4
EARRAY = 0
ERANGE = 1
ESET = 2
EIDIVZ = 6
EHEAP = 17
EILLINS = 18
ECASE = 20
EBADGTO = 27
.base 0x20000
.text
begtext:
! Bleasdale puts the argument and environment vectors
! themselves on top of the stack, instead of POINTERS
! to these vectors. We get things right here.
move.l 4(sp),a0
clr.l -4(a0)
move.l sp,a0
sub.l #8,sp
move.l (a0),(sp)
add.l #4,a0
move.l a0,4(sp)
1:
tst.l (a0)+
bne 1b
move.l 4(sp),a1
cmp.l (a1),a0
blt 2f
sub.l #4,a0
2:
move.l a0,8(sp)
! Now the stack contains an argc (4 bytes), argv-pointer and
! envp pointer.
add.l #2,sp !convert argc from 4-byte to 2-byte
pea endbss
jsr _brk
add.l #4,sp
jsr _m_a_i_n
add #010,sp
EXIT:
jsr __exit
.data
begdata:
hol0:
.lino:
.short 0,0 ! lino
.filn:
.long 0 ! filn
.reghp:
.long endbss
.limhp:
.long endbss
.trppc:
.long 0
.trpim:
.short 0
.bss
begbss:

View File

@@ -0,0 +1,9 @@
.define _ioctl
.extern _ioctl
.text
_ioctl: move.w #0x36,d0
move.w 4(sp),a0
move.w 6(sp),d1
ext.l d1
move.l 8(sp),a1
jmp callc

8
mach/m68k2/libsys/kill.s Normal file
View File

@@ -0,0 +1,8 @@
.define _kill
.extern _kill
.text
_kill: move.w #0x25,d0
move.w 4(sp),a0
move.w 6(sp),d1
ext.l d1
jmp callc

8
mach/m68k2/libsys/link.s Normal file
View File

@@ -0,0 +1,8 @@
.define _link
.extern _link
.text
_link: move.w #0x9,d0
move.l 4(sp),a0
move.w 8(sp),d1
ext.l d1
jmp callc

View File

@@ -0,0 +1,8 @@
.define _lseek
.extern _lseek
.text
_lseek: move.w #0x13,d0
move.w 4(sp),a0
move.l 6(sp),d1
move.w 10(sp),a1
jmp call

View File

@@ -0,0 +1,9 @@
.define _mknod
.extern _mknod
.text
_mknod: move.w #0xE,d0
move.l 4(sp),a0
move.w 8(sp),d1
ext.l d1
move.w 10(sp),a1
jmp callc

View File

@@ -0,0 +1,9 @@
.define _mount
.extern _mount
.text
_mount: move.w #0x15,d0
move.l 4(sp),a0
move.l 8(sp),d1
move.l 12(sp),a1
jmp callc

6
mach/m68k2/libsys/nice.s Normal file
View File

@@ -0,0 +1,6 @@
.define _nice
.extern _nice
.text
_nice: move.w #0x22,d0
move.w 4(sp),a0
jmp callc

8
mach/m68k2/libsys/open.s Normal file
View File

@@ -0,0 +1,8 @@
.define _open
.extern _open
.text
_open: move.w #0x5,d0
move.l 4(sp),a0
move.w 8(sp),d1
ext.l d1
jmp call

View File

@@ -0,0 +1,6 @@
.define _pause
.extern _pause
.text
_pause: move.w #0x1D,d0
trap #0
rts

8
mach/m68k2/libsys/read.s Normal file
View File

@@ -0,0 +1,8 @@
.define _read
.extern _read
.text
_read: move.w #0x3,d0
move.w 4(sp),a0
move.l 6(sp),d1
move.w 10(sp),a1
jmp call

View File

@@ -0,0 +1,6 @@
.define _setgid
.extern _setgid
.text
_setgid: move.w #0x2E,d0
move.w 4(sp),a0
jmp callc

View File

@@ -0,0 +1,6 @@
.define _setuid
.extern _setuid
.text
_setuid: move.w #0x17,d0
move.w 4(sp),a0
jmp callc

View File

@@ -0,0 +1,49 @@
.define _signal
.extern _signal
NSIG=32
_signal:
move.w 4(sp), d0
ext.l d0
cmp.l #NSIG,d0
bcc 1f
move.l 6(sp),d1
move.l d0,a0
add.l a0,a0
add.l a0,a0
add.l #dvect,a0
move.l (a0),a1
move.l d1,(a0)
beq 2f
btst #0,d1
bne 2f
move.l #enter,d1
2:
move.l d0,a0
move.w #0x30,d0
trap #0
bcs 3f
btst #0,d0
bne 4f
move.l a1,d0
4:
rts
1:
move.l #22,d0
3:
jmp cerror
enter:
movem.l d0/d1/a0/a1,-(sp)
move.l 16(sp),a0
move.l a0,-(sp)
add.l a0,a0
add.l a0,a0
add.l #dvect,a0
move.l (a0),a0
jsr (a0)
add.l #4,sp
movem.l (sp)+,d0/d1/a0/a1
add.l #4,sp
rtr
.bss
dvect: .space 4*NSIG

8
mach/m68k2/libsys/stat.s Normal file
View File

@@ -0,0 +1,8 @@
.define _stat
.extern _stat
.text
_stat: move.w #0x12,d0
move.l 4(sp),a0
move.w 8(sp),d1
ext.l d1
jmp callc

11
mach/m68k2/libsys/stime.s Normal file
View File

@@ -0,0 +1,11 @@
.define _stime
.extern _stime
.text
_stime: move.w #0x19,d0
move.l 4(sp),a0
move.l (a0),a0
trap #0
bcs 1f
rts
1:
jmp cerror

13
mach/m68k2/libsys/stty.s Normal file
View File

@@ -0,0 +1,13 @@
.define _stty
.extern _stty
.text
_stty:
tst.b -40(sp)
link a6,#-0
move.l 10(a6),-(sp)
move.w #29705,-(sp)
move.w 8(a6),-(sp)
jsr _ioctl
add.l #8,sp
unlk a6
rts

6
mach/m68k2/libsys/sync.s Normal file
View File

@@ -0,0 +1,6 @@
.define _sync
.extern _sync
.text
_sync: move.w #0x24,d0
trap #0
rts

11
mach/m68k2/libsys/time.s Normal file
View File

@@ -0,0 +1,11 @@
.define _time
.extern _time
.text
_time: move.w #0xD,d0
trap #0
tst.l 4(sp)
beq 1f
move.l 4(sp),a0
move.l d0,(a0)
1:
rts

View File

@@ -0,0 +1,7 @@
.define _times
.extern _times
.text
_times: move.w #0x2B,d0
move.w 4(sp),a0
trap #0
rts

View File

@@ -0,0 +1,6 @@
.define _umount
.extern _umount
.text
_umount: move.w #0x16,d0
move.l 4(sp),a0
jmp callc

View File

@@ -0,0 +1,6 @@
.define _unlink
.extern _unlink
.text
_unlink: move.w #0xA,d0
move.l 4(sp),a0
jmp callc

12
mach/m68k2/libsys/wait.s Normal file
View File

@@ -0,0 +1,12 @@
.define _wait
.extern _wait
_wait: move.w #0x7,d0
move.l 4(sp),a0
trap #0
bcs cerror
tst.l 4(sp)
beq 1f
move.l 4(sp),a0
move.w d1,(a0)
1:
rts

View File

@@ -0,0 +1,8 @@
.define _write
.extern _write
.text
_write: move.w #0x4,d0
move.w 4(sp),a0
move.l 6(sp),d1
move.w 10(sp),a1
jmp call

178
mach/m68k2/ncg/Makefile Normal file
View File

@@ -0,0 +1,178 @@
# $Header$
PREFLAGS=-I../../../h -I.
PFLAGS=
CFLAGS=$(PREFLAGS) $(PFLAGS)
LDFLAGS=-i $(PFLAGS)
LINTOPTS=-hbxac
LIBS=../../../lib/em_data.a
CDIR=../../proto/ncg
CGG=../../../lib/ncgg
CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \
$(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \
$(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \
$(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c
OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\
move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o
all:
make tables.c
make cg
cg: tables.o $(OFILES)
cc $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg
tables.o: tables.c
cc -c $(PREFLAGS) -I$(CDIR) tables.c
codegen.o: $(CDIR)/codegen.c
cc -c $(CFLAGS) $(CDIR)/codegen.c
compute.o: $(CDIR)/compute.c
cc -c $(CFLAGS) $(CDIR)/compute.c
equiv.o: $(CDIR)/equiv.c
cc -c $(CFLAGS) $(CDIR)/equiv.c
fillem.o: $(CDIR)/fillem.c
cc -c $(CFLAGS) $(CDIR)/fillem.c
gencode.o: $(CDIR)/gencode.c
cc -c $(CFLAGS) $(CDIR)/gencode.c
glosym.o: $(CDIR)/glosym.c
cc -c $(CFLAGS) $(CDIR)/glosym.c
main.o: $(CDIR)/main.c
cc -c $(CFLAGS) $(CDIR)/main.c
move.o: $(CDIR)/move.c
cc -c $(CFLAGS) $(CDIR)/move.c
nextem.o: $(CDIR)/nextem.c
cc -c $(CFLAGS) $(CDIR)/nextem.c
reg.o: $(CDIR)/reg.c
cc -c $(CFLAGS) $(CDIR)/reg.c
regvar.o: $(CDIR)/regvar.c
cc -c $(CFLAGS) $(CDIR)/regvar.c
salloc.o: $(CDIR)/salloc.c
cc -c $(CFLAGS) $(CDIR)/salloc.c
state.o: $(CDIR)/state.c
cc -c $(CFLAGS) $(CDIR)/state.c
subr.o: $(CDIR)/subr.c
cc -c $(CFLAGS) $(CDIR)/subr.c
var.o: $(CDIR)/var.c
cc -c $(CFLAGS) $(CDIR)/var.c
install: all
../../install cg
cmp: all
-../../compare cg
tables.c: table $(CGG)
$(CGG) table
-cmp tables.h tables.H || cp tables.H tables.h
lint: $(CFILES)
lint $(LINTOPTS) $(PREFLAGS) $(CFILES)
clean:
rm -f *.o tables.c tables.h debug.out cg tables.H
codegen.o: $(CDIR)/assert.h ../../../h/cgg_cg.h
codegen.o: $(CDIR)/data.h
codegen.o: $(CDIR)/equiv.h
codegen.o: $(CDIR)/extern.h
codegen.o: $(CDIR)/param.h
codegen.o: $(CDIR)/result.h
codegen.o: $(CDIR)/state.h
codegen.o: tables.h
codegen.o: $(CDIR)/types.h
compute.o: $(CDIR)/assert.h ../../../h/cgg_cg.h
compute.o: $(CDIR)/data.h
compute.o: $(CDIR)/extern.h
compute.o: $(CDIR)/glosym.h
compute.o: $(CDIR)/param.h
compute.o: $(CDIR)/result.h
compute.o: tables.h
compute.o: $(CDIR)/types.h
equiv.o: $(CDIR)/assert.h
equiv.o: $(CDIR)/data.h ../../../h/cgg_cg.h
equiv.o: $(CDIR)/equiv.h
equiv.o: $(CDIR)/extern.h
equiv.o: $(CDIR)/param.h
equiv.o: $(CDIR)/result.h
equiv.o: tables.h
equiv.o: $(CDIR)/types.h
fillem.o: $(CDIR)/assert.h ../../../h/cgg_cg.h
fillem.o: $(CDIR)/data.h
fillem.o: $(CDIR)/extern.h
fillem.o: mach.c
fillem.o: mach.h
fillem.o: $(CDIR)/param.h
fillem.o: $(CDIR)/regvar.h
fillem.o: $(CDIR)/result.h
fillem.o: tables.h
fillem.o: $(CDIR)/types.h
gencode.o: $(CDIR)/assert.h ../../../h/cgg_cg.h
gencode.o: $(CDIR)/data.h
gencode.o: $(CDIR)/extern.h
gencode.o: $(CDIR)/param.h
gencode.o: $(CDIR)/result.h
gencode.o: tables.h
gencode.o: $(CDIR)/types.h
glosym.o: $(CDIR)/glosym.h
glosym.o: $(CDIR)/param.h
glosym.o: tables.h
glosym.o: $(CDIR)/types.h
main.o: $(CDIR)/param.h
main.o: tables.h
move.o: $(CDIR)/assert.h ../../../h/cgg_cg.h
move.o: $(CDIR)/data.h
move.o: $(CDIR)/extern.h
move.o: $(CDIR)/param.h
move.o: $(CDIR)/result.h
move.o: tables.h
move.o: $(CDIR)/types.h
nextem.o: $(CDIR)/assert.h ../../../h/cgg_cg.h
nextem.o: $(CDIR)/data.h
nextem.o: $(CDIR)/extern.h
nextem.o: $(CDIR)/param.h
nextem.o: $(CDIR)/result.h
nextem.o: tables.h
nextem.o: $(CDIR)/types.h
reg.o: $(CDIR)/assert.h ../../../h/cgg_cg.h
reg.o: $(CDIR)/data.h
reg.o: $(CDIR)/extern.h
reg.o: $(CDIR)/param.h
reg.o: $(CDIR)/result.h
reg.o: tables.h
reg.o: $(CDIR)/types.h
regvar.o: $(CDIR)/assert.h ../../../h/cgg_cg.h
regvar.o: $(CDIR)/data.h
regvar.o: $(CDIR)/extern.h
regvar.o: $(CDIR)/param.h
regvar.o: $(CDIR)/regvar.h
regvar.o: $(CDIR)/result.h
regvar.o: tables.h
regvar.o: $(CDIR)/types.h
salloc.o: $(CDIR)/assert.h ../../../h/cgg_cg.h
salloc.o: $(CDIR)/data.h
salloc.o: $(CDIR)/extern.h
salloc.o: $(CDIR)/param.h
salloc.o: $(CDIR)/result.h
salloc.o: tables.h
salloc.o: $(CDIR)/types.h
state.o: $(CDIR)/assert.h ../../../h/cgg_cg.h
state.o: $(CDIR)/data.h
state.o: $(CDIR)/extern.h
state.o: $(CDIR)/param.h
state.o: $(CDIR)/result.h
state.o: $(CDIR)/state.h
state.o: tables.h
state.o: $(CDIR)/types.h
subr.o: $(CDIR)/assert.h ../../../h/cgg_cg.h
subr.o: $(CDIR)/data.h
subr.o: $(CDIR)/extern.h
subr.o: $(CDIR)/param.h
subr.o: $(CDIR)/result.h
subr.o: tables.h
subr.o: $(CDIR)/types.h
var.o: $(CDIR)/data.h ../../../h/cgg_cg.h
var.o: $(CDIR)/param.h
var.o: $(CDIR)/result.h
var.o: tables.h
var.o: $(CDIR)/types.h