Digital Research
This commit is contained in:
2020-11-06 18:50:37 +01:00
parent 621ed8ccaf
commit 31738079c4
8481 changed files with 1888323 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) ar68.h - Jul 26, 1983 REGULUS 4.1
*/
#define LIBMAGIC 0177545
#define LIBHDSIZE 26
#define LIBNSIZE 14
struct libhdr {
char lfname[LIBNSIZE];
long lmodti;
char luserid;
char lgid;
#ifndef VAX11
int lfimode;
#else
unsigned short lfimode;
#endif
long lfsize;
};

View File

@@ -0,0 +1,97 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) sys/cout.h - Jul 26, 1983 REGULUS 4.1
*/
struct hdr {
#ifndef VAX11
int ch_magic; /* c.out magic number 060016 = $600E */
#else
unsigned short ch_magic;
#endif
long ch_tsize; /* text size */
long ch_dsize; /* data size */
long ch_bsize; /* bss size */
long ch_ssize; /* symbol table size */
long ch_stksize; /* stack size */
long ch_entry; /* location of entry point */
short ch_rlbflg; /* relocation bits present flag, must be signed */
};
struct hdr_cout {
#ifndef VAX11
int ftype; /* c.out magic number 060016 = $600E */
#else
unsigned short ftype;
#endif
long ftext; /* text size */
long fdata; /* data size */
long fbss; /* bss size */
long fsym; /* symbol table size */
long fssize; /* stack size */
long fentry; /* location of entry point */
short fflag; /* relocation bits present flag, must be signed */
};
struct hdr2 {
#ifndef VAX11
int ch_magic; /* c.out magic number = 601B hex */
#else
unsigned short ch_magic;
#endif
long ch_tsize; /* # bytes in program text segment */
long ch_dsize; /* # bytes in program data segment */
long ch_bsize; /* # bytes in program bss segment */
long ch_ssize; /* # bytes in symbol table */
long ch_stksize; /* initial stack size */
long ch_entry; /* entry point--address of text segment */
short ch_rlbflg; /* relocation bits suppressed flag, must be signed */
long ch_dstart; /* address of data segment */
long ch_bstart; /* address of bss segment */
};
/* HDSIZE should be 28 bytes, HDSIZ2 should be 36 bytes */
#ifndef VAX11
# define HDSIZE (sizeof (struct hdr))
# define HDSIZ2 (sizeof (struct hdr2))
#else
# define HDSIZE 28
# define HDSIZ2 36
#endif
#ifdef VAX11
# define MAGIC (unsigned short) 0x601a /* bra .+26 instruction */
# define MAGIC1 (unsigned short) 0x601b /* data & bss base defined */
# define MAGICST2 (unsigned short) 0x601c /* shared text 2K boundary */
# define MAGICID (unsigned short) 0x601d /* I & D split */
# define MAGICST (unsigned short) 0x601e /* shared test 4k boundary (-n default) */
# define EX_MAGIC (unsigned short) 0x601a
# define EX_ABMAGIC (unsigned short) 0x601b
# define EX_2KSTXT (unsigned short) 0x601c
# define EX_IDMAGIC (unsigned short) 0x601d
# define EX_4KSTXT (unsigned short) 0x601e
#else
# define MAGIC 0x601a /* bra .+26 instruction */
# define MAGIC1 0x601b /* data & bss base defined */
# define MAGICST2 0x601c /* shared text 2K boundary */
# define MAGICID 0x601d /* I & D split */
# define MAGICST 0x601e /* shared test 4k boundary (-n default) */
# define EX_MAGIC 0x601a
# define EX_ABMAGIC 0x601b
# define EX_2KSTXT 0x601c
# define EX_IDMAGIC 0x601d
# define EX_4KSTXT 0x601e
#endif
#define SHT2KBOUND 2048
#define SHT2KFIX(x) (((x+SHT2KBOUND-1)/SHT2KBOUND)*SHT2KBOUND)
#define SHT4KBOUND 4096
#define SHT4KFIX(x) (((x+SHT4KBOUND-1)/SHT4KBOUND)*SHT4KBOUND)

View File

@@ -0,0 +1,27 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) cputc.c - Sep 12, 1983 REGULUS 4.1
*/
# include "iodec.h"
/**
** put a single character
**/
int f_log 0;
cputc(c, fn)
char c;
int fn;
{
if (fn == 2) /* Standard Error */
write(fn, &c, 1);
else
putchar(c);
}

View File

