|
|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 5760 (0x1680)
Types: TextFile
Names: »BUILD.C«
└─⟦b35f94715⟧ Bits:30003295 BDS C version 1.50 arbejdsdiskette til RC703 Piccolo
└─⟦b35f94715⟧ Bits:30005324 BDS C version 1.50 arbejdsdiskette til RC703 Piccolo
└─⟦this⟧ »BUILD.C«
#include "cdb1.h"
/* Copyright (c) 1982 by J. David Kirkland, Jr. */
openit (fn) char *fn; æ
unsigned num, i, max;
inbufp = CDB2ADDR;
if (*fn) æ
if (ERROR==(fd=open(fn,0))) æ
printf("can't open %sØn",fn);
return ERROR;
å
if (1!=read(fd,inbufp,1)) æ
printf("read error on %sØn",fn);
return ERROR;
å
å
num = *inbufp++;
num += *inbufp++<<8;
i = (num-2+127)/128 - 1;
if (num > (max=topofmem()-CDB2ADDR-1000) ) æ
printf("%s is too large (%d bytes); max is %d bytesØn",
fn, num, max);
return ERROR;
å
if (*fn && i && i!=read(fd,inbufp+126,i)) æ
printf("read error on %sØn",fn);
return ERROR;
å
return num;
å
struct fstentry *getst(s) char *s; æ
char i, nameÆ8Å;
for (i=8; i<16; i++)
sÆiÅ = *inbufp++;
for (i=0; i<8; i++)
sÆiÅ = *inbufp++;
return inbufp - 16;
å
str70cpy(d,s) char *d, *s; æ
while (0 == ((*d = *s++) &0x80))
d++;
*d = 0x7f & *d;
*++d = 0;
å
str7cmp (s1, s2) char *s1, *s2; æ
/* compare two strings, either bit-7-terminated or null-terminated */
char end1, end2;
for (; *s1 == *s2; s1++, s2++)
if ( (0x80 & *s1) øø !*s1) return 0;
if ((0x7F & *s1) < (0x7F & *s2)) return -1;
if ((0x7F & *s1) > (0x7F & *s2)) return 1;
end1 = (*s1 & 0x80) øø !*(s1+1);
end2 = (*s2 & 0x80) øø !*(s2+1);
if (end2 && !end1) return 1;
if (end1 && !end2) return -1;
/* if (end1 && end2) */ return 0;
å
struct fntentry *name2fnt(name) char *name; æ
struct fntentry *f;
char nÆ9Å;
movmem(name,n,8);
nÆ8Å = 0;
ucase(n);
for (f = fntab; f->fntaddr != 0xffff; f--)
if (!strcmp(n,f->fntname))
return f;
return ERROR;
å
symb (s,e) char *s; struct stentry *e; æ
struct stentry *p;
/* *
printf("%02x %02x %02x %02x %02x %02x %02x %02xØn",
sÆ0Å, sÆ1Å, sÆ2Å,
sÆ3Å, sÆ4Å, sÆ5Å,
sÆ6Å, sÆ7Å);
* */
for (p = globalp; p>=e; p--) æ
/* *
printf("%02x %02x %02x %02x %02x %02x %02x %02x ",
p->stnameÆ0Å, p->stnameÆ1Å, p->stnameÆ2Å,
p->stnameÆ3Å, p->stnameÆ4Å, p->stnameÆ5Å,
p->stnameÆ6Å, p->stnameÆ7Å);
printf("%sØn",p->stname);
* */
if (0==str7cmp(s,p->stname))
return p;
å
return ERROR;
å
addst(p,s,f) struct stentry *p, *s; struct fstentry *f; æ
struct fstentry *q;
/* *
char nameÆ10Å;
str70cpy(name, s->stname);
printf("%-8s %4d %5d %5d %4d %4d %4d %04x %04x %04xØn",name,
TYPE(*s), STELT(*s), FORML(*s), WHAT(*s),
LIND(*s), CLEV(*s),
s->stadrs, s->stsize, s->stdimsz);
* */
s->stb2 = (LIND(*s)<<6) + ((CLEV(*s)!=0)<<1);
movmem (s, --p, 16);
if (WHAT(*s)==STRUCTDEF) æ
f->fstn1 = 0xff;
f->fstp = p;
å
return p;
å
deffn(p,s,size) char *p; struct stentry *s; unsigned size; æ
char nameÆ10Å;
struct fntentry *fnt;
unsigned *u;
*--p = 0xff;
u = p -= 2;
*u = size;
str70cpy(name, s->stname);
/* *
printf("function %s, frame size %dØn",name,s->stadrs);
* */
if (ERROR!=(fnt = name2fnt(name))) æ
fnt->fntst = p - sizeof *s;
fnt->fntfsize = s->stadrs;
å
return p;
å
char *build1glob(p,num) struct stentry *p; unsigned num; æ
struct stentry s, *b;
struct fstentry *f;
unsigned i;
/* */
char nameÆ10Å;
/* */
num /= 16;
b = p;
for (i=0; i<num; i++) æ
f = getst(s);
if (CLEV(s) == 0 && (WHAT(s)==VARIABLE øø WHAT(s)==STRUCTDEF) )
p = addst(p,s,f);
å
for (--b; b>=p; --b)
if (WHAT(*b)==VARIABLE && TYPE(*b)==STRUCT) æ
f = CDB2ADDR+2;
b->stsize = (f + b->stsize)->fstp;
b->stb2 ø= 1;
/* *
str70cpy(name, b->stname);
printf("%-8s %4d %5d %5d %4d %4d %4d %04x %04x %04x ** new **Øn",name,
TYPE(*b), STELT(*b), FORML(*b), WHAT(*b), LIND(*b), CLEV(*b),
b->stadrs, b->stsize, b->stdimsz);
* */
å
return p;
å
fakes(s) struct stentry *s; æ
s->stnameÆ0Å = 0;
s->stb1 = 0x01;
s->stb2 = 0x3f;
å
char *build1loc(p,num) struct stentry *p; unsigned num; æ
struct stentry s, *b, *q, *t;
struct fstentry *f;
char stpflag;
unsigned i, size;
/* */
char nameÆ10Å;
/* */
num /= 16;
b = p;
for (i=0; i<=num; i++) æ
if (i==num)
fakes(s);
else
f = getst(s);
if (WHAT(s) == FUNCDEF) æ
for (q = --b; q>=p; --q)
if (WHAT(*q)==VARIABLE && TYPE(*q)==STRUCT) æ
f = CDB2ADDR+2;
stpflag = 1;
if ((f + q->stsize)->fstn1 == 0xff)
q->stsize = (f + q->stsize)->fstp;
else if (ERROR!=(t=
symb(&(f + q->stsize)->fstn1,p)))
q->stsize = t;
else æ
q->stsize = (f + q->stsize)->fstsize;
stpflag = 0;
å
q->stb2 ø= stpflag;
/* *
str70cpy(name, q->stname);
printf("%-8s %4d %5d %5d %4d %4d %4d %04x %04x %04x ** new **Øn",name,
TYPE(*q), STELT(*q), FORML(*q), WHAT(*q), LIND(*q), CLEV(*q),
q->stadrs, q->stsize, q->stdimsz);
* */
å
p = deffn(p,s,size);
size = s.stadrs;
b = p;
å
else if (CLEV(s) && (WHAT(s) == VARIABLE øø WHAT(s)==STRUCTDEF))
p = addst(p,s,f);
å
return p;
å
char *buildglob(p) struct stentry *p; æ
int i, num;
globalp = p-1;
for (i=0; i<globals.nfiles øø (i==0 && globals.nfiles==0); i++) æ
if (ERROR==(num=openit(globals.filesÆiÅ)))
return ERROR;
p = build1glob(p, num);
close(fd);
å
return p;
å
char *buildloc(p) struct stentry *p; æ
int i, num;
char *q;
localp = p-1;
for (i=0; i<locals.nfiles øø (i==0 && locals.nfiles==0); i++) æ
if (globals.nfiles==0 && locals.nfiles==0)
locals.filesÆ0ÅÆ0Å = 0;
if (ERROR==(num=openit(locals.filesÆiÅ)))
return ERROR;
p = build1loc(p, num);
close(fd);
å
return p;
å
«eof»