mirror of
https://github.com/SEPPDROID/Digital-Research-Source-Code.git
synced 2025-10-23 00:14:25 +00:00
Upload
Digital Research
This commit is contained in:
17
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/ar.h
Normal file
17
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/ar.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#define ARMAG "!<arch>\n"
|
||||
#define SARMAG 8
|
||||
|
||||
#define ARFMAG "`\n"
|
||||
|
||||
struct ar_hdr {
|
||||
char ar_name[16];
|
||||
char ar_date[12];
|
||||
char ar_uid[6];
|
||||
char ar_gid[6];
|
||||
char ar_mode[8];
|
||||
char ar_size[10];
|
||||
char ar_fmag[2];
|
||||
};
|
||||
#include <stdio.h>
|
||||
#include <klib.h>
|
||||
|
755
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/ar68.c
Normal file
755
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/ar68.c
Normal file
@@ -0,0 +1,755 @@
|
||||
/*
|
||||
Copyright 1981
|
||||
Alcyon Corporation
|
||||
8474 Commerce Av.
|
||||
San Diego, Ca. 92121
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <klib.h>
|
||||
#include "machine.h"
|
||||
#include "iobuf.h"
|
||||
#include "cout.h"
|
||||
|
||||
#define BLKSIZE 512
|
||||
char buff[BLKSIZE]={0};
|
||||
|
||||
/* flags for cp1file*/
|
||||
#define IEVEN 1
|
||||
#define OEVEN 2
|
||||
#define WHDR 4
|
||||
|
||||
#define DIR 0100000
|
||||
#define CHR 040000
|
||||
#define BLK 020000
|
||||
#define ROWN 0400
|
||||
#define WOWN 0200
|
||||
#define XOWN 0100
|
||||
#define RGRP 040
|
||||
#define WGRP 020
|
||||
#define XGRP 010
|
||||
#define ROTH 04
|
||||
#define WOTH 02
|
||||
#define XOTH 01
|
||||
|
||||
#define LIBMAGIC 0177545
|
||||
|
||||
#define LNAMLEN 14
|
||||
struct lib2hdr {
|
||||
char l2fname[LNAMLEN];
|
||||
long l2modti;
|
||||
char l2userid;
|
||||
char l2gid;
|
||||
short l2fimode;
|
||||
long l2fsize;
|
||||
short l2junk;
|
||||
} libhd={0};
|
||||
|
||||
struct {
|
||||
int f_devnum;
|
||||
int f_inum;
|
||||
int f_fimode;
|
||||
char f_nlinks;
|
||||
char f_userid;
|
||||
char f_gid;
|
||||
char f_size0;
|
||||
int f_size1;
|
||||
int f_addr[8];
|
||||
long f_acti;
|
||||
long f_modti;
|
||||
};
|
||||
|
||||
short libmagic = LIBMAGIC;
|
||||
|
||||
int rflg=0, dflg=0, xflg=0, tflg=0, vflg=0;
|
||||
int uflg=0;
|
||||
int pflg=0;
|
||||
int areof=0;
|
||||
int arfd=0;
|
||||
int tempfd=0;
|
||||
int aflg=0, bflg=0;
|
||||
int psflg=0;
|
||||
int matchflg=0;
|
||||
char *psname=0;
|
||||
|
||||
char *arname=0,tempname[80]={0,0,0};
|
||||
/************************/
|
||||
#ifdef UNIX /* */
|
||||
char *dname="/tmp/"; /* UNIX */
|
||||
#else /* CP/M and VMS */
|
||||
char *dname=""; /* Disk Name */
|
||||
#endif /************************/
|
||||
#ifdef UNIX /* */
|
||||
char *tname="arXXXXXX"; /* Unix temp file name */
|
||||
#else /* CP/M and VMS */
|
||||
char *tname="ar68.tmp"; /* Temp file name */
|
||||
#endif /************************/
|
||||
|
||||
long lseek();
|
||||
long fixlong();
|
||||
long filesize();
|
||||
int endit();
|
||||
|
||||
int (*docom)()=0;
|
||||
int replace();
|
||||
int delete();
|
||||
int extract();
|
||||
int xtell();
|
||||
#ifdef JUNK
|
||||
long mklong();
|
||||
#endif
|
||||
int print();
|
||||
#ifdef VAX
|
||||
struct {
|
||||
short loword;
|
||||
short hiword;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef PDP11
|
||||
struct {
|
||||
short loword;
|
||||
short hiword;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef MC68000
|
||||
struct {
|
||||
short hiword;
|
||||
short loword;
|
||||
};
|
||||
#endif
|
||||
|
||||
main(argc,argv)
|
||||
char **argv;
|
||||
{
|
||||
|
||||
register char *p1, *p2;
|
||||
register char **ap;
|
||||
register int i;
|
||||
register long l;
|
||||
register long k;
|
||||
long kk;
|
||||
if(argc < 3) {
|
||||
usage:
|
||||
error("usage: ar68 drtwx[abiv][f d:] [opmod] archive obmod1 [obmod2] ... [>filespec]\n");
|
||||
|
||||
endit();
|
||||
}
|
||||
/* signal(1,endit); */
|
||||
ap = &argv[1];
|
||||
p1 = *ap++;
|
||||
i = argc-3;
|
||||
while(*p1) {
|
||||
switch(*p1++) {
|
||||
|
||||
case 'r':
|
||||
rflg++;
|
||||
docom = replace;
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
aflg++;
|
||||
psname = *ap++;
|
||||
i--;
|
||||
break;
|
||||
|
||||
/* These options removed because they don't work!
|
||||
|
||||
case 'b':
|
||||
case 'i':
|
||||
bflg++;
|
||||
i--;
|
||||
psname = *ap++;
|
||||
break;
|
||||
|
||||
*/
|
||||
case 'd':
|
||||
dflg++;
|
||||
docom = delete;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
xflg++;
|
||||
docom = extract;
|
||||
break;
|
||||
|
||||
case 't':
|
||||
tflg++;
|
||||
docom = xtell;
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
pflg++;
|
||||
docom = print;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
vflg++;
|
||||
break;
|
||||
|
||||
case 'f': /* Drive for temp files */
|
||||
dname = *ap++; /* Set proper disk name */
|
||||
break;
|
||||
default:
|
||||
error("invalid option flag: %c\n",*--p1);
|
||||
endit();
|
||||
}
|
||||
}
|
||||
uflg = rflg+dflg;
|
||||
if((uflg+xflg+tflg+pflg) != 1) {
|
||||
error("one and only one of drtwx flags required\n");
|
||||
endit();
|
||||
}
|
||||
psflg = aflg+bflg;
|
||||
if(psflg > 1) {
|
||||
error("only one of abi flags allowed\n");
|
||||
endit();
|
||||
}
|
||||
strcat (tempname,dname); /* Form 1st part of string */
|
||||
strcat (tempname,tname); /* Add in file name */
|
||||
|
||||
#ifdef UNIX /* For UNIX, make temp file*/
|
||||
mktemp(tempname);
|
||||
#endif
|
||||
|
||||
arname = *ap++;
|
||||
arfd = openar(arname,rflg);
|
||||
if(i==0 && tflg) {
|
||||
listall();
|
||||
endit();
|
||||
}
|
||||
if(i<=0)
|
||||
goto usage;
|
||||
if( xflg == 0 ) {
|
||||
if((tempfd=creat(tempname,0644,1)) < 0) {
|
||||
error("cannot create %s\n",tempname);
|
||||
endit();
|
||||
}
|
||||
if(write(tempfd,&libmagic,sizeof libmagic) != sizeof libmagic)
|
||||
{
|
||||
error("temp file write error\n");
|
||||
endit();
|
||||
}
|
||||
}
|
||||
while(i) {
|
||||
excom(*ap++);
|
||||
i--;
|
||||
}
|
||||
excom(0L); /*end of arg list*/
|
||||
if (xflg == 0)
|
||||
{
|
||||
k = lseek(tempfd,0L,1); /* Fetch file size */
|
||||
#ifndef UNIX
|
||||
l = lseek(tempfd,0L,0); /* Rewind temp file */
|
||||
if (l < 0) /* Error? */
|
||||
{
|
||||
printf("seek error on %s\n",tempname);
|
||||
exit(-1);
|
||||
}
|
||||
#else
|
||||
close(tempfd);
|
||||
if((tempfd=open(tempname,0,1)) < 0)
|
||||
{
|
||||
printf("Cannot re-open %s\n",tempname);
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
close(arfd); /* Close input file */
|
||||
unlink(arname); /* Delete the file */
|
||||
arfd=creat(arname,0666,1); /* Create the file again*/
|
||||
if(arfd < 0) /* Error? */
|
||||
{
|
||||
printf("Unable to re-create %s -- archive is in %s\n",
|
||||
arname,tempname);
|
||||
exit(-1);
|
||||
}
|
||||
i = 1; /* Klutz */
|
||||
while (i > 0 && k > 0) /* Copy the file back */
|
||||
{
|
||||
i = (k > BLKSIZE) ? BLKSIZE : k;
|
||||
i = read(tempfd,buff,i);
|
||||
if(i < 0)
|
||||
{
|
||||
printf("Read error on %s\n",tempname);
|
||||
exit(-1);
|
||||
}
|
||||
else if (i > 0)
|
||||
{
|
||||
if(write(arfd,buff,i) != i)
|
||||
{
|
||||
printf("Write error on %s\n",arname);
|
||||
exit (-1);
|
||||
}
|
||||
}
|
||||
k -= i;
|
||||
}
|
||||
kk = 0;
|
||||
write(arfd,&kk,sizeof(k)); /* Put 0 on end of file */
|
||||
close (tempfd);
|
||||
unlink(tempname);
|
||||
}
|
||||
endit();
|
||||
}
|
||||
|
||||
openar(arp,crfl)
|
||||
char *arp;
|
||||
{
|
||||
|
||||
register i;
|
||||
int ib;
|
||||
|
||||
if((i=open(arp,2,1)) < 0) { /*does not exist*/
|
||||
areof = 1;
|
||||
if((i = creat(arp,0666,1)) < 0)
|
||||
{
|
||||
printf("Cannot Create %s\n",arname);
|
||||
exit(-1);
|
||||
}
|
||||
else
|
||||
return(i);
|
||||
}
|
||||
if(read(i,&ib,sizeof libmagic) != sizeof libmagic || ib != LIBMAGIC) {
|
||||
notar:
|
||||
error("not archive format: %s\n",arp);
|
||||
endit();
|
||||
}
|
||||
return(i);
|
||||
}
|
||||
|
||||
/* execute one command -- call with filename or 0*/
|
||||
|
||||
excom(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
register char *p;
|
||||
if(p=ap)
|
||||
{
|
||||
if(p[1] == ':') /* CP/M Drive number */
|
||||
p += 2; /* Bump to file name */
|
||||
}
|
||||
if((p) && (matchflg==0)) { /*look thru archive for file name*/
|
||||
while(areof==0 && nextar()) { /*get next ar file header*/
|
||||
if(streq(p,&libhd.l2fname[0]))
|
||||
break;
|
||||
if(psflg && streq(psname,&libhd.l2fname[0])) {
|
||||
break;
|
||||
}
|
||||
skcopy(uflg); /*skip or copy*/
|
||||
}
|
||||
}
|
||||
(*docom)(ap); /*exec requested command*/
|
||||
}
|
||||
|
||||
xtell(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
register char *p;
|
||||
register i;
|
||||
register char *p1;
|
||||
|
||||
if(ap==0)
|
||||
endit();
|
||||
if(vflg) { /*long list*/
|
||||
pmode(libhd.l2fimode);
|
||||
printf(" %d/%d %6ld ",libhd.l2userid,libhd.l2gid,
|
||||
libhd.l2fsize);
|
||||
/* p1 = ctime(&libhd.l2modti);
|
||||
p1[24] = '\0';
|
||||
p1 =+ 4;
|
||||
printf(" %s ",p1); */
|
||||
}
|
||||
pfname();
|
||||
skcopy(0);
|
||||
}
|
||||
|
||||
pfname()
|
||||
{
|
||||
printf("%.14s\n",libhd.l2fname);
|
||||
}
|
||||
|
||||
replace(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
register i;
|
||||
int ifd;
|
||||
register long l;
|
||||
register char *p1;
|
||||
|
||||
if( ap == 0 ) {
|
||||
if( bflg && areof == 0 ) {
|
||||
l = -(sizeof libhd);
|
||||
lseek(arfd,l,1);
|
||||
}
|
||||
cprest();
|
||||
return;
|
||||
}
|
||||
if((ifd=open(ap,0,1)) < 0) {
|
||||
error("cannot open %s\n",ap);
|
||||
endit();
|
||||
}
|
||||
if(areof && psflg) {
|
||||
error("%s not in library\n",psname);
|
||||
endit();
|
||||
}
|
||||
if((bflg|aflg) && matchflg==0) { /*copy archive file before appending*/
|
||||
if(aflg)
|
||||
skcopy(1);
|
||||
matchflg++;
|
||||
}
|
||||
p1 = (ap[1] == ':') ? ap + 2 : ap; /* Drive name */
|
||||
copystr(p1,&libhd.l2fname[0],LNAMLEN);
|
||||
if(areof|aflg) {
|
||||
inform('a');
|
||||
}
|
||||
else if(bflg) {
|
||||
inform('i');
|
||||
}
|
||||
else {
|
||||
inform('r');
|
||||
skcopy(0); /*skip old copy*/
|
||||
}
|
||||
p1 = buff;
|
||||
libhd.l2modti = 0;
|
||||
libhd.l2userid = 0;
|
||||
libhd.l2gid = 0;
|
||||
libhd.l2fimode = 0666;
|
||||
libhd.l2fsize = filesize(&ifd,ap);
|
||||
cp1file(ifd,tempfd,WHDR+OEVEN,ap,tempname);
|
||||
close(ifd);
|
||||
}
|
||||
|
||||
struct iobuf ssbuf={0};
|
||||
long filesize(fdp,fname)
|
||||
int *fdp;
|
||||
char *fname;
|
||||
{
|
||||
struct hdr tcout;
|
||||
register long size;
|
||||
register short *p;
|
||||
register int i;
|
||||
|
||||
close(*fdp);
|
||||
if( fopen(fname,&ssbuf,1) < 0 )
|
||||
error("cannot open %s\n",fname);
|
||||
p = &tcout;
|
||||
for( i = 0; i < (sizeof tcout)/2; i++ )
|
||||
*p++ = getw(&ssbuf);
|
||||
close(ssbuf.fildes);
|
||||
if( tcout.ch_magic != MAGIC )
|
||||
error("not object file: %s\n",fname);
|
||||
size = tcout.ch_tsize + tcout.ch_dsize;
|
||||
if( tcout.ch_rlbflg == 0 )
|
||||
size += size;
|
||||
size += tcout.ch_ssize;
|
||||
if( (*fdp=open(fname,0,1)) < 0 )
|
||||
error("cannot reopen %s\n",fname);
|
||||
size += sizeof tcout;
|
||||
#ifndef UNIX
|
||||
size = ((size+3)/4)*4; /*turkey round-up to long for VAX*/
|
||||
#endif
|
||||
return(size);
|
||||
}
|
||||
|
||||
struct { char byt1; char byt2; char byt3; char byt4; };
|
||||
long fixlong(l)
|
||||
long l;
|
||||
{
|
||||
long tl;
|
||||
|
||||
tl.byt1 = l.byt4;
|
||||
tl.byt2 = l.byt3;
|
||||
tl.byt3 = l.byt2;
|
||||
tl.byt4 = l.byt1;
|
||||
return(tl);
|
||||
}
|
||||
fixshort(i)
|
||||
int i;
|
||||
{
|
||||
int ti;
|
||||
|
||||
ti.byt1 = i.byt2;
|
||||
ti.byt2 = i.byt1;
|
||||
}
|
||||
|
||||
delete(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
if(ap==0) {
|
||||
cprest();
|
||||
return;
|
||||
}
|
||||
inform('d');
|
||||
skcopy(0);
|
||||
}
|
||||
|
||||
extract(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
register ofd;
|
||||
register long l;
|
||||
register i;
|
||||
|
||||
if(ckafile(ap))
|
||||
return;
|
||||
if((ofd=creat(ap,0666)) < 0) {
|
||||
error("cannot create %s\n",ap);
|
||||
endit();
|
||||
}
|
||||
inform('x');
|
||||
cp1file(arfd,ofd,IEVEN,arname,ap);
|
||||
close(ofd);
|
||||
}
|
||||
|
||||
print(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
if(ckafile(ap))
|
||||
return;
|
||||
cp1file(arfd,1,IEVEN,arname,"std output");
|
||||
}
|
||||
|
||||
endit()
|
||||
{
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
/* list all file in the library*/
|
||||
|
||||
listall()
|
||||
{
|
||||
|
||||
while(nextar()) {
|
||||
xtell(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*read next ar file header into libhd*/
|
||||
|
||||
nextar()
|
||||
{
|
||||
|
||||
if( read(arfd,&libhd,sizeof libhd) != sizeof libhd ||
|
||||
libhd.l2fname[0] == '\0' ) {
|
||||
areof++;
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* call with cpflag=0 for skip, cpflag=1 for copy*/
|
||||
skcopy(cpflag)
|
||||
{
|
||||
|
||||
register long l;
|
||||
register int i;
|
||||
|
||||
if(areof)
|
||||
return;
|
||||
l = libhd.l2fsize;
|
||||
if(l&1)
|
||||
l++;
|
||||
if(cpflag) {
|
||||
inform('c');
|
||||
cp1file(arfd,tempfd,WHDR+OEVEN+IEVEN,arname,tempname);
|
||||
}
|
||||
else {
|
||||
if(lseek(arfd,l,1) < 0) {
|
||||
error("seek error on library\n");
|
||||
endit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef JUNK
|
||||
char *mktemp(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
register char *p;
|
||||
register i,j;
|
||||
|
||||
/* i = getpid(); /*process id*/
|
||||
/* p = ap;
|
||||
while(*p)
|
||||
p++;
|
||||
for(j=0; j<5; j++) {
|
||||
*--p = ((i&7) + '0');
|
||||
i =>> 3;
|
||||
}
|
||||
*/ return(ap);
|
||||
}
|
||||
#endif
|
||||
|
||||
streq(s1, s2)
|
||||
char *s1, *s2;
|
||||
{
|
||||
register char *p1, *p2;
|
||||
|
||||
p1 = s1;
|
||||
p2 = s2;
|
||||
while(*p1++ == *p2)
|
||||
if(*p2++ == 0)
|
||||
return(1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int m1[] = { 1, ROWN, 'r', '-' };
|
||||
int m2[] = { 1, WOWN, 'w', '-' };
|
||||
int m3[] = { 1, XOWN, 'x', '-' };
|
||||
int m4[] = { 1, RGRP, 'r', '-' };
|
||||
int m5[] = { 1, WGRP, 'w', '-' };
|
||||
int m6[] = { 1, XGRP, 'x', '-' };
|
||||
int m7[] = { 1, ROTH, 'r', '-' };
|
||||
int m8[] = { 1, WOTH, 'w', '-' };
|
||||
int m9[] = { 1, XOTH, 'x', '-' };
|
||||
|
||||
int *m[] = { m1, m2, m3, m4, m5, m6, m7, m8, m9};
|
||||
|
||||
pmode(aflg1)
|
||||
{
|
||||
register int **mp;
|
||||
|
||||
for (mp = &m[0]; mp < &m[9];)
|
||||
select(*mp++,aflg1);
|
||||
}
|
||||
|
||||
select(pairp,flg)
|
||||
int *pairp;
|
||||
int flg;
|
||||
{
|
||||
register int n, *ap, f;
|
||||
|
||||
ap = pairp;
|
||||
f = flg;
|
||||
n = *ap++;
|
||||
while (--n>=0 && (f&*ap++)==0)
|
||||
ap++;
|
||||
putchar(*ap);
|
||||
}
|
||||
|
||||
inform(cc)
|
||||
char cc;
|
||||
{
|
||||
|
||||
if(vflg) {
|
||||
putchar(cc);
|
||||
putchar(' ');
|
||||
pfname();
|
||||
}
|
||||
}
|
||||
|
||||
copystr(ap1,ap2,alen)
|
||||
char *ap1, *ap2;
|
||||
{
|
||||
|
||||
register char *p1, *p2;
|
||||
register len;
|
||||
|
||||
p1 = ap1;
|
||||
p2 = ap2;
|
||||
len = alen;
|
||||
while(len) {
|
||||
if(!(*p2++ = *p1++))
|
||||
break;
|
||||
len--;
|
||||
}
|
||||
while(--len > 0)
|
||||
*p2++ = '\0';
|
||||
}
|
||||
|
||||
#ifdef JUNK
|
||||
long mklong(ai1,ai2)
|
||||
{
|
||||
|
||||
long l;
|
||||
|
||||
l.hiword = ai1;
|
||||
l.loword = ai2;
|
||||
return(l);
|
||||
}
|
||||
#endif
|
||||
|
||||
cprest()
|
||||
{
|
||||
|
||||
while(areof==0 && nextar())
|
||||
skcopy(1); /*copy rest of library*/
|
||||
}
|
||||
|
||||
cp1file(ifd,ofd,aflags,iname,oname)
|
||||
char *iname, *oname;
|
||||
{
|
||||
|
||||
register i;
|
||||
register int j;
|
||||
register long l;
|
||||
register flags;
|
||||
|
||||
flags = aflags;
|
||||
if(flags&WHDR) {
|
||||
if(write(ofd,&libhd,sizeof libhd) != sizeof libhd) {
|
||||
iwrerr:
|
||||
error("write error on %s\n",oname);
|
||||
endit();
|
||||
}
|
||||
}
|
||||
for( l = libhd.l2fsize; l > BLKSIZE; l -= BLKSIZE ) {
|
||||
if((i=read(ifd,buff,BLKSIZE)) != BLKSIZE) {
|
||||
irderr:
|
||||
error("read error on %s\n",iname);
|
||||
endit();
|
||||
}
|
||||
if(write(ofd,buff,BLKSIZE) != BLKSIZE) {
|
||||
goto iwrerr;
|
||||
}
|
||||
}
|
||||
if( l > 0 ) {
|
||||
i = l;
|
||||
if((j=read(ifd,buff,i)) != i)
|
||||
goto irderr;
|
||||
if(flags&OEVEN) {
|
||||
if(i&1) {
|
||||
buff[i] = '\0';
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if(write(ofd,buff,i) != i)
|
||||
goto iwrerr;
|
||||
}
|
||||
if(flags&IEVEN)
|
||||
if(l&1)
|
||||
read(ifd,buff,1);
|
||||
}
|
||||
|
||||
ckafile(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
if(ap==0)
|
||||
endit();
|
||||
if(areof) {
|
||||
error("%s not in archive file\n",ap);
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
error(x1,x2,x3,x4,x5,x6)
|
||||
int x1, x2, x3, x4, x5, x6;
|
||||
{
|
||||
printf(x1,x2,x3,x4,x5,x6);
|
||||
if( tempfd ) {
|
||||
close(tempfd);
|
||||
unlink(tempname);
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
14
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/cout.h
Normal file
14
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/cout.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#define HDSIZE (sizeof couthd) /**.o file header size*/
|
||||
struct hdr {
|
||||
short ch_magic; /*c.out magic number 060016 = $600E*/
|
||||
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; /*entry point*/
|
||||
short ch_rlbflg; /*relocation bits suppressed flag*/
|
||||
} couthd={0};
|
||||
|
||||
#define MAGIC 0x601a /* bra .+26 instruction*/
|
||||
|
@@ -0,0 +1,42 @@
|
||||
e:vax AR.H r
|
||||
e:vax AR68.C r
|
||||
e:vax BASEPAGE.H r
|
||||
e:vax BDOS.H r
|
||||
e:vax COUT.H r
|
||||
e:vax CPM.H r
|
||||
e:vax CTYPE.H r
|
||||
e:vax DOWN.SUB r
|
||||
e:vax DUMP.C r
|
||||
e:vax ERRNO.H r
|
||||
e:vax FIND.C r
|
||||
e:vax IOBUF.H r
|
||||
e:vax KLIB.H r
|
||||
e:vax LIBFIX.C r
|
||||
e:vax LINK.COM r
|
||||
e:vax LIST.COM r
|
||||
e:vax LO68.C r
|
||||
e:vax LO68.H r
|
||||
e:vax LO68INIT.C r
|
||||
e:vax MACHINE.11 r
|
||||
e:vax MACHINE.68K r
|
||||
e:vax MACHINE.H r
|
||||
e:vax MACHINE.VAX r
|
||||
e:vax MAKE.SUB r
|
||||
e:vax N.C r
|
||||
e:vax NM68.C r
|
||||
e:vax NUXI.C r
|
||||
e:vax PORTAB.H r
|
||||
e:vax PRTOBJ.C r
|
||||
e:vax RELOC.C r
|
||||
e:vax SEND10.SUB r
|
||||
e:vax SENDC68.C r
|
||||
e:vax SENDC68.H r
|
||||
e:vax SETJMP.H r
|
||||
e:vax SGTTY.H r
|
||||
e:vax SIGNAL.H r
|
||||
e:vax SIZE68.C r
|
||||
e:vax STDIO.H r
|
||||
e:vax VMAKE.COM r
|
||||
e:vax VSEND.COM r
|
||||
e:vax XER.COM r
|
||||
|
136
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/dump.c
Normal file
136
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/dump.c
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Kludge hex dump routine for 68K
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <osif.h>
|
||||
#include "machine.h"
|
||||
#include <ctype.h>
|
||||
main(argc,argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
char buffer[128]; /* Sector buffer */
|
||||
int sector; /* Sector number */
|
||||
long filaddr; /* File address */
|
||||
int offset; /* Sector Offset */
|
||||
register i,j,k,l,m; /* Temps. */
|
||||
int fd; /* File descriptor */
|
||||
|
||||
if(argc < 2 || argc > 3) /* Only 1 file, please! */
|
||||
{
|
||||
printf("Usage: dump [-shhhhhh] file\n");
|
||||
exit();
|
||||
}
|
||||
|
||||
i = 1;
|
||||
filaddr= 0; /* Zero file address */
|
||||
if(*argv[1] == '-')
|
||||
{
|
||||
decode(argv[1],&filaddr); /* Get hex file addr */
|
||||
i=2;
|
||||
}
|
||||
|
||||
if((fd=openb(argv[i],READ)) < 0) /* Try to open file */
|
||||
{
|
||||
printf("Unable to open \"%s\"\n",argv[i]);
|
||||
exit();
|
||||
}
|
||||
|
||||
sector = filaddr >> 7; /* Zero sector count */
|
||||
filaddr &= ~15; /* Round request down */
|
||||
lseek(fd,filaddr,0); /* Do the seek */
|
||||
m = (128 - (filaddr & 127)); /* # bytes in sector */
|
||||
while((l=read(fd,buffer,m)) > 0) /* Until EOF */
|
||||
{
|
||||
l = (l + 15) / 16; /* Number of lines */
|
||||
offset = filaddr & 127; /* Starting Offset */
|
||||
for(i=0; i<l; i++) /* 8 lines / sector */
|
||||
{
|
||||
printf("%04x %02x (%06lx): ",sector,offset,filaddr);
|
||||
for(j=0; j<16; j++) /* 16 bytes / line */
|
||||
{
|
||||
#if VAX
|
||||
printf(" %02x%02x",(buffer[i*16+j+1])&0xff,
|
||||
(buffer[i*16+j]&0xff));
|
||||
#endif
|
||||
#if PDP11
|
||||
printf(" %02x%02x",(buffer[i*16+j+1])&0xff,
|
||||
(buffer[i*16+j])&0xff);
|
||||
#endif
|
||||
#if MC68000
|
||||
printf(" %02x%02x",(buffer[i*16+j])&0xff,
|
||||
(buffer[i*16+j+1]&0xff));
|
||||
#endif
|
||||
j++;
|
||||
}
|
||||
printf(" *");
|
||||
for(j=0; j<16; j++) /* Now ASCII */
|
||||
{
|
||||
k = buffer[i*16+j] & 0x7f;
|
||||
if ((k < ' ') || (k == 0x7f)) k= '.';
|
||||
printf("%c",k);
|
||||
}
|
||||
printf("*\n");
|
||||
filaddr += 16; /* Bump up file address*/
|
||||
offset += 16; /* and offset */
|
||||
}
|
||||
sector++; /* Increment sector count*/
|
||||
m = 128; /* # bytes to read next */
|
||||
for(j=0; j<128; j++)
|
||||
buffer[j] = 0;
|
||||
}
|
||||
printf("\n*** E O F ***\n");
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* D e c o d e F u n c t i o n */
|
||||
/* ------------------------------ */
|
||||
/* */
|
||||
/* Routine "decode" is called to process the relocation base argument */
|
||||
/* from the command line. */
|
||||
/* */
|
||||
/* Calling sequence: */
|
||||
/* */
|
||||
/* ret = decode(string,&address); */
|
||||
/* */
|
||||
/* Where: */
|
||||
/* string -> argument string (usually argv[1]) */
|
||||
/* &address -> long word to receive converted value */
|
||||
/* */
|
||||
/* ret = 0 if successful conversion */
|
||||
/* = -1 if anything amiss */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
WORD decode(string,addr) /* */
|
||||
/* */
|
||||
REG BYTE *string; /* -> Command argument */
|
||||
LONG *addr; /* = return value */
|
||||
{ /****************************/
|
||||
REG LONG a; /* Temp return value */
|
||||
REG BYTE c; /* Temp character */
|
||||
/* */
|
||||
if(*string++ != '-' || *string++ != 's')/* Check for valid switch */
|
||||
return(FAILURE); /* quit if NFG */
|
||||
/* */
|
||||
a = 0; /* Zero out accumulator */
|
||||
/* */
|
||||
while(*string) /* Until no more chars */
|
||||
{ /* */
|
||||
c = toupper(*string) & 0177; /* Pick up next char */
|
||||
if (c >= '0' && c <= '9') /* Digit */
|
||||
a = (a << 4) + c - '0'; /* Un-ASCIIfy */
|
||||
else if (c >= 'A' && c <= 'F') /* Hex */
|
||||
a = (a << 4) + c - 'A'+ 10; /* Un-ASCIIfy */
|
||||
else /* Bad character */
|
||||
return(FAILURE); /* So long, sucker!! */
|
||||
string++; /* Increment pointer */
|
||||
} /* */
|
||||
*addr = a; /* Store result */
|
||||
return(SUCCESS); /* Return all ok */
|
||||
} /****************************/
|
||||
|
||||
|
241
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/find.c
Normal file
241
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/find.c
Normal file
@@ -0,0 +1,241 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* C R U N T I M E G R E P R O U T I N E
|
||||
* -------------------------------------------
|
||||
* Copyright 1983 by Digital Research Inc. All rights reserved.
|
||||
*
|
||||
* The routine "grep" searches for an ascii character pattern in
|
||||
* a series of files. "Grep" allows the following options:
|
||||
*
|
||||
* OPTION FUNCTION
|
||||
* ------ --------
|
||||
* -v Print only lines not matching the pattern
|
||||
* -c Print only a count of the lines
|
||||
* -n Print with line numbers
|
||||
* -s Write out the sector number in which the pattern was found
|
||||
* -l Write out a list of the files in which the pattern was found
|
||||
* -y Do not distinguish between upper & lower case
|
||||
*
|
||||
* Calling Sequence:
|
||||
*
|
||||
* grep(options,expression,files);
|
||||
*
|
||||
* Where:
|
||||
*
|
||||
* options Is a pointer to a string of options
|
||||
* expression Is a pointer to the search pattern
|
||||
* files Is an array of pointers to filenames
|
||||
*
|
||||
*****************************************************************************/
|
||||
/****************************/
|
||||
/* INCLUDE FILES */
|
||||
/****************************/
|
||||
#include <stdio.h> /* standard I/O library */
|
||||
#include <portab.h> /* CP/M portability defines */
|
||||
#include <ctype.h> /* char type definitions */
|
||||
/****************************/
|
||||
/* GLOBAL VARIABLES */
|
||||
/****************************/
|
||||
GLOBAL BYTE __match = TRUE; /* Print Matching lines only*/
|
||||
GLOBAL BYTE __count = FALSE; /* Just count the lines */
|
||||
GLOBAL BYTE __num = FALSE; /* Print line #'s */
|
||||
GLOBAL BYTE __sector = FALSE; /* Display the sector */
|
||||
GLOBAL BYTE __list = FALSE; /* Display only a file list */
|
||||
GLOBAL BYTE __nocase = FALSE; /* Distinguish between cases*/
|
||||
GLOBAL FILE *fstream; /* file stream ptr */
|
||||
GLOBAL BYTE line[129]; /* line buffer */
|
||||
GLOBAL BYTE line1[129]; /* Temp line buffer */
|
||||
GLOBAL BYTE first = TRUE; /* used on the list option */
|
||||
GLOBAL UWORD numfound = 0; /* number of lines found */
|
||||
/****************************/
|
||||
/* FUNCTIONS */
|
||||
/****************************/
|
||||
FILE *fopenb(); /* returns a ptr to a file */
|
||||
/****************************/
|
||||
/* MAIN */
|
||||
main(argc,argv) /* Entry point */
|
||||
WORD argc; /* = # args */
|
||||
BYTE **argv; /* -> args */
|
||||
{ /****************************/
|
||||
BYTE *options; /* Option pointer */
|
||||
BYTE *expression; /* -> expression */
|
||||
BYTE **files; /* -> files */
|
||||
/* */
|
||||
if(argc < 2) /* Must have at least 2 */
|
||||
{ /* */
|
||||
usage: printf("Usage: find [-options] pattern files\n");
|
||||
exit(); /* */
|
||||
} /****************************/
|
||||
/* */
|
||||
options = "-ny"; /* Set up option */
|
||||
if(*argv[1] == '-') /* Options specified? */
|
||||
{ /* */
|
||||
options = argv[1]; /* Yes, use them */
|
||||
if(argc < 3) goto usage; /* check for valid args */
|
||||
expression = argv[2]; /* -> Pattern */
|
||||
files = &argv[3]; /* -> file list */
|
||||
} /****************************/
|
||||
else { /* No options */
|
||||
expression = argv[1]; /* Expression */
|
||||
files = &argv[2]; /* file list */
|
||||
} /****************************/
|
||||
return(grep(options,expression,files)); /* Call the real function */
|
||||
} /* */
|
||||
/****************************/
|
||||
grep(options,expression,files) /* */
|
||||
REG BYTE *options; /* option list */
|
||||
REG BYTE *expression; /* pattern to search for */
|
||||
BYTE *files[]; /* array of files */
|
||||
{ /* */
|
||||
REG BYTE *p; /* temp pointer */
|
||||
REG UWORD patt_cnt; /* pattern counter */
|
||||
REG UWORD char_cnt; /* character count */
|
||||
REG UWORD line_cnt; /* line count */
|
||||
REG UWORD i; /* counter */
|
||||
UWORD length; /* length of pattern */
|
||||
BYTE found; /* set if pattern is found */
|
||||
/* */
|
||||
/* */
|
||||
if(*options != '-') /* Legal option list? */
|
||||
{ /* */
|
||||
fprintf(stderr,"FIND--Illegal option list: %s\n",options); /* */
|
||||
exit(-1); /* Just quit */
|
||||
} /****************************/
|
||||
while(*options) /* if found ........ */
|
||||
{ /* */
|
||||
switch(*++options) /* */
|
||||
{ /* */
|
||||
case 'v' : __match = FALSE; /* print non-matching lines */
|
||||
break; /* */
|
||||
case 'c' : __count = TRUE; /* print a count of lines */
|
||||
break; /* */
|
||||
case 'n' : __num = TRUE; /* number the lines */
|
||||
break; /* */
|
||||
case 's' : __sector= TRUE; /* print sector number */
|
||||
break; /* */
|
||||
case 'l' : __list = TRUE; /* list the files */
|
||||
break; /* */
|
||||
case 'y' : __nocase= TRUE; /* no case distinction */
|
||||
/*break;*/ /* */
|
||||
} /* */
|
||||
} /* */
|
||||
/****************************/
|
||||
if(__list) /* list option has priority */
|
||||
{ /* over these..... */
|
||||
__count = FALSE; /* */
|
||||
__num = FALSE; /* */
|
||||
__sector = FALSE; /* */
|
||||
} /* */
|
||||
else /* */
|
||||
if(__count) /* count option has priority*/
|
||||
{ /* over these..... */
|
||||
__num = FALSE; /* */
|
||||
__sector = FALSE; /* */
|
||||
} /* */
|
||||
else /* */
|
||||
if(__num) /* num option has priority */
|
||||
__sector = FALSE; /* over the sector option */
|
||||
if(__nocase) /* if no case destinction */
|
||||
{ /* */
|
||||
p = expression; /* */
|
||||
while(*p) /* change expression to */
|
||||
{ /* */
|
||||
*p = toupper(*p); /* upper case letters */
|
||||
p++; /* */
|
||||
} /* */
|
||||
} /* */
|
||||
length = strlen(expression); /* count the characters in */
|
||||
/* the pattern to match */
|
||||
while(*files) /* search all the files */
|
||||
{ /* */
|
||||
if((fstream = fopenb(*files,"r")) != NULL)/*try to open the file */
|
||||
{ /* */
|
||||
char_cnt = 0; /* initialize char count */
|
||||
line_cnt = 0; /* initialize line # count */
|
||||
numfound = 0; /* initialize # found */
|
||||
first = TRUE; /* initialize for list */
|
||||
if(!__list && !__count) /* if these options are not */
|
||||
{ /* ON then print the file- */
|
||||
printf("\nFILE: %s\n",*files); /* name before each search */
|
||||
printf("----\n"); /* */
|
||||
} /* */
|
||||
while(!feof(fstream)) /* go until end of file */
|
||||
{ /* */
|
||||
found = FALSE; patt_cnt = 0; /* */
|
||||
p = expression; /* */
|
||||
for(i=0;i<129;i++) /* Zap out the buffers */
|
||||
line[i]=line1[i]=0; /* */
|
||||
fgets(line1,129,fstream); /* read a line */
|
||||
/****************************/
|
||||
for(i = 0;line1[i];i++) /* */
|
||||
if(__nocase) /* Translate? */
|
||||
line[i] = toupper(line1[i]);/* */
|
||||
else /* Don't translate */
|
||||
line[i] = line1[i]; /* Just copy */
|
||||
/****************************/
|
||||
i = 0; /* */
|
||||
while(line[i]) /* scan until a NULL */
|
||||
{ /* */
|
||||
char_cnt++; /* bump the char count */
|
||||
if(line[i] == *p) /* check pattern */
|
||||
{ /* */
|
||||
p++; /* look for next char */
|
||||
patt_cnt++; /* we found a character */
|
||||
if(patt_cnt == length) /* Have we found the end ? */
|
||||
{ /* */
|
||||
found = TRUE; /* set a flag */
|
||||
p = expression; /* */
|
||||
patt_cnt = 0; /* */
|
||||
} /* */
|
||||
} /* */
|
||||
else /* */
|
||||
{ /* */
|
||||
p = expression; /* reset the pattern ptr */
|
||||
patt_cnt = 0; /* start the count over */
|
||||
} /* */
|
||||
i++; /* check next character */
|
||||
} /* */
|
||||
line[i-1] = NULL; /* mask out extra LF */
|
||||
line_cnt++; /* bump the line count */
|
||||
prtline(found,char_cnt,line_cnt,files);/*then print routine */
|
||||
} /* */
|
||||
if(__count) /* is count option ON ? */
|
||||
printf("\n%s: %d",*files,numfound);/*print a count of # fnd */
|
||||
} /* */
|
||||
fclose(fstream); /* Close the file */
|
||||
files++; /* go to next file */
|
||||
} /* */
|
||||
} /****************************/
|
||||
/* PRINT ROUTINE */
|
||||
prtline(found,char_cnt,line_cnt,files) /****************************/
|
||||
BYTE found; /* does line contain pattern*/
|
||||
UWORD char_cnt; /* number of chars searched */
|
||||
UWORD line_cnt; /* number of lines searched */
|
||||
BYTE *files[]; /* current file */
|
||||
{ /****************************/
|
||||
if((__match && found) || /* have we a line ? */
|
||||
(!__match && !found)) /* */
|
||||
{ /* */
|
||||
numfound++; /* count the # lines found */
|
||||
if(__count) return; /* nothing to do */
|
||||
if(__list) /* if the list option */
|
||||
{ /* */
|
||||
if(first) /* FIRST pattern found ? */
|
||||
printf("\n%s",*files); /* print the filename */
|
||||
first = FALSE; /* turn off flag */
|
||||
return; /* and return.. */
|
||||
} /* */
|
||||
if(__sector) /* do we print the sector# ?*/
|
||||
{ /* */
|
||||
printf("\n%d",char_cnt/128);/* divide count by 128 */
|
||||
return; /* */
|
||||
} /* */
|
||||
if(__num) /* do we print a line # ? */
|
||||
{ /* */
|
||||
printf("%5d: ",line_cnt); /* */
|
||||
} /* otherwise..... */
|
||||
fputs(line1,stdout); /* just print the line */
|
||||
} /* */
|
||||
} /****************************/
|
||||
|
||||
|
@@ -0,0 +1,6 @@
|
||||
struct iobuf{
|
||||
int fildes;
|
||||
int nunused;
|
||||
char *xfree;
|
||||
char buff[512];
|
||||
};
|
1604
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/lo68.c
Normal file
1604
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/lo68.c
Normal file
File diff suppressed because it is too large
Load Diff
200
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/lo68.h
Normal file
200
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/lo68.h
Normal file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
Copyright 1981
|
||||
Alcyon Corporation
|
||||
8474 Commerce Av.
|
||||
San Diego, Ca. 92121
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <klib.h>
|
||||
#include "machine.h"
|
||||
/* format of a symbol entry in the main table*/
|
||||
|
||||
#define SEEKREL 1 /*relative seek flag*/
|
||||
|
||||
#define SYNAMLEN 8
|
||||
|
||||
struct symtab {
|
||||
char name[SYNAMLEN]; /*symbol name*/
|
||||
short flags; /*bit flags*/
|
||||
long vl1; /*symbol value*/
|
||||
char *tlnk; /*table link*/
|
||||
};
|
||||
|
||||
struct symtab *symptr;
|
||||
#define OSTSIZE 14 /*entry length on object file without tlnk*/
|
||||
|
||||
/* flags for symbols*/
|
||||
# define SYDF 0100000 /*defined*/
|
||||
# define SYEQ 0040000 /*equated*/
|
||||
# define SYGL 0020000 /*global - entry or external*/
|
||||
# define SYER 0010000 /*equated register*/
|
||||
# define SYXR 0004000 /*external reference*/
|
||||
# define SYDA 0002000 /*DATA based relocatable*/
|
||||
# define SYTX 0001000 /*TEXT based relocatable*/
|
||||
# define SYBS 0000400 /*BSS based relocatable*/
|
||||
|
||||
struct irts {
|
||||
char *irle; /*ptr to last entry in chain*/
|
||||
char *irfe; /*ptr to first entry in chain*/
|
||||
};
|
||||
#ifdef VAX
|
||||
struct {
|
||||
short loword;
|
||||
short hiword;
|
||||
};
|
||||
#endif
|
||||
#ifdef PDP11
|
||||
struct {
|
||||
short loword;
|
||||
short hiword;
|
||||
};
|
||||
#endif
|
||||
#ifdef MC68000
|
||||
struct {
|
||||
short hiword;
|
||||
short loword;
|
||||
};
|
||||
#endif
|
||||
/* parameters that define the main table*/
|
||||
#define SZMT 300 /*initial size of the main table*/
|
||||
/*must be large enough to initialize*/
|
||||
#define ICRSZMT 100 /*add to main table when run out*/
|
||||
int cszmt; /*current size of main table*/
|
||||
char *bmte; /*beginning of main table*/
|
||||
char *emte; /*end of main table*/
|
||||
|
||||
/*initial reference table for externals*/
|
||||
# define SZIRT 64
|
||||
char *eirt[SZIRT];
|
||||
char *saveirt[SZIRT];
|
||||
|
||||
/*initial reference table for globals*/
|
||||
char *girt[SZIRT];
|
||||
char *savgirt[SZIRT];
|
||||
|
||||
char **pirt;
|
||||
|
||||
char *lmte; /*last entry in main table*/
|
||||
char *savlmte;
|
||||
|
||||
#define AREGLO 8
|
||||
#define AREGHI 15
|
||||
|
||||
/* relocation bit definitions:*/
|
||||
#define RBMASK 07 /*tells type of relocation*/
|
||||
#define INSABS 7 /*first word of instr -- absolute*/
|
||||
#define DABS 0 /*data word absolute*/
|
||||
#define TRELOC 2 /* TEXT relocatable*/
|
||||
#define DRELOC 1 /* DATA relocatable*/
|
||||
#define BRELOC 3 /* BSS relocatable*/
|
||||
#define EXTVAR 4 /* ref to external variable*/
|
||||
#define LUPPER 5 /* upper word of long*/
|
||||
#define EXTREL 6 /* relative mode on external variable*/
|
||||
|
||||
#define BUFSIZE 512
|
||||
|
||||
struct buf{
|
||||
int fildes;
|
||||
int nunused;
|
||||
char *xfree;
|
||||
char buff[512];
|
||||
};
|
||||
|
||||
struct buf ibuf;
|
||||
struct buf tbuf;
|
||||
struct buf obuf;
|
||||
struct buf rbuf;
|
||||
struct buf rtbuf;
|
||||
struct buf rdbuf;
|
||||
|
||||
int sflag; /*remove symbol table*/
|
||||
|
||||
long textbase;
|
||||
long database;
|
||||
long bssbase;
|
||||
long textsize;
|
||||
long datasize;
|
||||
long bsssize;
|
||||
long stacksize;
|
||||
|
||||
long textstart;
|
||||
long datastart;
|
||||
long bssstart;
|
||||
|
||||
char *ifilname; /*points to name of current input file*/
|
||||
|
||||
#define NFILE 256 /*max # files we can process*/
|
||||
char *fsymp[NFILE]; /*points to first symbol for each .o file*/
|
||||
char **firstsym; /*points to entry in fsymp*/
|
||||
|
||||
int extmatch; /*matched an external in a library entry*/
|
||||
int noload; /*dont load this lib file flag*/
|
||||
|
||||
#define NLIB 16 /*max # libraries to process*/
|
||||
int lbfictr[NLIB]; /*counts files loaded from one library*/
|
||||
int *libfctr; /*points to lbfictr*/
|
||||
long lbfioff[NFILE]; /*each file offset in library*/
|
||||
long *libptr; /*points to lbfioff*/
|
||||
|
||||
#define LIB1MAGIC 0177555
|
||||
#define LIB2MAGIC 0xffffff65
|
||||
#define LIB1HDSIZE 16
|
||||
#define LIB2HDSIZE 26
|
||||
struct libhdr {
|
||||
char l1fname[8];
|
||||
long l1modti;
|
||||
char l1userid;
|
||||
char l1fimode;
|
||||
short l1fsize;
|
||||
};
|
||||
|
||||
struct lib2hdr {
|
||||
char l2fname[14];
|
||||
long l2modti;
|
||||
char l2userid;
|
||||
char l2gid;
|
||||
short l2fimode;
|
||||
long l2fsize;
|
||||
short l2junk;
|
||||
} *lib2hd;
|
||||
|
||||
#define ARMAG "!<arch>\n"
|
||||
#define SARMAG 8
|
||||
|
||||
#define ARFMAG "`\n"
|
||||
|
||||
struct ar_hdr {
|
||||
char ar_name[16];
|
||||
char ar_date[12];
|
||||
char ar_uid[6];
|
||||
char ar_gid[6];
|
||||
char ar_mode[8];
|
||||
char ar_size[10];
|
||||
char ar_fmag[2];
|
||||
} lib3_hdr;
|
||||
|
||||
#define LIB3MAGIC 0x3c21
|
||||
#define LIB3HDSIZE (sizeof lib3_hdr)
|
||||
|
||||
int libhdsize;
|
||||
long libhd[20]; /*length is max lib head size*/
|
||||
|
||||
int undflg;
|
||||
char dafnc;
|
||||
int pass2;
|
||||
long stlen;
|
||||
int Xflag;
|
||||
int Dflag;
|
||||
int Bflag;
|
||||
int Zflag;
|
||||
|
||||
|
||||
struct symtab *etextptr;
|
||||
struct symtab *edataptr;
|
||||
struct symtab *endptr;
|
||||
char *lastdup;
|
||||
|
||||
char rtfnc;
|
||||
char rdfnc;
|
||||
int saverbits;
|
||||
|
186
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/lo68init.c
Normal file
186
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/lo68init.c
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
Copyright 1981
|
||||
Alcyon Corporation
|
||||
8474 Commerce Av.
|
||||
San Diego, Ca. 92121
|
||||
*/
|
||||
|
||||
/* format of a symbol entry in the main table*/
|
||||
|
||||
#define SEEKREL 1 /*relative seek flag*/
|
||||
|
||||
#define SYNAMLEN 8
|
||||
|
||||
struct symtab {
|
||||
char name[SYNAMLEN]; /*symbol name*/
|
||||
short flags; /*bit flags*/
|
||||
long vl1; /*symbol value*/
|
||||
char *tlnk; /*table link*/
|
||||
};
|
||||
|
||||
struct symtab *symptr =0;
|
||||
#define OSTSIZE 14
|
||||
/*entry length on object file without tlnk*/
|
||||
|
||||
/* flags for symbols*/
|
||||
# define SYDF 0100000 /*defined*/
|
||||
# define SYEQ 0040000 /*equated*/
|
||||
# define SYGL 0020000 /*global - entry or external*/
|
||||
# define SYER 0010000 /*equated register*/
|
||||
# define SYXR 0004000 /*external reference*/
|
||||
# define SYDA 0002000 /*DATA based relocatable*/
|
||||
# define SYTX 0001000 /*TEXT based relocatable*/
|
||||
# define SYBS 0000400 /*BSS based relocatable*/
|
||||
|
||||
struct irts {
|
||||
char *irle; /*ptr to last entry in chain*/
|
||||
char *irfe; /*ptr to first entry in chain*/
|
||||
};
|
||||
|
||||
struct {
|
||||
short loword;
|
||||
short hiword;
|
||||
};
|
||||
|
||||
/* parameters that define the main table*/
|
||||
#define SZMT 300 /*initial size of the main table*/
|
||||
/*must be large enough to initialize*/
|
||||
#define ICRSZMT 100 /*add to main table when run out*/
|
||||
int cszmt =0;
|
||||
char *bmte =0;
|
||||
char *emte =0;
|
||||
|
||||
/*initial reference table for externals*/
|
||||
# define SZIRT 64
|
||||
char *eirt[SZIRT] ={0};
|
||||
char *saveirt[SZIRT] ={0};
|
||||
|
||||
/*initial reference table for globals*/
|
||||
char *girt[SZIRT] ={0};
|
||||
char *savgirt[SZIRT] ={0};
|
||||
|
||||
char **pirt =0;
|
||||
|
||||
char *lmte =0;
|
||||
char *savlmte =0;
|
||||
|
||||
#define AREGLO 8
|
||||
#define AREGHI 15
|
||||
|
||||
/* relocation bit definitions:*/
|
||||
#define RBMASK 07 /*tells type of relocation*/
|
||||
#define INSABS 7 /*first word of instr -- absolute*/
|
||||
#define DABS 0 /*data word absolute*/
|
||||
#define TRELOC 2 /* TEXT relocatable*/
|
||||
#define DRELOC 1 /* DATA relocatable*/
|
||||
#define BRELOC 3 /* BSS relocatable*/
|
||||
#define EXTVAR 4 /* ref to external variable*/
|
||||
#define LUPPER 5 /* upper word of long*/
|
||||
#define EXTREL 6 /* relative mode on external variable*/
|
||||
|
||||
#define BUFSIZE 512
|
||||
|
||||
struct buf{
|
||||
int fildes;
|
||||
int nunused;
|
||||
char *xfree;
|
||||
char buff[512];
|
||||
};
|
||||
|
||||
struct buf ibuf ={0};
|
||||
struct buf tbuf ={0};
|
||||
struct buf obuf ={0};
|
||||
struct buf rbuf ={0};
|
||||
struct buf rtbuf ={0};
|
||||
struct buf rdbuf ={0};
|
||||
|
||||
int sflag =0;
|
||||
|
||||
long textbase =0;
|
||||
long database =0;
|
||||
long bssbase =0;
|
||||
long textsize =0;
|
||||
long datasize=0;
|
||||
long bsssize =0;
|
||||
long stacksize =0;
|
||||
|
||||
long textstart =0;
|
||||
long datastart =0;
|
||||
long bssstart =0;
|
||||
|
||||
char *ifilname =0;
|
||||
|
||||
#define NFILE 256 /*max # files we can process*/
|
||||
char *fsymp[NFILE] ={0};
|
||||
char **firstsym =0;
|
||||
|
||||
int extmatch =0;
|
||||
int noload =0;
|
||||
|
||||
#define NLIB 16 /*max # libraries to process*/
|
||||
int lbfictr[NLIB] ={0};
|
||||
int *libfctr =0;
|
||||
long lbfioff[NFILE] ={0};
|
||||
long *libptr =0;
|
||||
|
||||
#define LIB1MAGIC 0177555
|
||||
#define LIB2MAGIC 0177545
|
||||
#define LIB1HDSIZE 16
|
||||
#define LIB2HDSIZE 26
|
||||
struct libhdr {
|
||||
char l1fname[8];
|
||||
long l1modti;
|
||||
char l1userid;
|
||||
char l1fimode;
|
||||
int l1fsize;
|
||||
};
|
||||
|
||||
struct lib2hdr {
|
||||
char l2fname[14];
|
||||
long l2modti;
|
||||
char l2userid;
|
||||
char l2gid;
|
||||
int l2fimode;
|
||||
long l2fsize;
|
||||
};
|
||||
|
||||
#define ARMAG "!<arch>\n"
|
||||
#define SARMAG 8
|
||||
|
||||
#define ARFMAG "`\n"
|
||||
|
||||
struct ar_hdr {
|
||||
char ar_name[16];
|
||||
char ar_date[12];
|
||||
char ar_uid[6];
|
||||
char ar_gid[6];
|
||||
char ar_mode[8];
|
||||
char ar_size[10];
|
||||
char ar_fmag[2];
|
||||
} lib3_hdr ={0};
|
||||
|
||||
#define LIB3MAGIC 0x3c21
|
||||
#define LIB3HDSIZE (sizeof lib3_hdr)
|
||||
|
||||
int libhdsize =0;
|
||||
long libhd[20] ={0};
|
||||
|
||||
int undflg =0;
|
||||
char dafnc =0;
|
||||
int pass2 =0;
|
||||
long stlen =0;
|
||||
int Xflag =0;
|
||||
int Dflag =0;
|
||||
int Bflag =0;
|
||||
int Zflag =0;
|
||||
|
||||
|
||||
struct symtab *etextptr =0;
|
||||
struct symtab *edataptr =0;
|
||||
struct symtab *endptr =0;
|
||||
char *lastdup =0;
|
||||
|
||||
char rtfnc =0;
|
||||
char rdfnc =0;
|
||||
int saverbits =0;
|
||||
|
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Use this file to determine what kind of machine you want the
|
||||
* Alcyon stuff to run on ....
|
||||
*/
|
||||
/*#define MC68000 1*/ /* 68000 version */
|
||||
/*#define VAX 1*/ /* VAX Version */
|
||||
#define PDP11 1 /* PDP-11 Version*/
|
||||
/*#define CPM 1*/ /* CP/M Operating System*/
|
||||
#define UNIX 1 /* UNIX Operating System*/
|
||||
/*#define VMS 1*/ /* VMS Operating System*/
|
||||
|
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Use this file to determine what kind of machine you want the
|
||||
* Alcyon stuff to run on ....
|
||||
*/
|
||||
#define MC68000 1 /* 68000 version */
|
||||
/*#define VAX 1*/ /* VAX Version */
|
||||
/*#define PDP11 1*/ /* PDP-11 Version*/
|
||||
#define CPM 1 /* CP/M Operating System*/
|
||||
/*#define UNIX 1*/ /* UNIX Operating System*/
|
||||
/*#define VMS 1*/ /* VMS Operating System*/
|
||||
|
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Use this file to determine what kind of machine you want the
|
||||
* Alcyon stuff to run on ....
|
||||
*/
|
||||
#define MC68000 1 /* 68000 version */
|
||||
/*#define VAX 1*/ /* VAX Version */
|
||||
/*#define PDP11 1*/ /* PDP-11 Version*/
|
||||
#define CPM 1 /* CP/M Operating System*/
|
||||
/*#define UNIX 1*/ /* UNIX Operating System*/
|
||||
/*#define VMS 1*/ /* VMS Operating System*/
|
||||
|
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Use this file to determine what kind of machine you want the
|
||||
* Alcyon stuff to run on ....
|
||||
*/
|
||||
/*#define MC68000 1*/ /* 68000 version */
|
||||
#define VAX 1 /* VAX Version */
|
||||
/*#define PDP11 1*/ /* PDP-11 Version*/
|
||||
/*#define CPM 1*/ /* CP/M Operating System*/
|
||||
/*#define UNIX 1*/ /* UNIX Operating System*/
|
||||
#define VMS 1 /* VMS Operating System*/
|
||||
|
@@ -0,0 +1,95 @@
|
||||
$2pip machine.h=machine.68k
|
||||
|
||||
$2cp68 -i 0$1 ar68.c $1x.i
|
||||
$2c068 $1x.i $1x.1 $1x.2 $1x.3 -f
|
||||
era $1x.i
|
||||
$2c168 $1x.1 $1x.2 ar68.s
|
||||
era $1x.1
|
||||
era $1x.2
|
||||
$2as68 -s 0$1 -f $1 -l -u ar68.s
|
||||
era ar68.s
|
||||
|
||||
$2cp68 -i 0$1 lo68.c $1x.i
|
||||
$2c068 $1x.i $1x.1 $1x.2 $1x.3 -f
|
||||
era $1x.i
|
||||
$2c168 $1x.1 $1x.2 lo68.s
|
||||
era $1x.1
|
||||
era $1x.2
|
||||
$2as68 -s 0$1 -f $1 -l -u lo68.s
|
||||
era lo68.s
|
||||
|
||||
$2cp68 -i 0$1 dump.c $1x.i
|
||||
$2c068 $1x.i $1x.1 $1x.2 $1x.3 -f
|
||||
era $1x.i
|
||||
$2c168 $1x.1 $1x.2 dump.s
|
||||
era $1x.1
|
||||
era $1x.2
|
||||
$2as68 -s 0$1 -f $1 -l -u dump.s
|
||||
era dump.s
|
||||
|
||||
$2cp68 -i 0$1 nm68.c $1x.i
|
||||
$2c068 $1x.i $1x.1 $1x.2 $1x.3 -f
|
||||
era $1x.i
|
||||
$2c168 $1x.1 $1x.2 nm68.s
|
||||
era $1x.1
|
||||
era $1x.2
|
||||
$2as68 -s 0$1 -f $1 -l -u nm68.s
|
||||
era nm68.s
|
||||
|
||||
$2cp68 -i 0$1 prtobj.c $1x.i
|
||||
$2c068 $1x.i $1x.1 $1x.2 $1x.3 -f
|
||||
era $1x.i
|
||||
$2c168 $1x.1 $1x.2 prtobj.s
|
||||
era $1x.1
|
||||
era $1x.2
|
||||
$2as68 -s 0$1 -f $1 -l -u prtobj.s
|
||||
era prtobj.s
|
||||
|
||||
$2cp68 -i 0$1 reloc.c $1x.i
|
||||
$2c068 $1x.i $1x.1 $1x.2 $1x.3 -f
|
||||
era $1x.i
|
||||
$2c168 $1x.1 $1x.2 reloc.s
|
||||
era $1x.1
|
||||
era $1x.2
|
||||
$2as68 -s 0$1 -f $1 -l -u reloc.s
|
||||
era reloc.s
|
||||
|
||||
$2cp68 -i 0$1 sendc68.c $1x.i
|
||||
$2c068 $1x.i $1x.1 $1x.2 $1x.3 -f
|
||||
era $1x.i
|
||||
$2c168 $1x.1 $1x.2 sendc68.s
|
||||
era $1x.1
|
||||
era $1x.2
|
||||
$2as68 -s 0$1 -f $1 -l -u sendc68.s
|
||||
era sendc68.s
|
||||
|
||||
$2cp68 -i 0$1 size68.c $1x.i
|
||||
$2c068 $1x.i $1x.1 $1x.2 $1x.3 -f
|
||||
era $1x.i
|
||||
$2c168 $1x.1 $1x.2 size68.s
|
||||
era $1x.1
|
||||
era $1x.2
|
||||
$2as68 -s 0$1 -f $1 -l -u size68.s
|
||||
era size68.s
|
||||
|
||||
$2cp68 -i 0$1 find.c $1x.i
|
||||
$2c068 $1x.i $1x.1 $1x.2 $1x.3 -f
|
||||
era $1x.i
|
||||
$2c168 $1x.1 $1x.2 find.s
|
||||
era $1x.1
|
||||
era $1x.2
|
||||
$2as68 -s 0$1 -f $1 -l -u find.s
|
||||
era find.s
|
||||
|
||||
|
||||
$2lo68 -s -f $1 -r -u_nofloat -s -o lo68.rel 0$1s.o lo68.o 0$2klib 0$2clib
|
||||
$2lo68 -s -f $1 -r -u_nofloat -s -o ar68.rel 0$1s.o ar68.o 0$2klib 0$2clib
|
||||
$2lo68 -s -f $1 -r -u_nofloat -s -o dump.rel 0$1s.o dump.o 0$2clib
|
||||
$2lo68 -s -f $1 -r -u_nofloat -s -o nm68.rel 0$1s.o nm68.o 0$2klib 0$2clib
|
||||
$2lo68 -s -f $1 -r -u_nofloat -s -o prtobj.rel 0$1s.o prtobj.o 0$2klib 0$2clib
|
||||
$2lo68 -s -f $1 -r -u_nofloat -s -o reloc.rel 0$1s.o reloc.o 0$2clib
|
||||
$2lo68 -s -f $1 -r -u_nofloat -s -o sendc68.rel 0$1s.o sendc68.o 0$2klib 0$2clib
|
||||
$2lo68 -s -f $1 -r -u_nofloat -s -o size68.rel 0$1s.o size68.o 0$2klib 0$2clib
|
||||
$2lo68 -s -f $1 -r -u_nofloat -s -o find.rel 0$1s.o find.o 0$2clib
|
||||
era *.o
|
||||
user 11!make $1 $2
|
115
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/n.c
Normal file
115
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/n.c
Normal file
@@ -0,0 +1,115 @@
|
||||
#include "cout.h"
|
||||
#include "sendc68.h"
|
||||
|
||||
#define MAGIC1 MAGIC+1
|
||||
int hdsize=0;
|
||||
|
||||
int loctr=0;
|
||||
int pflg=0;
|
||||
int syno=0;
|
||||
int symflg;
|
||||
extern int fout;
|
||||
long lseek();
|
||||
main(argc,argv)
|
||||
char **argv;
|
||||
{
|
||||
|
||||
long l,l1;
|
||||
register i,j,k;
|
||||
|
||||
if(argc<2) {
|
||||
printf("Usage: nm68 objectfile\n");
|
||||
exit();
|
||||
}
|
||||
hdsize = HDSIZE;
|
||||
fout = dup(1);
|
||||
i = 1;
|
||||
openfile(argv[i]);
|
||||
l = couthd.ch_tsize+couthd.ch_dsize+hdsize;
|
||||
lseek(ibuf.fildes,l,0);
|
||||
ibuf.nunused = 0;
|
||||
l1 = couthd.ch_ssize;
|
||||
syno = 0;
|
||||
while(l1) {
|
||||
syno++;
|
||||
for(i=0; i<8; i++) /* Print Symbol name*/
|
||||
{
|
||||
k = getc(&ibuf) & 0377;
|
||||
if (k < ' ') k = ' '; /* Filter ctrl chars*/
|
||||
putchar(k);
|
||||
}
|
||||
putchar((char)'\t');
|
||||
j = getw(&ibuf); /*flags*/
|
||||
l.hiword = getw(&ibuf);
|
||||
l.loword = getw(&ibuf);
|
||||
printf("%8lx",l);
|
||||
prtflags(j);
|
||||
l1 -= OSTSIZE;
|
||||
}
|
||||
myflush();
|
||||
}
|
||||
|
||||
prtflags(af)
|
||||
{
|
||||
|
||||
register f;
|
||||
|
||||
f = af;
|
||||
if(f&SYEQ)
|
||||
printf(" equ");
|
||||
if(f&SYGL)
|
||||
printf(" global");
|
||||
if(f&SYER)
|
||||
printf(" reg");
|
||||
if(f&SYXR)
|
||||
printf(" external");
|
||||
if(f&SYDA)
|
||||
printf(" data");
|
||||
else if(f&SYTX)
|
||||
printf(" text");
|
||||
else if(f&SYBS)
|
||||
printf(" bss");
|
||||
else
|
||||
printf(" abs");
|
||||
putchar((char)'\n');
|
||||
}
|
||||
openfile(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
register char *p;
|
||||
|
||||
p = ap;
|
||||
if((ibuf.fildes=fopen(p,&ibuf,1)) < 0) {
|
||||
printf("unable to open %s\n",p);
|
||||
exit();
|
||||
}
|
||||
ifilname = p; /*point to current file name for error msgs*/
|
||||
if(read(ibuf.fildes,&couthd,2) != 2) {
|
||||
printf("read error on file: %s\n",ifilname);
|
||||
exit();
|
||||
}
|
||||
ibuf.nunused = 0;
|
||||
lseek(ibuf.fildes,0L,0);
|
||||
readhdr(); /*read file header*/
|
||||
}
|
||||
readhdr()
|
||||
{
|
||||
|
||||
register int i;
|
||||
register short *p;
|
||||
|
||||
p = &couthd;
|
||||
for(i=0; i<HDSIZE/2; i++)
|
||||
*p++ = getw(&ibuf);
|
||||
if(couthd.ch_magic != MAGIC) {
|
||||
if(couthd.ch_magic==MAGIC1) {
|
||||
hdsize =+ 8;
|
||||
}
|
||||
else {
|
||||
printf("file format error: %s\n",ifilname);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
117
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/nm68.c
Normal file
117
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/nm68.c
Normal file
@@ -0,0 +1,117 @@
|
||||
#include <stdio.h>
|
||||
#include <klib.h>
|
||||
#include "cout.h"
|
||||
#include "sendc68.h"
|
||||
|
||||
#define MAGIC1 MAGIC+1
|
||||
int hdsize=0;
|
||||
|
||||
int loctr=0;
|
||||
int pflg=0;
|
||||
int syno=0;
|
||||
int symflg;
|
||||
extern int fout;
|
||||
long lseek();
|
||||
main(argc,argv)
|
||||
char **argv;
|
||||
{
|
||||
|
||||
long l,l1;
|
||||
register i,j,k;
|
||||
|
||||
if(argc<2) {
|
||||
printf("Usage: nm68 objectfile\n");
|
||||
exit();
|
||||
}
|
||||
hdsize = HDSIZE;
|
||||
fout = dup(1);
|
||||
i = 1;
|
||||
openfile(argv[i]);
|
||||
l = couthd.ch_tsize+couthd.ch_dsize+hdsize;
|
||||
lseek(ibuf.fildes,l,0);
|
||||
ibuf.nunused = 0;
|
||||
l1 = couthd.ch_ssize;
|
||||
syno = 0;
|
||||
while(l1) {
|
||||
syno++;
|
||||
for(i=0; i<8; i++) /* Print Symbol name*/
|
||||
{
|
||||
k = getc(&ibuf) & 0377;
|
||||
if (k < ' ') k = ' '; /* Filter ctrl chars*/
|
||||
putchar(k);
|
||||
}
|
||||
putchar((char)'\t');
|
||||
j = getw(&ibuf); /*flags*/
|
||||
l.hiword = getw(&ibuf);
|
||||
l.loword = getw(&ibuf);
|
||||
printf("%8lx",l);
|
||||
prtflags(j);
|
||||
l1 -= OSTSIZE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
prtflags(af)
|
||||
{
|
||||
|
||||
register f;
|
||||
|
||||
f = af;
|
||||
if(f&SYEQ)
|
||||
printf(" equ");
|
||||
if(f&SYGL)
|
||||
printf(" global");
|
||||
if(f&SYER)
|
||||
printf(" reg");
|
||||
if(f&SYXR)
|
||||
printf(" external");
|
||||
if(f&SYDA)
|
||||
printf(" data");
|
||||
else if(f&SYTX)
|
||||
printf(" text");
|
||||
else if(f&SYBS)
|
||||
printf(" bss");
|
||||
else
|
||||
printf(" abs");
|
||||
putchar((char)'\n');
|
||||
}
|
||||
openfile(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
register char *p;
|
||||
|
||||
p = ap;
|
||||
if((ibuf.fildes=fopen(p,&ibuf,1)) < 0) {
|
||||
printf("unable to open %s\n",p);
|
||||
exit();
|
||||
}
|
||||
ifilname = p; /*point to current file name for error msgs*/
|
||||
if(read(ibuf.fildes,&couthd,2) != 2) {
|
||||
printf("read error on file: %s\n",ifilname);
|
||||
exit();
|
||||
}
|
||||
ibuf.nunused = 0;
|
||||
lseek(ibuf.fildes,0L,0);
|
||||
readhdr(); /*read file header*/
|
||||
}
|
||||
readhdr()
|
||||
{
|
||||
|
||||
register int i;
|
||||
register short *p;
|
||||
|
||||
p = &couthd;
|
||||
for(i=0; i<HDSIZE/2; i++)
|
||||
*p++ = getw(&ibuf);
|
||||
if(couthd.ch_magic != MAGIC) {
|
||||
if(couthd.ch_magic==MAGIC1) {
|
||||
hdsize =+ 8;
|
||||
}
|
||||
else {
|
||||
printf("file format error: %s\n",ifilname);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
77
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/nuxi.c
Normal file
77
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/nuxi.c
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "cout.h"
|
||||
long lseek();
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
register i,j,c,d;
|
||||
long symseek; /* Symbol table seek addr */
|
||||
int symlength; /* Symbol length (bytes) */
|
||||
char symbuf[30000]; /* Symbol table buffer */
|
||||
int fd; /* File descriptor */
|
||||
|
||||
if((fd=open(argv[1],2,1)) < 0) /* Open input file */
|
||||
{
|
||||
printf("Cannot open %s\n",argv[1]); /* Can't */
|
||||
exit(); /* Just quit */
|
||||
} /****************************/
|
||||
|
||||
if((i=read(fd,&couthd,HDSIZE)) != HDSIZE) /* Read file header */
|
||||
{ /* Can't */
|
||||
printf("Header read error\n"); /* Print message */
|
||||
exit(); /* Then quit */
|
||||
} /****************************/
|
||||
|
||||
symseek=couthd.ch_tsize+couthd.ch_dsize+HDSIZE;
|
||||
if(couthd.ch_magic != MAGIC)
|
||||
{
|
||||
if(couthd.ch_magic == (MAGIC+1))
|
||||
{
|
||||
symseek += 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("File format error\n");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
symlength = lseek(fd,symseek,0); /* Seek to sym begin */
|
||||
if(symlength != symseek) /* OK? */
|
||||
{
|
||||
printf("Seek error\n"); /*No, quit */
|
||||
exit(); /* */
|
||||
}
|
||||
|
||||
symlength = couthd.ch_ssize; /* Fetch symbol length */
|
||||
|
||||
if(read(fd,&symbuf[0],symlength) != symlength)
|
||||
{
|
||||
printf("Symbol table read error\n");
|
||||
}
|
||||
|
||||
for(i=0; i < symlength; i+=14)
|
||||
{
|
||||
for(j=0; j < 8; j+=2)
|
||||
{
|
||||
c = symbuf[j+i];
|
||||
d = symbuf[j+i+1];
|
||||
symbuf[j+i] = d;
|
||||
symbuf[j+i+1] = c;
|
||||
}
|
||||
}
|
||||
|
||||
if(lseek(fd,symseek,0) != symseek)
|
||||
{
|
||||
printf("Seek error\n");
|
||||
exit();
|
||||
}
|
||||
if(write(fd,&symbuf[0],symlength) != symlength)
|
||||
{
|
||||
printf("Symbol table write error\n");
|
||||
exit();
|
||||
}
|
||||
close(fd);
|
||||
exit(0);
|
||||
}
|
||||
|
183
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/prtobj.c
Normal file
183
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/prtobj.c
Normal file
@@ -0,0 +1,183 @@
|
||||
#include "cout.h"
|
||||
#include "lo68.h"
|
||||
#define LIBMAGIC 0177545
|
||||
int loctr=0;
|
||||
int pflg=0;
|
||||
int syno=0;
|
||||
int symflg=0;
|
||||
extern int fout;
|
||||
|
||||
char *reloc[] {
|
||||
"DABS",
|
||||
"DRELOC",
|
||||
"TRELOC",
|
||||
"BRELOC",
|
||||
"EXTVAR",
|
||||
"LUPPER",
|
||||
"NOTUSED",
|
||||
"INSABS" };
|
||||
|
||||
long lseek();
|
||||
|
||||
main(argc,argv)
|
||||
char **argv;
|
||||
{
|
||||
|
||||
long l,l1;
|
||||
register i,j;
|
||||
|
||||
if(argc<2) {
|
||||
printf("Usage: prtobj [-] objectfile\n");
|
||||
exit();
|
||||
}
|
||||
fout = dup(1);
|
||||
i = 1;
|
||||
if(*argv[1] == '-') {
|
||||
i++;
|
||||
symflg++;
|
||||
}
|
||||
pass2 = 1;
|
||||
openfile(argv[i]);
|
||||
if(couthd.ch_rlbflg == 0) { /*relocation bits there*/
|
||||
l = couthd.ch_tsize+couthd.ch_dsize+couthd.ch_ssize+HDSIZE; /*ptr to relocation bits*/
|
||||
longseek(l,&rbuf,0);
|
||||
}
|
||||
printf("file name: %s\n",argv[i]);
|
||||
l = couthd.ch_tsize;
|
||||
printf("text size = %9ld = %08lx hex\n",l,l);
|
||||
l = couthd.ch_dsize;
|
||||
printf("data size = %9ld = %08lx hex\n",l,l);
|
||||
l = couthd.ch_bsize;
|
||||
printf("bss size = %9ld = %08lx hex\n",l,l);
|
||||
l = couthd.ch_ssize;
|
||||
printf("symbol size = %9ld = %08lx hex\n",l,l);
|
||||
l = couthd.ch_stksize;
|
||||
printf("stack size = %9ld = %08lx hex\n",l,l);
|
||||
loctr = couthd.ch_entry;
|
||||
printf("entry point = %9ld = %08lx hex\n",loctr,loctr);
|
||||
if(symflg) {
|
||||
l = couthd.ch_tsize+couthd.ch_dsize+HDSIZE;
|
||||
longseek(l,&ibuf,0);
|
||||
goto dosyms;
|
||||
}
|
||||
l1 = couthd.ch_tsize;
|
||||
printf("TEXT:\n");
|
||||
mloop:
|
||||
for(l=0; l<l1; l=+ 2) {
|
||||
i = getw(&ibuf);
|
||||
if(couthd.ch_rlbflg==0)
|
||||
j = getw(&rbuf);
|
||||
else
|
||||
j = DABS;
|
||||
printf("%08x %04x %s",loctr,((int)i)&0xffff,reloc[j&7]);
|
||||
if((j&7) == EXTVAR)
|
||||
printf(" ext# %5d\n",(j>>3)&017777);
|
||||
else
|
||||
putchar('\n');
|
||||
loctr =+ 2;
|
||||
}
|
||||
if(pflg==0) {
|
||||
printf("\nDATA:\n");
|
||||
l1 = couthd.ch_dsize;
|
||||
pflg++;
|
||||
goto mloop;
|
||||
}
|
||||
dosyms:
|
||||
printf("\nSYMBOLS:\n");
|
||||
l1 = couthd.ch_ssize;
|
||||
syno = 0;
|
||||
while(l1) {
|
||||
printf("%4d ",syno);
|
||||
syno++;
|
||||
for(i=0; i<8; i++)
|
||||
putchar((int)getc(&ibuf)); /*symbol name*/
|
||||
putchar((int)'\t');
|
||||
j = getw(&ibuf); /*flags*/
|
||||
l.hiword = getw(&ibuf);
|
||||
l.loword = getw(&ibuf);
|
||||
printf("%04x%04x",((int)l.hiword)&0xffff,
|
||||
((int)l.loword)&0xffff);
|
||||
prtflags(j);
|
||||
l1 =- OSTSIZE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
prtflags(af)
|
||||
{
|
||||
|
||||
register f;
|
||||
|
||||
f = af;
|
||||
if(f&SYEQ)
|
||||
printf(" equ");
|
||||
if(f&SYGL)
|
||||
printf(" global");
|
||||
if(f&SYER)
|
||||
printf(" equreg");
|
||||
if(f&SYXR)
|
||||
printf(" external");
|
||||
if(f&SYDA)
|
||||
printf(" data");
|
||||
else if(f&SYTX)
|
||||
printf(" text");
|
||||
else if(f&SYBS)
|
||||
printf(" bss");
|
||||
else
|
||||
printf(" abs");
|
||||
putchar((int)'\n');
|
||||
}
|
||||
openfile(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
register char *p;
|
||||
|
||||
p = ap;
|
||||
if((ibuf.fildes=open(p,0,1)) < 0) {
|
||||
printf("unable to open %s\n",p);
|
||||
exit();
|
||||
}
|
||||
ifilname = p; /*point to current file name for error msgs*/
|
||||
if(read(ibuf.fildes,&couthd,2) != 2) {
|
||||
printf("read error on file: %s\n",ifilname);
|
||||
exit();
|
||||
}
|
||||
ibuf.nunused = 0;
|
||||
if(couthd.ch_magic != LIBMAGIC) {
|
||||
lseek(ibuf.fildes,0L,0);
|
||||
readhdr(); /*read file header*/
|
||||
}
|
||||
if(pass2) { /*need file descrptr for reloc bits*/
|
||||
rbuf.fildes = open(p,0,1);
|
||||
rbuf.nunused = 0;
|
||||
}
|
||||
}
|
||||
|
||||
readhdr()
|
||||
{
|
||||
|
||||
register int i;
|
||||
register short *p;
|
||||
|
||||
p = &couthd;
|
||||
for(i=0; i<HDSIZE/2; i++)
|
||||
*p++ = getw(&ibuf);
|
||||
if(couthd.ch_magic != MAGIC) {
|
||||
printf("file format error: %s\n",ifilname);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
longseek(al,bp,pn)
|
||||
long al;
|
||||
struct buf *bp;
|
||||
{
|
||||
long lseek();
|
||||
|
||||
if(lseek(bp->fildes,al,pn) < 0)
|
||||
{
|
||||
printf("Seek error on %s\n",ifilname);
|
||||
exit();
|
||||
}
|
||||
bp->nunused = 0; /*input buff empty*/
|
||||
}
|
435
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/reloc.c
Normal file
435
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/reloc.c
Normal file
@@ -0,0 +1,435 @@
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* R e l o c P r o g r a m */
|
||||
/* ------------------------- */
|
||||
/* */
|
||||
/* This program is used to relocate an Alcyon format load module into */
|
||||
/* an absolute module using the minimum disk space possible. The */
|
||||
/* relocation information, symbol table, and trailing zeros in the */
|
||||
/* data segment are deleted. */
|
||||
/* */
|
||||
/* Invokation: */
|
||||
/* */
|
||||
/* A>reloc -bhhhhhh in.68k out.68k */
|
||||
/* */
|
||||
/* Where: */
|
||||
/* hhhhhh Is the desired new base address (TPA + 100) in hex */
|
||||
/* in.68k Is the input file */
|
||||
/* out.68k Is the output file */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* The following code defines the organization of a "long" variable on */
|
||||
/* either the VAX (11) or 68000. This allows us to use "getw" on the */
|
||||
/* separate parts of the long and to recombine them for 32-bit */
|
||||
/* arithmetic operations. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
#include "machine.h"
|
||||
#ifdef UNIX
|
||||
#include <portab.h>
|
||||
#endif
|
||||
|
||||
#ifdef VAX /****************************/
|
||||
struct { /* low word first on VAX */
|
||||
WORD loword; /* */
|
||||
WORD hiword; /* */
|
||||
}; /****************************/
|
||||
#endif
|
||||
|
||||
#ifdef PDP11 /****************************/
|
||||
struct { /* low word first on PDP11 */
|
||||
WORD loword; /* */
|
||||
WORD hiword; /* */
|
||||
}; /****************************/
|
||||
#endif
|
||||
|
||||
#ifdef MC68000 /****************************/
|
||||
struct { /* */
|
||||
WORD hiword; /* High word first on 68K */
|
||||
WORD loword; /* */
|
||||
}; /****************************/
|
||||
#endif
|
||||
|
||||
#ifdef UNIX /****************************/
|
||||
#define fopenb fopen /* Not in UNIX library */
|
||||
#endif /****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* Relocation bit definitions */
|
||||
/* */
|
||||
/* Note that this program is intended only for load module files. Any */
|
||||
/* references to external symbols or relative references are illegal. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
#define DABS 0 /* Data absolute */
|
||||
#define DRELOC 1 /* Data segment relative */
|
||||
#define TRELOC 2 /* Text segment relative */
|
||||
#define BRELOC 3 /* BSS segment relative */
|
||||
#define EXTVAL 4 /* External variable */
|
||||
#define LUPPER 5 /* Upper word of long */
|
||||
#define EXTREL 6 /* External relative symbol */
|
||||
#define INSABS 7 /* 1st word of instruction */
|
||||
/****************************/
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* G l o b a l D a t a */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
BYTE *ifname=0; /* -> Input filename */
|
||||
BYTE *ofname=0; /* -> Output filename */
|
||||
LONG base=0; /* New relocation base */
|
||||
FILE *fopenb(); /* File open procedure */
|
||||
LONG ftell(); /* File offset procedure */
|
||||
#ifdef CPM /* Only defined with CP/M */
|
||||
EXTERN BYTE _start; /* Start of program */
|
||||
#endif /* */
|
||||
/****************************/
|
||||
#include "cout.h" /* Output header area */
|
||||
/****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* M a i n P r o c e d u r e */
|
||||
/* --------------------------- */
|
||||
/* */
|
||||
/* Here we get things started: */
|
||||
/* */
|
||||
/* 1). Get relocation base */
|
||||
/* 2). Open input and output files */
|
||||
/* 3). Determine data area (new) size */
|
||||
/* */
|
||||
/* Any errors here are fatal, and cause program termination. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
VOID main(argc,argv)
|
||||
/****************************/
|
||||
DEFAULT argc; /* Int var from RTL startup */
|
||||
BYTE **argv; /* -> Arg strings */
|
||||
{ /****************************/
|
||||
REG LONG i,l; /* Temps */
|
||||
REG FILE *ifp,*ofp,*rfp; /* File pointers */
|
||||
/* */
|
||||
if(argc != 4 && argc != 3) /* Gotta have right format */
|
||||
usage(); /* Print out nasty message */
|
||||
/****************************/
|
||||
if(argc == 4) /* "-bxxxx" form */
|
||||
{ /****************************/
|
||||
if(decode(argv[1], &base) == FAILURE) /* Convert to binary */
|
||||
{ /* */
|
||||
printf("Illegal option: %s\n", /* Print offending option */
|
||||
argv[1]); /* */
|
||||
usage(); /* Print reminder messages */
|
||||
} /****************************/
|
||||
ifname = argv[2]; /* -> Input file name */
|
||||
ofname = argv[3]; /* -> Output file name */
|
||||
} else /* Default form */
|
||||
{ /* */
|
||||
#ifdef CPM /* On CP/M, */
|
||||
base = &_start; /* Use start of reloc itself*/
|
||||
#else /****************************/
|
||||
base = 0x500; /* 500H is default */
|
||||
#endif /* */
|
||||
ifname = argv[1]; /* -> Input filename */
|
||||
ofname = argv[2]; /* -> Output filename */
|
||||
} /****************************/
|
||||
/* */
|
||||
if((base & 1) != 0) /* In range? */
|
||||
{ /* no */
|
||||
printf("Illegal base address=%lx\n", /* print */
|
||||
base); /* message */
|
||||
exit(-1); /* And quit */
|
||||
} /****************************/
|
||||
/* */
|
||||
if((ifp=fopenb(ifname,"r")) == NULL) /* Try to open input */
|
||||
{ /* */
|
||||
printf("Cannot open %s\n",ifname); /* Complain */
|
||||
exit(-1); /* & quit */
|
||||
} /****************************/
|
||||
/* */
|
||||
if((ofp=fopenb(ofname,"w")) == NULL) /* Try to create output */
|
||||
{ /* */
|
||||
printf("Cannot create %s\n",ifname); /* Complain */
|
||||
exit(-1); /* & quit */
|
||||
} /****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* Now read the file header and compute the new data segment size ... */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
i = fread(&couthd,1,(sizeof couthd), /* Do the read */
|
||||
ifp); /* */
|
||||
if(i != (sizeof couthd)) /* Did it work?? */
|
||||
{ /* */
|
||||
printf("Read error on %s\n",ifname); /* No, complain */
|
||||
exit(-1); /* and quit */
|
||||
} /****************************/
|
||||
/* */
|
||||
if(couthd.ch_magic != MAGIC) /* Valid file? */
|
||||
{ /* */
|
||||
printf("File format error: %s\n", /* Print nasty message */
|
||||
ifname); /* */
|
||||
exit(-1); /* Quit */
|
||||
} /****************************/
|
||||
/* */
|
||||
l = couthd.ch_tsize + sizeof couthd; /* Seek address for data */
|
||||
fseek(ifp,l,0); /* Seek to data start */
|
||||
/* */
|
||||
i = couthd.ch_dsize; /* Fetch data size */
|
||||
l = ftell(ifp); /* l <= new data end addr */
|
||||
/* */
|
||||
while (i > 0) /* Until all data examined */
|
||||
{ /* */
|
||||
if(getw(ifp) != 0) /* This data word = 0? */
|
||||
l = ftell(ifp); /* No, record seek address */
|
||||
i -= 2; /* Down count */
|
||||
} /****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* Open the file a second time, and perform the proper seeks to align */
|
||||
/* one copy of the open file to the beginning of the text segment, and */
|
||||
/* the other copy to the beginning of the relocation information */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
if((rfp=fopenb(ifname,"r")) == NULL) /* Try to open again */
|
||||
{ /* */
|
||||
printf("Cannot re-open %s\n",ifname); /* Print nasty message */
|
||||
exit(-1); /* and quit */
|
||||
} /****************************/
|
||||
fseek(ifp,(LONG)(sizeof couthd),0); /* Seek to text beginning */
|
||||
fseek(rfp,(LONG)(sizeof couthd) + /* Seek to */
|
||||
couthd.ch_tsize+couthd.ch_dsize + /* relocation */
|
||||
couthd.ch_ssize, 0); /* info*/
|
||||
/****************************/
|
||||
reloc(ifp,rfp,ofp,l); /* Do relocation */
|
||||
} /****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* U s a g e F u n c t i o n */
|
||||
/* --------------------------- */
|
||||
/* */
|
||||
/* Routine "usage" is used to print out an error message when the */
|
||||
/* program is invoked in an improper manner. */
|
||||
/* */
|
||||
/* Calling Sequence: */
|
||||
/* */
|
||||
/* usage(); */
|
||||
/* */
|
||||
/* No return is made, "exit()" is called to go back to the O/S. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
VOID usage()
|
||||
{
|
||||
printf("Usage: reloc [-bhhhhhh] input output\n");
|
||||
printf(" where: hhhhhh is new base address\n");
|
||||
printf(" (TPA+100 is default base address)\n");
|
||||
printf(" input is relocatable file\n");
|
||||
printf(" output is absolute file\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* D e c o d e F u n c t i o n */
|
||||
/* ------------------------------ */
|
||||
/* */
|
||||
/* Routine "decode" is called to process the relocation base argument */
|
||||
/* from the command line. */
|
||||
/* */
|
||||
/* Calling sequence: */
|
||||
/* */
|
||||
/* ret = decode(string,&address); */
|
||||
/* */
|
||||
/* Where: */
|
||||
/* string -> argument string (usually argv[1]) */
|
||||
/* &address -> long word to receive converted value */
|
||||
/* */
|
||||
/* ret = 0 if successful conversion */
|
||||
/* = -1 if anything amiss */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
WORD decode(string,addr) /* */
|
||||
/* */
|
||||
REG BYTE *string; /* -> Command argument */
|
||||
LONG *addr; /* = return value */
|
||||
{ /****************************/
|
||||
REG LONG a; /* Temp return value */
|
||||
REG BYTE c; /* Temp character */
|
||||
/* */
|
||||
if(*string++ != '-' || *string++ != 'b')/* Check for valid switch */
|
||||
return(FAILURE); /* quit if NFG */
|
||||
/* */
|
||||
a = 0; /* Zero out accumulator */
|
||||
/* */
|
||||
while(*string) /* Until no more chars */
|
||||
{ /* */
|
||||
c = *string & 0177; /* Pick up next char */
|
||||
if (c >= '0' && c <= '9') /* Digit */
|
||||
a = (a << 4) + c - '0'; /* Un-ASCIIfy */
|
||||
else if (c >= 'A' && c <= 'F') /* Hex */
|
||||
a = (a << 4) + c - 'A'+ 10; /* Un-ASCIIfy */
|
||||
else if (c >= 'a' && c <= 'f') /* Lower case hex */
|
||||
a = (a << 4) + c - 'a'+ 10; /* Un-ASCII it */
|
||||
else /* Bad character */
|
||||
return(FAILURE); /* So long, sucker!! */
|
||||
string++; /* Increment pointer */
|
||||
} /* */
|
||||
*addr = a; /* Store result */
|
||||
return(SUCCESS); /* Return all ok */
|
||||
} /****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* R e l o c F u n c t i o n */
|
||||
/* --------------------------- */
|
||||
/* */
|
||||
/* Function "reloc" is called to perform the relocation operation and */
|
||||
/* write the output file simultaneously. */
|
||||
/* */
|
||||
/* Calling Sequence: */
|
||||
/* */
|
||||
/* reloc(ifp,rfp,ofp,length); */
|
||||
/* */
|
||||
/* Where: */
|
||||
/* */
|
||||
/* ifp Is the input stream pointer (positioned at text) */
|
||||
/* rfp Is a stream pointer positioned at relocation bits */
|
||||
/* ofp Is a stream pointer for the output file */
|
||||
/* length Is the total length of the output file */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
VOID reloc(ifp,rfp,ofp,length) /* */
|
||||
/* */
|
||||
REG FILE *ifp; /* -> Text information */
|
||||
REG FILE *rfp; /* -> Relocation info */
|
||||
REG FILE *ofp; /* -> Output file */
|
||||
LONG length; /* = # bytes in the file */
|
||||
{ /****************************/
|
||||
struct hdr x; /* Duplicate header */
|
||||
REG LONG bytes; /* File offset */
|
||||
LONG j; /* Temp for long relocation */
|
||||
REG WORD r; /* Relocation word */
|
||||
REG WORD k; /* Temp data word */
|
||||
WORD longf; /* Long relocation flag */
|
||||
WORD z; /* Temp for error codes */
|
||||
LONG bias; /* Relocation bias */
|
||||
/* */
|
||||
bias = base - couthd.ch_entry; /* Compute relocation bias */
|
||||
/* */
|
||||
/************************************************* */
|
||||
/* */
|
||||
/* Prepare and write the new file header in structure "x". */
|
||||
/* */
|
||||
/************************************************* */
|
||||
/* */
|
||||
x.ch_magic = MAGIC; /* Magic word */
|
||||
x.ch_tsize = couthd.ch_tsize; /* Text size */
|
||||
j = sizeof couthd + couthd.ch_tsize + /* Compute number of bytes */
|
||||
couthd.ch_dsize - length; /* moved from data to bss */
|
||||
x.ch_dsize = couthd.ch_dsize - j; /* New data size */
|
||||
x.ch_bsize = couthd.ch_bsize + j; /* New bss size */
|
||||
x.ch_ssize = 0; /* No symbols */
|
||||
x.ch_stksize = 0; /* No stack */
|
||||
x.ch_entry = base; /* New base address */
|
||||
x.ch_rlbflg = -1; /* No relocation bits */
|
||||
/****************************/
|
||||
if(fwrite(&x,1,sizeof x,ofp) != /* Do the write */
|
||||
sizeof x) /* */
|
||||
{ /* Here if failed */
|
||||
printf("Write error on %s\n",ofname); /* print message */
|
||||
exit(-1); /* Quit */
|
||||
} /****************************/
|
||||
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* Here begins the actual file relocation procedure. Read a word */
|
||||
/* from the relocation bits and from the file together. If long, */
|
||||
/* read another word from each. Perform indicated relocation. */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
bytes = 0; /* No bytes written yet ... */
|
||||
length -= sizeof(couthd); /* Just program, please... */
|
||||
while (bytes < length) /* until we are done */
|
||||
{ /****************************/
|
||||
k = getw(ifp); /* get next text/data word */
|
||||
r = getw(rfp); /* get next relocation word */
|
||||
/****************************/
|
||||
if ((r & ~7) != 0) /* Check for validity */
|
||||
badrel(r,bytes); /* Not valid, quit */
|
||||
/* */
|
||||
if(r == LUPPER) /* Doing a long? */
|
||||
{ /* */
|
||||
j.hiword = k; /* Yes, get another word */
|
||||
j.loword = getw(ifp); /* From both */
|
||||
r = getw(rfp); /* streams */
|
||||
longf = 2; /* Set flag */
|
||||
} /****************************/
|
||||
else /* Not a long */
|
||||
{ /* */
|
||||
j.loword = k; /* Put in low order word */
|
||||
j.hiword = 0; /* Make top part 0 */
|
||||
longf = 0; /* Clear flag */
|
||||
} /****************************/
|
||||
switch (r) /* Now do indicated reloc */
|
||||
{ /* */
|
||||
case TRELOC: /* If relocatable, */
|
||||
case DRELOC: /* relocate */
|
||||
case BRELOC: /* */
|
||||
j += bias; /* Add in bias */
|
||||
case DABS: /* If not relocatable, */
|
||||
case INSABS: /* don't */
|
||||
break; /****************************/
|
||||
default: /* Any others illegal */
|
||||
badrel(r,bytes); /* Print message */
|
||||
} /****************************/
|
||||
if(longf == 0 && j.hiword !=0) /* 16-bit overflow? */
|
||||
{ /* */
|
||||
printf("16-bit overflow at %ld\n", /* Print out message */
|
||||
bytes); /* with offset */
|
||||
exit(-1); /* */
|
||||
} /****************************/
|
||||
if(longf != 0) /* Long? */
|
||||
putw(j.hiword,ofp); /* yes, output high */
|
||||
#ifndef UNIX /* A bug in UNIX RTL!! */
|
||||
if((z=putw(j.loword,ofp)) != j.loword) /* Check for write error */
|
||||
{ /* */
|
||||
printf("Write error on %s ",ofname); /* Had one, */
|
||||
printf("Offset = %lx data= %x err =%x\n", /* */
|
||||
bytes,j.loword,z); /* Print out message */
|
||||
exit(-1); /* & quit */
|
||||
} /****************************/
|
||||
#else /* Just output and pray... */
|
||||
putw(j.loword,ofp); /* Output low word */
|
||||
#endif /****************************/
|
||||
bytes += 2 + longf; /* Increment byte count */
|
||||
/* */
|
||||
} /* End while loop */
|
||||
} /* End reloc procedure */
|
||||
/****************************/
|
||||
VOID badrel(r,offset) /* Print bad reloc message */
|
||||
/* */
|
||||
WORD r; /* Relocation bits */
|
||||
LONG offset; /* File offset */
|
||||
{ /****************************/
|
||||
printf("Illegal reloc = %x at %lx\n", /* Print error message */
|
||||
r,offset); /* */
|
||||
exit(-1); /* quit */
|
||||
} /****************************/
|
||||
|
||||
|
@@ -0,0 +1,41 @@
|
||||
$1vsend make.sub
|
||||
$1vsend lo68.rel
|
||||
$1vsend dump.rel
|
||||
$1vsend ar68.rel
|
||||
$1vsend nm68.rel
|
||||
$1vsend reloc.rel
|
||||
$1vsend prtobj.rel
|
||||
$1vsend machine.h
|
||||
$1vsend lo68.c
|
||||
$1vsend sendc68.rel
|
||||
$1vsend size68.rel
|
||||
$1vsend find.rel
|
||||
$1vsend down.sub
|
||||
$1vsend ar.h
|
||||
$1vsend ar68.c
|
||||
$1vsend cout.h
|
||||
$1vsend dump.c
|
||||
$1vsend find.c
|
||||
$1vsend libfix.c
|
||||
$1vsend link.com
|
||||
$1vsend list.com
|
||||
$1vsend lo68.h
|
||||
$1vsend lo68init.c
|
||||
$1vsend machine.11
|
||||
$1vsend machine.68k
|
||||
$1vsend machine.vax
|
||||
$1vsend n.c
|
||||
$1vsend nm68.c
|
||||
$1vsend nuxi.c
|
||||
$1vsend prtobj.c
|
||||
$1vsend reloc.c
|
||||
$1vsend send10.sub
|
||||
$1vsend sendc68.c
|
||||
$1vsend sendc68.h
|
||||
$1vsend size68.c
|
||||
$1vsend vmake.com
|
||||
$1vsend vsend.com
|
||||
$1vsend xer.com
|
||||
$1vsend send.sub
|
||||
$1vsend iobuf.h
|
||||
$1vsend done
|
214
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/sendc68.c
Normal file
214
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/sendc68.c
Normal file
@@ -0,0 +1,214 @@
|
||||
#include <stdio.h>
|
||||
#include <klib.h>
|
||||
#include "cout.h"
|
||||
#include "sendc68.h"
|
||||
|
||||
/* this program reads a c.out format binary file and converts*/
|
||||
/* it to the absolute ASCII load format acceptable by MACSBUG*/
|
||||
/* and then sends it down the standard output file*/
|
||||
|
||||
#define MAGIC1 MAGIC+1
|
||||
long lseek();
|
||||
long datastart=0;
|
||||
long bssstart=0;
|
||||
|
||||
long loctr=0;
|
||||
extern int fout;
|
||||
int pflg=0;
|
||||
#define RBLEN 32 /*number of bytes per S1 record*/
|
||||
int bcnt=RBLEN;
|
||||
char cksum=0;
|
||||
int syno=0;
|
||||
char *ofn=0;
|
||||
int ofd=0;
|
||||
int noclear=0;
|
||||
|
||||
|
||||
main(argc,argv)
|
||||
char **argv;
|
||||
{
|
||||
|
||||
long l,l1;
|
||||
register i,j;
|
||||
|
||||
if(argc < 2 || argc > 3) {
|
||||
usage();
|
||||
}
|
||||
i = 1;
|
||||
if(*argv[1] == '-') {
|
||||
noclear++;
|
||||
i++;
|
||||
}
|
||||
openfile(argv[i++]);
|
||||
if(argc>i) {
|
||||
usage();
|
||||
}
|
||||
|
||||
else {
|
||||
ofd = dup(1); /*standard output file*/
|
||||
}
|
||||
fout = ofd; /*use buffered output*/
|
||||
l1 = couthd.ch_tsize;
|
||||
loctr = couthd.ch_entry;
|
||||
mloop:
|
||||
for(l=0; l<l1; l=+ 2) {
|
||||
i = getw(&ibuf);
|
||||
outword(i);
|
||||
loctr =+ 2;
|
||||
}
|
||||
if(couthd.ch_magic==MAGIC1) {
|
||||
while(bcnt != RBLEN) /*fill out the last S1 buffer*/
|
||||
outword(0);
|
||||
loctr = datastart;
|
||||
}
|
||||
l1 = couthd.ch_dsize;
|
||||
for(l=0; l<l1; l=+ 2) {
|
||||
i = getw(&ibuf);
|
||||
outword(i);
|
||||
loctr =+ 2;
|
||||
}
|
||||
if(noclear==0) {
|
||||
if(couthd.ch_magic==MAGIC1) {
|
||||
while(bcnt != RBLEN) /*fill out the last S1 buffer*/
|
||||
outword(0);
|
||||
loctr = bssstart;
|
||||
}
|
||||
l1 = couthd.ch_bsize; /*size of bss*/
|
||||
while(l1 > 0) {
|
||||
outword(0); /*clear the bss*/
|
||||
l1 =- 2;
|
||||
loctr =+ 2;
|
||||
}
|
||||
}
|
||||
while(bcnt != RBLEN) /*fill out the last S1 buffer*/
|
||||
outword(0);
|
||||
printf("S9030000FC\n");
|
||||
|
||||
}
|
||||
|
||||
openfile(ap)
|
||||
char *ap;
|
||||
{
|
||||
|
||||
register char *p;
|
||||
|
||||
p = ap;
|
||||
if((ibuf.fildes=open(p,0,1)) < 0) {
|
||||
printf("unable to open %s\n",p);
|
||||
exit();
|
||||
}
|
||||
ifilname = p; /*point to current file name for error msgs*/
|
||||
if(read(ibuf.fildes,&couthd,2) != 2) {
|
||||
printf("read error on file: %s\n",ifilname);
|
||||
exit();
|
||||
}
|
||||
ibuf.nunused = 0;
|
||||
lseek(ibuf.fildes,0L,0);
|
||||
readhdr(); /*read file header*/
|
||||
}
|
||||
readhdr()
|
||||
{
|
||||
|
||||
register int i;
|
||||
register short *p;
|
||||
|
||||
p = &couthd;
|
||||
for(i=0; i<HDSIZE/2; i++)
|
||||
*p++ = getw(&ibuf);
|
||||
if(couthd.ch_magic != MAGIC) {
|
||||
if(couthd.ch_magic==MAGIC1) {
|
||||
#ifdef VAX
|
||||
datastart.loword = getw(&ibuf);
|
||||
datastart.hiword = getw(&ibuf);
|
||||
bssstart.loword = getw(&ibuf);
|
||||
bssstart.hiword = getw(&ibuf);
|
||||
#endif
|
||||
#ifdef PDP11
|
||||
datastart.loword = getw(&ibuf);
|
||||
datastart.hiword = getw(&ibuf);
|
||||
bssstart.loword = getw(&ibuf);
|
||||
bssstart.hiword = getw(&ibuf);
|
||||
#endif
|
||||
#ifdef MC68000
|
||||
datastart.hiword = getw(&ibuf);
|
||||
datastart.loword = getw(&ibuf);
|
||||
bssstart.hiword = getw(&ibuf);
|
||||
bssstart.loword = getw(&ibuf);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
printf("file format error: %s\n",ifilname);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
longseek(al,bp,pn)
|
||||
long al;
|
||||
struct buf *bp;
|
||||
{
|
||||
|
||||
if(lseek(bp->fildes,al,0) < 0) {
|
||||
printf("seek error on file %s\n",ifilname);
|
||||
exit();
|
||||
}
|
||||
bp->nunused = 0; /*input buff empty*/
|
||||
}
|
||||
|
||||
outword(i)
|
||||
register i;
|
||||
{
|
||||
|
||||
|
||||
if(bcnt==RBLEN) { /*beginning of record*/
|
||||
cksum = 0;
|
||||
if(loctr.hiword) {
|
||||
printf("S2");
|
||||
hexby(RBLEN+4);
|
||||
hexby(loctr.hiword);
|
||||
}
|
||||
else {
|
||||
printf("S1");
|
||||
hexby(RBLEN+3); /*byte count*/
|
||||
}
|
||||
hexwd(loctr.loword);
|
||||
}
|
||||
hexwd(i);
|
||||
bcnt =- 2;
|
||||
if(bcnt==0) {
|
||||
hexby(-cksum-1);
|
||||
putchar('\n');
|
||||
bcnt = RBLEN;
|
||||
}
|
||||
}
|
||||
|
||||
hexwd(i)
|
||||
{
|
||||
|
||||
hexby((i>>8)&0xff);
|
||||
hexby(i&0xff);
|
||||
}
|
||||
|
||||
hexby(c)
|
||||
{
|
||||
|
||||
cksum =+ c;
|
||||
outhex((c>>4)&017);
|
||||
outhex(c&017);
|
||||
}
|
||||
|
||||
outhex(x)
|
||||
{
|
||||
|
||||
if(x>=0 && x<=9)
|
||||
putchar(x+'0');
|
||||
else if(x>=10 && x<=15)
|
||||
putchar(x-10+'A');
|
||||
else
|
||||
exit();
|
||||
}
|
||||
usage()
|
||||
{
|
||||
printf("Usage: sendc68 [-] commandfile [>outputfile]\n");
|
||||
exit();
|
||||
}
|
||||
|
@@ -0,0 +1,87 @@
|
||||
/* format of a symbol entry in the main table*/
|
||||
#include "machine.h"
|
||||
#define SEEKREL 1 /*relative seek flag*/
|
||||
|
||||
#define OSTSIZE 14 /*symbol table entry length on object file*/
|
||||
/* without table link*/
|
||||
# define STESIZE 18 /*byte length of symbol table entry*/
|
||||
struct symtab {
|
||||
char name[8]; /*symbol name*/
|
||||
short flags; /*bit flags*/
|
||||
long vl1; /*symbol value*/
|
||||
char *tlnk; /*table link*/
|
||||
};
|
||||
|
||||
struct symtab *symptr;
|
||||
|
||||
/* flags for symbols*/
|
||||
# define SYDF 0100000 /*defined*/
|
||||
# define SYEQ 0040000 /*equated*/
|
||||
# define SYGL 0020000 /*global - entry or external*/
|
||||
# define SYER 0010000 /*equated register*/
|
||||
# define SYXR 0004000 /*external reference*/
|
||||
# define SYDA 0002000 /*DATA based relocatable*/
|
||||
# define SYTX 0001000 /*TEXT based relocatable*/
|
||||
# define SYBS 0000400 /*BSS based relocatable*/
|
||||
|
||||
struct irts {
|
||||
char *irle; /*ptr to last entry in chain*/
|
||||
char *irfe; /*ptr to first entry in chain*/
|
||||
};
|
||||
|
||||
|
||||
#ifdef VAX
|
||||
struct {
|
||||
short loword;
|
||||
short hiword;
|
||||
};
|
||||
#endif
|
||||
#ifdef PDP11
|
||||
struct {
|
||||
short loword;
|
||||
short hiword;
|
||||
};
|
||||
#endif
|
||||
#ifdef MC68000
|
||||
struct {
|
||||
short hiword;
|
||||
short loword;
|
||||
};
|
||||
#endif
|
||||
#ifdef VAX
|
||||
struct {
|
||||
char lobyte;
|
||||
char hibyte;
|
||||
};
|
||||
#endif
|
||||
#ifdef PDP11
|
||||
struct {
|
||||
char lobyte;
|
||||
char hibyte;
|
||||
};
|
||||
#endif
|
||||
#ifdef MC68000
|
||||
struct {
|
||||
char hibyte;
|
||||
char lobyte;
|
||||
};
|
||||
#endif
|
||||
/* relocation bit definitions:*/
|
||||
#define RBMASK 07 /*tells type of relocation*/
|
||||
#define INSABS 7 /*first word of instr -- absolute*/
|
||||
#define DABS 0 /*data word absolute*/
|
||||
#define TRELOC 2 /* TEXT relocatable*/
|
||||
#define DRELOC 1 /* DATA relocatable*/
|
||||
#define BRELOC 3 /* BSS relocatable*/
|
||||
#define EXTVAR 4 /* ref to external variable*/
|
||||
#define LUPPER 5 /* upper word of long*/
|
||||
|
||||
struct buf{
|
||||
int fildes;
|
||||
int nunused;
|
||||
char *xfree;
|
||||
char buff[512];
|
||||
};
|
||||
|
||||
struct buf ibuf={0};
|
||||
char *ifilname=0;
|
106
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/size68.c
Normal file
106
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/lo68/size68.c
Normal file
@@ -0,0 +1,106 @@
|
||||
#include <stdio.h>
|
||||
#include <klib.h>
|
||||
#include "cout.h"
|
||||
#define MAGIC1 MAGIC+1
|
||||
|
||||
int fd=0;
|
||||
char *fn = {"c.out"};
|
||||
|
||||
main(argc,argv)
|
||||
char **argv;
|
||||
{
|
||||
|
||||
register i,j;
|
||||
long l;
|
||||
|
||||
i = 1;
|
||||
if(argc<2)
|
||||
goto dodef;
|
||||
for(i=1; i<argc; i++) {
|
||||
fn = argv[i];
|
||||
dodef:
|
||||
if((fd=open(fn,0,1)) < 0) {
|
||||
printf("unable to open %s\n",fn);
|
||||
exit();
|
||||
}
|
||||
if((j=read(fd,&couthd,HDSIZE)) != HDSIZE) {
|
||||
printf("read error on %s\n",fn);
|
||||
exit();
|
||||
}
|
||||
if(couthd.ch_magic!=MAGIC && couthd.ch_magic!=MAGIC1) {
|
||||
printf("File format error: %s\n",fn);
|
||||
exit();
|
||||
}
|
||||
printf("%s:",fn);
|
||||
l = couthd.ch_tsize+couthd.ch_dsize+couthd.ch_bsize;
|
||||
ldec(couthd.ch_tsize);
|
||||
putchar('+');
|
||||
ldec(couthd.ch_dsize);
|
||||
putchar('+');
|
||||
ldec(couthd.ch_bsize);
|
||||
putchar('=');
|
||||
ldec(l);
|
||||
printf(" (");
|
||||
lhex(l);
|
||||
printf(" ) stack size = ");
|
||||
ldec(couthd.ch_stksize);
|
||||
putchar('\n');
|
||||
if(couthd.ch_magic == MAGIC1) {
|
||||
read(fd,&l,4);
|
||||
printf("data start=");
|
||||
lhex(l);
|
||||
read(fd,&l,4);
|
||||
printf(" bss start=");
|
||||
lhex(l);
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char ostr[80] = {0};
|
||||
|
||||
lhex(al)
|
||||
long al;
|
||||
{
|
||||
|
||||
register i;
|
||||
register char *p;
|
||||
register j;
|
||||
|
||||
p = &ostr[80];
|
||||
*--p = 0;
|
||||
for(i=0; i<8; i++) {
|
||||
j = al&017;
|
||||
if(j<10)
|
||||
j =+ '0';
|
||||
else
|
||||
j =+ 'A'-10;
|
||||
*--p = j;
|
||||
al =>> 4;
|
||||
if(al == 0)
|
||||
break;
|
||||
}
|
||||
printf("%s",p);
|
||||
}
|
||||
|
||||
ldec(al)
|
||||
long al;
|
||||
{
|
||||
|
||||
register i;
|
||||
register char *p;
|
||||
register j;
|
||||
|
||||
p = &ostr[80];
|
||||
*--p = 0;
|
||||
for(i=0; i<10; i++) {
|
||||
j = al%10;
|
||||
j =+ '0';
|
||||
*--p = j;
|
||||
al =/ 10;
|
||||
if(al == 0)
|
||||
break;
|
||||
}
|
||||
printf("%s",p);
|
||||
}
|
||||
|
Reference in New Issue
Block a user