@@ -0,0 +1,29 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) fcreat.c - Sep 12, 1983 REGULUS 4.1
*/
/* v6 fcreat library call */
#define BSIZE 512
struct iob {
int fd; /* file descriptor */
int cc; /* char count */
char *cp; /* ptr to next char */
char cbuf[BSIZE]; /* char buffer */
};
fcreat(fname,ibuf)
char *fname;
register struct iob *ibuf;
{
ibuf->cc = BSIZE; /* no chars */
ibuf->cp = &(ibuf->cbuf[0]);
return(ibuf->fd = creat(fname,0666));
}

View File

@@ -0,0 +1,46 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) getarhd.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include "ar68.h"
#include "iobuf.h"
/*
* getarhd - fills the archive header structure from the buffer int
* the manner which will be understood on the current machine.
*/
int
getarhd(fp,arptr) /* returns -1 for failure, 0 for success */
FILE *fp;
struct libhdr *arptr;
{
register int i;
register char *p, *lp;
for (i = 0, lp = arptr->lfname; i < LIBNSIZE; i++)
if ((*lp++ = getc(fp)) == -1)
return(-1);
if (lgetl(&arptr->lmodti,fp) == -1)
return(-1);
if ((arptr->luserid = getc(fp)) == -1)
return(-1);
if ((arptr->lgid = getc(fp)) == -1)
return(-1);
if (lgetw(&arptr->lfimode,fp) == -1)
return(-1);
if (lgetl(&arptr->lfsize,fp) == -1)
return(-1);
return(0);
}

View File

@@ -0,0 +1,34 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) getc.c - Sep 12, 1983 REGULUS 4.1
*/
/* v6 getc library routines */
#define BSIZE 512
struct iob {
int fd; /* file descriptor */
int cc; /* char count */
char *cp; /* ptr to next char */
char cbuf[BSIZE]; /* char buffer */
};
getc(ibuf)
struct iob *ibuf;
{
if (ibuf->cc <= 0) {
ibuf->cp = &(ibuf->cbuf[0]);
ibuf->cc = read(ibuf->fd,ibuf->cp,BSIZE);
}
if (ibuf->cc <= 0)
return(-1);
ibuf->cc--;
return((int)((*(ibuf->cp)++)&0xff));
}

View File

@@ -0,0 +1,44 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) getchar.c - Sep 12, 1983 REGULUS 4.1
*/
/* v6 getchar routine */
#define BSIZE 512
struct iob {
int fd; /* file descriptor */
int cc; /* char count */
char *cp; /* ptr to next character */
char cbuf[BSIZE]; /* char buffer */
} fin;
getchar()
{
char c;
register int i;
if (fin.fd == 0) {
if (read(0,&c,1) <= 0 || c==4)
return(0);
i = c;
return(i & 0xff);
}
if (fin.cc <= 0) {
fin.cp = &(fin.cbuf[0]);
fin.cc = read(fin.fd,fin.cp,BSIZE);
}
if (fin.cc <= 0)
return(0);
fin.cc--;
i = *(fin.cp)++;
return(i & 0xff);
}

View File

@@ -0,0 +1,52 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) getchd.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include "cout.h"
#include "iobuf.h"
/*
* getchd - fills the c.out header structure from the buffer in
* the manner which will be understood on the current machine.
*/
int
getchd(fp,arptr) /* returns 0 for success, -1 for failure */
FILE *fp;
struct hdr *arptr;
{
if (lgetw(&arptr->ch_magic,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_tsize,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_dsize,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_bsize,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_ssize,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_stksize,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_entry,fp) == -1)
return(-1);
if (lgetw(&arptr->ch_rlbflg,fp) == -1)
return(-1);
if (arptr->ch_magic == EX_ABMAGIC) {
if (lgetl(&arptr->ch_dstart,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_bstart,fp) == -1)
return(-1);
}
return(0);
}

View File

@@ -0,0 +1,19 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) iobuf.h - Jul 26, 1983 REGULUS 4.1
*/
#define BLEN 512
struct iobuf{
int fildes;
int nunused;
char *xfree;
char buff[BLEN];
};
#define FILE struct iobuf

View File

@@ -0,0 +1,34 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) iodec.h - Sep 12, 1983 REGULUS 4.1
*/
# define MAXFILES 15
struct fileps
{
char *buff; /* beginning of buffer */
char *bptr; /* current position */
int nchars; /* number of characters internal */
int bsize; /* size of buffer */
char eoferr; /* end of file flag */
char wrflag; /* mode flag */
char *pbuff; /* bottom of peek buffer */
};
struct fileps __filehdr[MAXFILES];
struct param
{
int bufsize; /* initial buffer size */
int peeksize; /* initial peek size */
};
extern struct param __param;
int __statbuf[MAXFILES];

View File

