*** empty log message ***

This commit is contained in:
ceriel 1987-02-26 19:54:57 +00:00
parent f8204dc8a9
commit f5099e7d9a
6 changed files with 134 additions and 100 deletions

View file

@ -15,11 +15,9 @@
* *
*/ */
#include <sgtty.h>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <out.h>
struct sgttyb tty;
#define DATTYPE 0 #define DATTYPE 0
#define EOFTYPE 1 #define EOFTYPE 1
@ -38,38 +36,63 @@ char *progname;
char hex[] = "0123456789ABCDEF"; char hex[] = "0123456789ABCDEF";
struct outhead ohead;
struct outsect sect[MAXSECT];
main(argc,argv) char **argv; { main(argc,argv) char **argv; {
register nd,pc,sg,osg,first; int i,nd,pc,first;
register char *s; register char *s;
progname = argv[0]; progname = argv[0];
if (argc > 3) if (argc > 3)
fatal("usage: %s [object [tty]]\n",argv[0]); fatal("usage: %s [object [tty]]\n",argv[0]);
s = "a.out"; s = "a.out";
if (argc >= 2) if (argc >= 2)
s = argv[1]; s = argv[1];
if (freopen(s,"r",stdin) == NULL) if (! rd_open(s)) {
fatal("can't open %s",s); fprintf(stderr,"%s: can't open %s\n",progname,s);
exit(-1);
}
rd_ohead(&ohead);
if (ohead.oh_flags & HF_LINK) {
fprintf(stderr,"%s: %s contains unresolved references\n",progname,s);
exit(-1);
}
rd_sect(sect, ohead.oh_nsect);
ttyfd = 1; ttyfd = 1;
first = 1; osg = 0; first = 1;
for (;;) { for (i = 0; i < ohead.oh_nsect; i++) {
pc = get2c(stdin); rd_outsect(i);
if (feof(stdin)) pc = sect[i].os_base;
break; while (sect[i].os_size) {
sg = get2c(stdin); unsigned int sz = 8096, fl;
nd = get2c(stdin); extern char *calloc();
if (first) { register char *buf;
first = 0; char *pbuf;
if (sz > sect[i].os_size) sz = sect[i].os_size;
sect[i].os_size -= sz;
pbuf = buf = calloc(sz, 1);
if (fl = sect[i].os_flen) {
if (fl > sz) fl = sz;
sect[i].os_flen -= fl;
rd_emit(buf, (long) fl);
}
while (sz >= MAXBYTE) {
data(MAXBYTE, (int) pc, buf);
sz -= MAXBYTE;
buf += MAXBYTE;
pc += MAXBYTE;
first = 0;
}
if (sz > 0) {
data(sz, (int) pc, buf);
first = 0;
}
free(pbuf);
} }
assert(sg == osg);
while (nd > MAXBYTE) {
data(MAXBYTE,pc);
nd -= MAXBYTE;
pc += MAXBYTE;
}
if (nd > 0)
data(nd,pc);
assert(feof(stdin) == 0);
} }
if (first == 0) if (first == 0)
eof(); eof();
@ -78,11 +101,13 @@ main(argc,argv) char **argv; {
reply(); reply();
} }
data(nd,pc) { data(nd,pc, buf)
register char *buf;
{
newline(nd,pc,DATTYPE); newline(nd,pc,DATTYPE);
do do
byte(getc(stdin)); byte(*buf++);
while (--nd); while (--nd);
endline(); endline();
} }
@ -132,14 +157,16 @@ b &= 0377;
put(hex[b & 017]); put(hex[b & 017]);
} }
put(c) { put(c)
char c;
{
write(ttyfd,&c,1); write(ttyfd,&c,1);
} }
reply() { reply() {
register i; register i;
int c; char c;
if (echo == 0) if (echo == 0)
return; return;
@ -148,13 +175,6 @@ reply() {
write(1,&c,1); write(1,&c,1);
} }
get2c(f) FILE *f; {
register c;
c = getc(f);
return((getc(f) << 8) | c);
}
fatal(s,a) { fatal(s,a) {
fprintf(stderr,"%s: ",progname); fprintf(stderr,"%s: ",progname);
@ -162,3 +182,5 @@ fatal(s,a) {
fprintf(stderr,"\n"); fprintf(stderr,"\n");
exit(-1); exit(-1);
} }
rd_fatal() { fatal("read error"); }

View file

@ -1,4 +1,4 @@
tail_em.s.a libem_s.a
adi.s adi.s
adi4.s adi4.s
and.s and.s

View file

@ -1,21 +1,22 @@
CFLAGS=-O EMHOME=../../..
OBJLIB=$(EMHOME)/modules/lib/libobject.a
cv: cv.o head: dl
$(CC) -o cv -n cv.o
install: ins_cv dl: dl.c
ins_cv: cv $(CC) -I$(EMHOME)/h -o dl dl.c $(OBJLIB)
../../install cv
cmp: cmp_cv install: head
cmp_cv: cv @echo Nothing is installed
-../../compare cv
opr: cmp: head
make pr | opr @echo Nothing is compared
pr:
@pr `pwd`/cv.c
clean: clean:
-rm -f *.o *.old cv rm -f *.o
pr:
@pr `pwd`/Makefile `pwd`/dl.c
opr:
make pr | opr

View file

@ -1,11 +1,14 @@
static char rcsid[] = "$Header$"; static char rcsid[] = "$Header$";
#define MAXBYTE 24 #define MAXBYTE 24
#include <stdio.h> #include <stdio.h>
#include <out.h>
char hex[] = "0123456789ABCDEF"; char hex[] = "0123456789ABCDEF";
FILE *fp, *fopen(); FILE *fp, *fopen();
char **s; char **s;
int bytes, bytcnt, checksum; int bytes, bytcnt, checksum;
long pc; long pc;
struct outhead ohead;
struct outsect sect[MAXSECT];
main (argc,argv) main (argc,argv)
@ -13,62 +16,86 @@ int argc;
char *argv[]; char *argv[];
{ {
if (argc != 2) fatal ("usage: %s filename\n",argv[0]); if (argc != 2) fatal ("usage: %s filename\n",argv[0]);
if ((fp = fopen (*++argv,"r")) == NULL) if (! rd_open (*++argv))
fatal ("can't open %s\n",*argv); fatal ("can't open %s\n",*argv);
else { else {
s = argv; s = argv;
convert (); convert ();
fclose (fp);
} }
} }
convert () convert ()
{ {
int c; int i;
do
{ rd_ohead(&ohead);
pc = getword (); if (ohead.oh_flags & HF_LINK) {
pc = (pc << 16) | getword (); fatal("%s contains unresolved references\n",s);
bytes = getword (); }
while (bytes != 0) rd_sect(sect, ohead.oh_nsect);
{ for (i = 0; i < ohead.oh_nsect; i++) {
bytcnt = (bytes < MAXBYTE) ? bytes : MAXBYTE; rd_outsect(i);
bytes -= bytcnt; pc = sect[i].os_base;
checksum = 0; while (sect[i].os_size) {
if (pc > 0xffffL) S2record (); else S1record (); unsigned int sz = 8096, fl;
extern char *calloc();
register char *buf;
char *pbuf;
if (sz > sect[i].os_size) sz = sect[i].os_size;
sect[i].os_size -= sz;
pbuf = buf = calloc(sz, 1);
if (fl = sect[i].os_flen) {
if (fl > sz) fl = sz;
sect[i].os_flen -= fl;
rd_emit(buf, (long) fl);
} }
c = getc (fp); while (sz > 0) {
ungetc (c, fp); int p = bytcnt = sz < MAXBYTE ? sz : MAXBYTE;
checksum = 0;
sz -= p;
if (pc > 0xffffL)
S2record (buf);
else S1record (buf);
buf += p;
}
free(pbuf);
} }
while (c != EOF); }
printf ("S9030000FC\n"); printf ("S9030000FC\n");
} }
S2record () S2record (buf)
char *buf;
{ {
printf ("S2"); printf ("S2");
bytcnt += 4; bytcnt += 4;
outbyte (bytcnt); outbyte (bytcnt);
outbyte (pc); outbyte ((int) (pc >> 16));
outbyte ((int) (pc >> 8));
outbyte ((int) pc);
record (); record ();
} }
S1record () S1record (buf)
char *buf;
{ {
printf ("S1"); printf ("S1");
bytcnt += 3; bytcnt += 3;
outbyte (bytcnt); outbyte (bytcnt);
record (); outbyte ((int) (pc >> 8));
outbyte((int) pc);
record (buf);
} }
record () record (buf)
register char *buf;
{ {
outbyte (pc << 8);
outbyte (pc << 16);
while (bytcnt != 0) while (bytcnt != 0)
{ {
outbyte (getbyte ()); outbyte (*buf++);
pc ++; pc ++;
} }
outbyte (~checksum); outbyte (~checksum);
@ -86,19 +113,8 @@ int b;
-- bytcnt; -- bytcnt;
} }
getword () rd_fatal() { fatal("Read error\n"); }
{
int c;
c = getbyte ();
return ((getbyte () << 8) | c );
}
getbyte ()
{
int c;
if ((c = getc (fp)) == EOF) fatal ("end of %s\n",*s);
return (c);
}
fatal (s,a) fatal (s,a)
{ {
printf (s,a); printf (s,a);

View file

@ -1,23 +1,18 @@
# $Header$ # $Header$
MACH=m68k4 MACH=m68k4
all: libem_o.a end.o
install: all install: all
../../install head_em.o head_em ../../install libem_o.a tail_em
../../install libem_o.a tail_em.rt
../../install end.o end_em ../../install end.o end_em
cmp: all cmp: all
-../../compare head_em.o head_em -../../compare libem_o.a tail_em
-../../compare libem_o.a tail_em.rt
-../../compare end.o end_em -../../compare end.o end_em
all: head_em.o libem_o.a end.o
end.o: end.s end.o: end.s
$(MACH) -I../../../h -c end.s $(MACH) -I../../../h -c end.s
head_em.o: head_em.s
$(MACH) -I../../../h -c head_em.s
libem_o.a: libem_s.a libem_o.a: libem_s.a
ASAR=aal ; export ASAR ;\ ASAR=aal ; export ASAR ;\
march . libem_o.a march . libem_o.a
@ -28,6 +23,5 @@ opr :
make pr | opr make pr | opr
pr: pr:
@pr `pwd`/head_em.s
@arch pv libem_s.a | pr -h `pwd`/libem_s.a @arch pv libem_s.a | pr -h `pwd`/libem_s.a
@pr `pwd`/end.s @pr `pwd`/end.s

View file

@ -1,5 +1,6 @@
SUF=o
MAKEFILE=../../proto/libg/Makefile MAKEFILE=../../proto/libg/Makefile
MACHDEF="MACH=ns" "SUF=o" "ASAR=aal" MACHDEF="MACH=ns" "SUF=$(SUF)" "ASAR=aal"
STDIO="PREF=cc" "SUB=.1s" "SRC=lang/cem/libcc/stdio" STDIO="PREF=cc" "SUB=.1s" "SRC=lang/cem/libcc/stdio"
GEN="PREF=cc" "SUB=.2g" "SRC=lang/cem/libcc/gen" GEN="PREF=cc" "SUB=.2g" "SRC=lang/cem/libcc/gen"
MON="PREF=mon" "SRC=lang/cem/libcc/mon" MON="PREF=mon" "SRC=lang/cem/libcc/mon"
@ -19,7 +20,7 @@ cplibm:
cplibln: cplibln:
make -f $(MAKEFILE) $(LIBLN) $(MACHDEF) tailcp make -f $(MAKEFILE) $(LIBLN) $(MACHDEF) tailcp
cmp: cmpstdio cmpgen cmpmon cmplib cmplibln cmp: cmpstdio cmpgen
cmpstdio: cmpstdio:
make -f $(MAKEFILE) $(STDIO) $(MACHDEF) tail make -f $(MAKEFILE) $(STDIO) $(MACHDEF) tail