@@ -0,0 +1,84 @@
.globl _ldivr
.comm _ldivr,4
.globl _ldiv
.globl ldiv
.text
_ldiv:
ldiv:
~~ldiv:
~b=R4
~q=R5
~l1=R7
~l2=R6
~al1=8
~al2=12
~sign=R3
link R14,#-2
movem.l R2-R7,-(sp)
clr R3
clr.l R5
move.l 8(R14),R7
move.l 12(R14),R6
bne L2
move.l #$80000000,_ldivr
move.l #$80000000,R0
bra L1
L2:
bge L3
neg.l R6
add #1,R3
L3:
tst.l R7
bge L4
neg.l R7
add #1,R3
L4:
cmp.l R7,R6
bgt L6
bne L7
move.l #1,R5
clr.l R7
bra L6
L7:
cmp.l #$10000,R7
bge L9
divu R6,R7
move R7,R5
swap R7
ext.l R7
bra L6
L9:
move.l #1,R4
L12:
cmp.l R6,R7
blo L11
asl.l #1,R6
asl.l #1,R4
bra L12
L11:
tst.l R4
beq L6
cmp.l R6,R7
blo L15
or.l R4,R5
sub.l R6,R7
L15:
lsr.l #1,R4
lsr.l #1,R6
bra L11
L6:
cmp #1,R3
bne L16
neg.l R7
move.l R7,_ldivr
move.l R5,R0
neg.l R0
bra L1
L16:
move.l R7,_ldivr
move.l R5,R0
L1:
tst.l (sp)+
movem.l (sp)+,R3-R7
unlk R14
rts

View File

@@ -0,0 +1,22 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) __length.c - Sep 12, 1983 REGULUS 4.1
*/
__length(s)
char *s;
{
register int l;
register char *p;
p = s;
l = 0;
while (*p++)
l++;
return(l);
}

View File

@@ -0,0 +1,46 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) libget.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include "order.h"
#include "iobuf.h"
#define dogetc(byte,i,fp) if((i=getc(fp))==-1) return(ERROR); else byte=(char)i
lgetl(lp,f) /* returns -1 for failure, 0 for success */
long *lp; /* 32 bits */
FILE *f;
{
register int i;
dogetc(lp->b1,i,f);
dogetc(lp->b2,i,f);
dogetc(lp->b3,i,f);
dogetc(lp->b4,i,f);
return(SUCCESS);
}
lgetw(lp,f) /* returns -1 for failure, 0 for success */
short *lp; /* 16 bits */
FILE *f;
{
register int i;
dogetc(lp->wb1,i,f);
dogetc(lp->wb2,i,f);
*lp &= 0xffff;
return(SUCCESS);
}

View File

@@ -0,0 +1,40 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) libput.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include "order.h"
#include "iobuf.h"
#define doputc(byte,fp) if(putc(byte,fp) == -1) return(ERROR)
lputl(lp,f) /* returns 0 for success, -1 for failure */
long *lp; /* 32 bits */
FILE *f;
{
doputc(lp->b1,f);
doputc(lp->b2,f);
doputc(lp->b3,f);
doputc(lp->b4,f);
return(SUCCESS);
}
lputw(lp,f) /* returns 0 for success, -1 for failure */
short *lp; /* 16 bits */
FILE *f;
{
doputc(lp->wb1,f);
doputc(lp->wb2,f);
return(SUCCESS);
}

View File

@@ -0,0 +1,53 @@
/*
Copyright 1982
Alcyon Corporation
8716 Production Ave.
San Diego, Ca. 92121
@(#) libread.c - Sep 12, 1983 REGULUS 4.1
*/
#include "order.h"
lreadl(fd,str)
int fd;
long *str;
{
register char *p;
char junk[4];
if (read(fd,junk,4) != 4)
return(ERROR);
p = junk;
str->b1 = *p++;
str->b2 = *p++;
str->b3 = *p++;
str->b4 = *p;
return(SUCCESS);
}
lreadw(fd,str)
int fd;
short *str;
{
char junk[2];
if (read(fd,junk,2) != 2)
return(ERROR);
str->wb1 = junk[0];
str->wb2 = junk[1];
return(SUCCESS);
}
lreadc(fd,str)
int fd;
char *str;
{
char junk[1];
if (read(fd,&junk,1) != 1)
return(ERROR);
*str = junk[0];
return(SUCCESS);
}

View File

@@ -0,0 +1,54 @@
/*
Copyright 1982
Alcyon Corporation
8716 Production Ave.
San Diego, Ca. 92121
@(#) libwrite.c - Sep 12, 1983 REGULUS 4.1
*/
#include "order.h"
lwritel(fd,str)
int fd;
long *str;
{
register char *p;
char junk[4];
p = junk;
*p++ = str->b1;
*p++ = str->b2;
*p++ = str->b3;
*p = str->b4;
if (write(fd,junk,4) == 4)
return(SUCCESS);
else
return(ERROR);
}
lwritew(fd,str)
int fd;
short *str;
{
register char *p;
char junk[2];
p = junk;
*p++ = str->wb1;
*p = str->wb2;
if (write(fd,junk,2) == 2)
return(SUCCESS);
else
return(ERROR);
}
lwritec(fd,str)
int fd;
char *str;
{
if (write(fd,str,1) != 1)
return(ERROR);
return(SUCCESS);
}

View File

@@ -0,0 +1,74 @@
*// long multiply routine without floating point
*// call with:
*// two long values on stack
*// returns:
*// long value in R0 and R1
*//
*// warning: no overflow checking or indication!!!!
*struct {
* int hiword;
* int loword;
*};
*long lmul(l1,l2)
*long l1,l2;
*{
*
* long t1;
* register int sign;
* register int t2;
*
* sign = 0;
* if(l1 < 0) {
* l1 = -l1; //make it positive
* sign++;
* }
* if(l2 < 0) {
* l2 = -l2; //make it positive
* sign++;
* }
* t1 = l1.loword*l2.loword;
* t2 = l1.hiword*l2.loword + l2.hiword*l1.loword;
* t1.hiword = t1.hiword + t2;
* if(sign&1)
* t1 = -t1; //negate results
* return(t1);
*}
*
*
.globl lmul
.text
lmul:
_lmul:
~~lmul:
~sign=R2
~l1=8
~l2=12
~t1=-4
~t2=R6
link R14,#-4
clr R2
tst.l 8(R14) //is first arg negative?
bge L2
neg.l 8(R14) //yes, negate it
inc R2 // increment sign flag
L2:tst.l 12(R14) //is second arg negative?
bge L3
neg.l 12(R14) //yes, make it positive
inc R2 //increment sign flag
L3:move 10(R14),R0 //arg1.loword
mulu 14(R14),R0 //arg2.loword
move.l R0,-4(R14) //save in temp
move 8(R14),R0 //arg1.hiword
mulu 14(R14),R0 //arg2.loword
move 12(R14),R1 //arg2.hiword
mulu 10(R14),R1 //arg1.loword
add R1,R0 //form the sum of 2 lo-hi products
add -4(R14),R0 //add to temp hiword
move R0,-4(R14) //store back in temp hiword
move.l -4(R14),R0 //long results
btst #0,R2 //test sign flag
beq L4
neg.l R0 //complement the results
L4:
unlk R14
rts

View File

@@ -0,0 +1,19 @@
.globl _ldiv
.globl _ldivr
.comm _ldivr,4
.globl _lrem
.globl lrem
.text
_lrem:
lrem:
~~lrem:
~l2=12
~al1=8
link R14,#-2
move.l 12(R14),-(sp)
move.l 8(R14),-(sp)
jsr _ldiv
cmpm.l (sp)+,(sp)+
move.l _ldivr,R0
unlk R14
rts

View File

@@ -0,0 +1,73 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) order.h - Jul 26, 1983 REGULUS 4.1
*/
#ifdef MC68000
struct { char b1; char b2; char b3; char b4; };
struct { char wb1; char wb2; };
union WORDPTR {
long longwd;
struct {
int hiword;
int loword;
} WORDSTR;
};
union BYTEPTR {
short shortwd;
struct {
char hibyte;
char lobyte;
} BYTESTR;
};
#endif
#ifdef VAX11
struct { char b4; char b3; char b2; char b1; };
struct { char wb2; char wb1; };
union WORDPTR {
long longwd;
struct {
short loword;
short hiword;
} WORDSTR;
};
union BYTEPTR {
short shortwd;
struct {
char lobyte;
char hibyte;
} BYTESTR;
};
#endif
#ifdef PDP11
struct { char b2; char b1; char b4; char b3; };
struct { char wb2; char wb1; };
union WORDPTR {
long longwd;
struct {
int hiword;
int loword;
} WORDSTR;
};
union BYTEPTR {
int shortwd;
struct {
char lobyte;
char hibyte;
} BYTESTR;
};
#endif
#define ERROR -1
#define SUCCESS 0

View File

@@ -0,0 +1,260 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) printf.c - Sep 12, 1983 REGULUS 4.1
*/
# include "iodec.h"
# define BUFSIZ 80
/**
** formated print
**/
printf(parlist)
char *parlist;
{
register char *fmt, c;
char buf[BUFSIZ];
extern char *__prtshort(), *__prtld(), *__prtld();
int mode;
char *fd;
register char **p;
register int *pi;
int width, prec;
int left, longf;
char padchar;
char *s;
int n;
auto (*fn)();
int len;
p = &parlist;
fd = 0;
mode = 0; /* mode zero, putchar */
if (parlist + 1 < MAXFILES + 1) {
mode++; /* mode one, cputc */
fd = *p++;
}
if (fd == -1) {
mode++; /* mode two, string */
fd = *p++;
}
fmt = *p++;
pi = p;
while (c = *fmt++)
{
p = pi;
if (c != '%') {
__putch(mode, &fd, c);
continue;
}
left = 0;
if ((c = *fmt++) == '-') {
c = *fmt++;
left++;
}
padchar = ' ';
if (c == '0') {
padchar = c;
c = *fmt++;
}
width = -1;
while (c >= '0' && c <= '9')
{
if (width < 0)
width = 0;
width = width * 10 + (c - '0');
c = *fmt++;
}
prec = -1;
if (c == '.')
{
prec = 0;
c = *fmt++;
}
while (c >= '0' && c <= '9')
{
prec = prec * 10 + (c - '0');
c = *fmt++;
}
longf = 0;
if (c == 'l')
{
longf++;
c = *fmt++;
}
/* we now have all the prelims out of the way;
let's see what we want to print */
s = buf;
switch (c)
{
case 'd': /* decimal signed */
case 'D':
if (longf)
fn = __prtld;
else
fn = __prtshort;
__prtint(pi++, buf, 10, 1, fn, 0);
if (longf)
pi++;
break;
case 'u': /* decimal unsigned */
case 'U':
__prtint(pi++, buf, 10, 0, __prtshort, 0);
break;
case 'o': /* octal unsigned */
case 'O':
if (longf)
fn = __prtld;
else
fn = __prtshort;
__prtint(pi++, buf, 8, 0, fn, 0);
if (longf)
pi++;
break;
case 'x': /* hexadecimal unsigned */
case 'X':
if (longf)
fn = __prtld;
else
fn = __prtshort;
__prtint(pi++, buf, 16, 0, fn, c == 'X');
if (longf)
pi++;
break;
case 's': /* string */
case 'S':
s = *p++;
pi = p;
break;
case 'c': /* character */
case 'C':
n = *pi++;
buf[0] = n;
buf[1] = '\0';
break;
default: /* just print the character */
__putch(mode, &fd, c);
continue;
}
len = __length(s);
if (prec < len && prec >= 0)
len = prec;
n = width - len;
if (!left)
{
if (padchar != ' ' && *s == '-')
{
len--;
__putch(mode, &fd, *s++);
}
while (n-- > 0)
__putch(mode, &fd, padchar);
}
while (len--)
__putch(mode, &fd, *s++);
while (n-- > 0)
__putch(mode, &fd, padchar);
}
if (mode == 2)
*fd = '\0';
}
__putch(mode, pfd, c)
int mode;
char c;
char **pfd;
{
switch (mode)
{
case 0:
putchar(c);
break;
case 1:
cputc(c, *pfd);
break;
case 2:
*(*pfd)++ = c;
break;
}
return (c);
}
char *__prtld(pobj, pbuf, base, signed, digs)
long *pobj;
char **pbuf;
int base;
int signed;
char *digs;
{
register long n;
register long b;
register char *p;
struct {
char cbyte0;
char cbyte1;
char cbyte2;
char cbyte3;
};
register i;
struct {
int wd1;
int wd2;
};
p = digs;
b = base;
n = *pobj;
if(base == 16) { /* special because of negatives */
i = 8;
while(n && i) {
*p++ = n & 0xf;
n =>> 4;
i--;
}
}
else if(base == 8) {
i = 11;
while(n && i) {
*p++ = n & 7;
n =>> 3;
i--;
}
if(i==0) {
*(p-1) =& 3; /* only 2 bits in upper octal digit */
}
}
else {
if (signed && n < 0) {
*(*pbuf)++ = '-';
n = -n;
}
while(n) {
*p++ = n%b;
n /= b;
}
}
return (p);
}

View File

@@ -0,0 +1,71 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) __prtint.c - Sep 12, 1983 REGULUS 4.1
*/
char *
__prtint(pobj, buf, base, signed, f, upper)
int *pobj;
char *buf;
int base, signed, upper;
char *(*f)();
{
char digs[15];
register char *dp;
register int k;
register char *p;
dp = (*f)(pobj, &buf, base, signed, digs);
if (dp == digs)
*dp++ = 0;
p = buf;
while (dp != digs)
{
k = *--dp;
if (k < 10)
k =+ '0';
else
k =+ upper ? 'A'-10 : 'a'-10;
*p++ = k;
}
*p = 0;
return (p);
}
char *
__prtshort(pobj, pbuf, base, signed, digs)
int *pobj;
char **pbuf;
int base, signed;
char *digs;
{
register long n;
register char *p;
register long b;
p = digs;
b = base;
n = *pobj;
if (signed && n < 0)
{
n = -n;
*(*pbuf)++ = '-';
}
else
n =& 0xffffL; /* clear upper half */
while (n != 0)
{
*p++ = n%b;
n /= b;
}
return (p);
}

View File

@@ -0,0 +1,47 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) putarhd.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include "ar68.h"
#include "iobuf.h"
/*
* putarhd - fills the buffer from the archive header structure in
* the byte orientation of the target machine (68000).
*/
int
putarhd(fp,arptr) /* returns 0 for success, -1 for error */
FILE *fp;
struct libhdr *arptr;
{
register int i;
register char *p, *lp;
for (i=0, lp = arptr->lfname; i<LIBNSIZE; i++, lp++)
if (putc(*lp,fp) == -1)
return(-1);
if (lputl(&arptr->lmodti,fp) == -1)
return(-1);
if (putc(arptr->luserid,fp) == -1)
return(-1);
if (putc(arptr->lgid,fp) == -1)
return(-1);
if (lputw(&arptr->lfimode,fp) == -1)
return(-1);
if (lputl(&arptr->lfsize,fp) == -1)
return(-1);
return(0);
}

View File

@@ -0,0 +1,34 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) putc.c - Sep 12, 1983 REGULUS 4.1
*/
#define BSIZE 512
struct iob {
int fd; /* file descriptor */
int cc; /* char count */
char *cp; /* ptr to next char */
char cbuf[BSIZE]; /* char buffer */
};
putc(c,ibuf)
char c;
register struct iob *ibuf;
{
if (ibuf->cc <= 0) {
ibuf->cp = &(ibuf->cbuf[0]);
if (write(ibuf->fd,ibuf->cp,BSIZE) != BSIZE)
return(-1);
ibuf->cc = BSIZE;
}
*(ibuf->cp)++ = c;
ibuf->cc--;
return((int)(c&0xff));
}

View File

@@ -0,0 +1,54 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) putchar.c - Sep 12, 1983 REGULUS 4.1
*/
/* version 6 putchar library routine */
#define BSIZE 512
struct iob {
int fd; /* file descriptor */
int cc; /* char count */
char *cp; /* prt to next char */
char cbuf[BSIZE]; /* char buffer */
} fout = {0,BSIZE,&fout.cbuf[0]};
putchar(cc)
char cc;
{
if (fout.fd <= 1) {
if (write(1,&cc,1) != 1)
return(-1);
return(cc);
}
/* buffered output */
if (fout.cc <= 0) {
fout.cp = &(fout.cbuf[0]);
if (write(fout.fd,fout.cp,BSIZE) != BSIZE)
return(-1);
fout.cc = BSIZE;
}
*(fout.cp)++ = cc;
fout.cc--;
return(cc);
}
flush()
{
register i;
i = BSIZE - fout.cc;
fout.cc = BSIZE;
fout.cp = &(fout.cbuf[0]);
if (write(fout.fd,fout.cp,i) != i)
return(-1);
return(0);
}

View File

@@ -0,0 +1,53 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) putchd.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include "cout.h"
#include "iobuf.h"
/*
* putchd - fills the buffer from the c.out header structure in
* the byte orientation of the target machine (68000).
*/
int
putchd(fp,arptr) /* returns 0 for success, -1 for failure */
FILE *fp;
struct hdr *arptr;
{
if (lputw(&arptr->ch_magic,fp) == -1)
return(-1);
if (lputl(&arptr->ch_tsize,fp) == -1)
return(-1);
if (lputl(&arptr->ch_dsize,fp) == -1)
return(-1);
if (lputl(&arptr->ch_bsize,fp) == -1)
return(-1);
if (lputl(&arptr->ch_ssize,fp) == -1)
return(-1);
if (lputl(&arptr->ch_stksize,fp) == -1)
return(-1);
if (lputl(&arptr->ch_entry,fp) == -1)
return(-1);
if (lputw(&arptr->ch_rlbflg,fp) == -1)
return(-1);
if (arptr->ch_magic == EX_ABMAGIC) {
if (lputl(&arptr->ch_dstart,fp) == -1)
return(-1);
if (lputl(&arptr->ch_bstart,fp) == -1)
return(-1);
}
return(0);
}

View File

@@ -0,0 +1,2 @@
This directory includes routines and include files necessary for porting
the Alcyon compiler, assembler and loader to a non-regulus machine.

View File

@@ -0,0 +1,24 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) seek.c - Sep 12, 1983 REGULUS 4.1
*/
/* fake v6 seek system call */
seek(fd,offset,position)
int fd, offset, position;
{
register long loffset;
loffset = offset;
if (position >= 3) {
loffset *= 512;
position -= 3;
}
lseek(fd,loffset,position);
}

View File

@@ -0,0 +1,35 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) v6fflush.c - Sep 12, 1983 REGULUS 4.1
*/
/* v6 v6fflush library call */
#define BSIZE 512
struct iob {
int fd; /* file descriptor */
int cc; /* char count */
char *cp; /* ptr to next char */
char cbuf[BSIZE]; /* char buffer */
};
v6fflush(ibuf)
register struct iob *ibuf;
{
register i;
i = BSIZE - ibuf->cc;
ibuf->cc = BSIZE;
ibuf->cp = &(ibuf->cbuf[0]);
if (write(ibuf->fd,ibuf->cp,i) != i)
return(-1);
return(0);
}

View File

@@ -0,0 +1,51 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) getarhd.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include <stdio.h>
#ifndef MC68000
# include <c68/ar68.h>
#else
# include <ar68.h>
#endif
/*
* getarhd - fills the archive header structure from the buffer int
* the manner which will be understood on the current machine.
*/
int
getarhd(fp,arptr) /* returns -1 for failure, 0 for success */
FILE *fp;
struct libhdr *arptr;
{
register int i;
register char *p, *lp;
for (i = 0, lp = arptr->lfname; i < LIBNSIZE; i++)
if ((*lp++ = getc(fp)) == EOF)
return(-1);
if ((lgetl(&arptr->lmodti,fp)) == -1)
return(-1);
if ((arptr->luserid = getc(fp)) == EOF)
return(-1);
if ((arptr->lgid = getc(fp)) == EOF)
return(-1);
if ((lgetw(&arptr->lfimode,fp)) == -1)
return(-1);
if ((lgetl(&arptr->lfsize,fp)) == -1)
return(-1);
return(0);
}

View File

@@ -0,0 +1,57 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) getchd.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include <stdio.h>
#ifndef MC68000
# include <c68/cout.h>
#else
# include <cout.h>
#endif
/*
* getchd - fills the c.out header structure from the buffer in
* the manner which will be understood on the current machine.
*/
int
getchd(fp,arptr) /* returns 0 for success, -1 for failure */
FILE *fp;
struct hdr2 *arptr;
{
if (lgetw(&arptr->ch_magic,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_tsize,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_dsize,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_bsize,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_ssize,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_stksize,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_entry,fp) == -1)
return(-1);
if (lgetw(&arptr->ch_rlbflg,fp) == -1)
return(-1);
if (arptr->ch_magic == EX_ABMAGIC) {
if (lgetl(&arptr->ch_dstart,fp) == -1)
return(-1);
if (lgetl(&arptr->ch_bstart,fp) == -1)
return(-1);
}
return(0);
}

View File

@@ -0,0 +1,49 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) libget.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include "order.h"
#include <stdio.h>
#ifndef PDP11
# define dogetc(byte,i,fp) byte = (unsigned char)getc(fp)
#else
# define dogetc(byte,i,fp) byte = getc(fp)
#endif
lgetl(lp,f) /* returns -1 for failure, 0 for success */
long *lp; /* 32 bits */
FILE *f;
{
register int i;
dogetc(lp->b1,i,f);
dogetc(lp->b2,i,f);
dogetc(lp->b3,i,f);
dogetc(lp->b4,i,f);
return((ferror(f)) ? ERROR :SUCCESS);
}
lgetw(lp,f) /* returns -1 for failure, 0 for success */
short *lp; /* 16 bits */
FILE *f;
{
register int i;
dogetc(lp->wb1,i,f);
dogetc(lp->wb2,i,f);
*lp &= 0xffff;
return((ferror(f)) ? ERROR :SUCCESS);
}

View File

@@ -0,0 +1,41 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) libput.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include "order.h"
#include <stdio.h>
#define doputc(byte,fp) putc(byte,fp)
lputl(lp,f) /* returns 0 for success, -1 for failure */
long *lp; /* 32 bits */
FILE *f;
{
doputc(lp->b1,f);
doputc(lp->b2,f);
doputc(lp->b3,f);
doputc(lp->b4,f);
return((ferror(f)) ? ERROR : SUCCESS);
}
lputw(lp,f) /* returns 0 for success, -1 for failure */
short *lp; /* 16 bits */
FILE *f;
{
doputc(lp->wb1,f);
doputc(lp->wb2,f);
return((ferror(f)) ? ERROR : SUCCESS);
}

View File

@@ -0,0 +1,55 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, Ca. 92121
@(#) libread.c - Sep 12, 1983 REGULUS 4.1
*/
#include "order.h"
lreadl(fd,str)
int fd;
long *str;
{
register char *p;
char junk[4];
if (read(fd,junk,4) != 4)
return(ERROR);
p = junk;
str->b1 = *p++;
str->b2 = *p++;
str->b3 = *p++;
str->b4 = *p;
return(SUCCESS);
}
lreadw(fd,str)
int fd;
short *str;
{
register char *p;
char junk[2];
if (read(fd,junk,2) != 2)
return(ERROR);
p = junk;
str->wb1 = *p++;
str->wb2 = *p;
return(SUCCESS);
}
lreadc(fd,str)
int fd;
char *str;
{
char junk[1];
if (read(fd,&junk,1) != 1)
return(ERROR);
*str = junk[0];
return(SUCCESS);
}

View File

@@ -0,0 +1,54 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, Ca. 92121
@(#) libwrite.c - Sep 12, 1983 REGULUS 4.1
*/
#include "order.h"
lwritel(fd,str)
int fd;
long *str;
{
register char *p;
char junk[4];
p = junk;
*p++ = str->b1;
*p++ = str->b2;
*p++ = str->b3;
*p = str->b4;
if (write(fd,junk,4) == 4)
return(SUCCESS);
else
return(ERROR);
}
lwritew(fd,str)
int fd;
short *str;
{
register char *p;
char junk[2];
p = junk;
*p++ = str->wb1;
*p = str->wb2;
if (write(fd,junk,2) == 2)
return(SUCCESS);
else
return(ERROR);
}
lwritec(fd,str)
int fd;
char *str;
{
if (write(fd,str,1) != 1)
return(ERROR);
return(SUCCESS);
}

View File

@@ -0,0 +1,51 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) putarhd.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include <stdio.h>
#ifndef MC68000
# include <c68/ar68.h>
#else
# include <ar68.h>
#endif
/*
* putarhd - fills the buffer from the archive header structure in
* the byte orientation of the target machine (68000).
*/
int
putarhd(fp,arptr) /* returns 0 for success, -1 for error */
FILE *fp;
struct libhdr *arptr;
{
register int i;
register char *p, *lp;
for (i=0, lp = arptr->lfname; i<LIBNSIZE; i++, lp++)
if ((putc(*lp,fp)) == -1)
return(-1);
if (lputl(&arptr->lmodti,fp) == -1)
return(-1);
if ((putc(arptr->luserid,fp)) == -1)
return(-1);
if ((putc(arptr->lgid,fp)) == -1)
return(-1);
if (lputw(&arptr->lfimode,fp) == -1)
return(-1);
if (lputl(&arptr->lfsize,fp) == -1)
return(-1);
return(0);
}

View File

@@ -0,0 +1,57 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, CA 92121
@(#) putchd.c - Sep 12, 1983 REGULUS 4.1
*/
/*
I/O independent mapping routine. Machine specific. Independent
of structure padding. Buffer must contain at least as many
characters as is required for structure.
*/
#include <stdio.h>
#ifndef MC68000
# include <c68/cout.h>
#else
# include <cout.h>
#endif
/*
* putchd - fills the buffer from the c.out header structure in
* the byte orientation of the target machine (68000).
*/
int
putchd(fp,arptr) /* returns 0 for success, -1 for failure */
FILE *fp;
struct hdr2 *arptr;
{
if (lputw(&arptr->ch_magic,fp) == -1)
return(-1);
if (lputl(&arptr->ch_tsize,fp) == -1)
return(-1);
if (lputl(&arptr->ch_dsize,fp) == -1)
return(-1);
if (lputl(&arptr->ch_bsize,fp) == -1)
return(-1);
if (lputl(&arptr->ch_ssize,fp) == -1)
return(-1);
if (lputl(&arptr->ch_stksize,fp) == -1)
return(-1);
if (lputl(&arptr->ch_entry,fp) == -1)
return(-1);
if (lputw(&arptr->ch_rlbflg,fp) == -1)
return(-1);
if (arptr->ch_magic == EX_ABMAGIC) {
if (lputl(&arptr->ch_dstart,fp) == -1)
return(-1);
if (lputl(&arptr->ch_bstart,fp) == -1)
return(-1);
}
return(0);
}