diff options
author | Robert de Bath <rdebath@poboxes.com> | 1996-12-01 16:58:31 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:34:16 +0200 |
commit | f8de35da65c5d93bb733073cf40da154bc1c0748 (patch) | |
tree | d28c7644739a24402376d24cb0020ea410a9ccff | |
parent | c218c617b5be443b7968308506969ad2b726d73c (diff) | |
download | dev86-f8de35da65c5d93bb733073cf40da154bc1c0748.tar.gz |
Import Dev86src-0.0.9.tar.gzv0.0.9
76 files changed, 2354 insertions, 927 deletions
@@ -1,3 +1,50 @@ +For version 0.0.9. + +> The debian stuff has been removed again, Christoph want's to keep contol + of the debian specific files. + +> I've done some changes to the makefiles, it'll now honour CC=XXX on the + make command line. + +> The assembler now works again compiled under bcc, it tried to allocate + too much memory. + +> Major change to the assembler, '-j' not auto-sizes jumps this requires + a change to at least 3 passes. Sometimes it'll say it needs another -j + because lengthing jumps cause others to fail, two -j's will give it lots + of passes :-) + +> The second large change is an effort to identify when instructions are + not right for a specific processor and generate a warning. The use16 + and use32 instructions now have an optional argument of a processor + type (86,186..686). Also bcc has a '-W' to remove the -w it passes to + the assembler. + +> Altered the way bcc deals with LOCALPREFIX, now under DOS it picks this + up based on the path to the executable. + +> Fixed a bug introduced by the 'cpp in asm' change in 0.0.8, bcc-cc1 + wasn't compiling under bcc. + +> Two new bootblocks in the 'examples' mbr.s is an MBR (no really :-)) + msdos.s is unfinished but even this far allows lilo to be used on an + MSDOS filesystem floppy. + +> Changed ld to _check_ the magic on files inside an archive, this cures + the problem caused by long names inserted by gnu-ar. Also it notices + if an archive has been included in an archive and will link that too. + +> Changed ld to do a final check that it knows what sort of a.out.h file + it's got, if this fails '-N' is disabled. + +> Ld changed so for 16 bit exes the heap is limited to 32k. + +> getcwd and execvp added, sash should now work. Also added to the 386-lib + except execvp won't run scripts without '#!' + +> Nasty bug with syscalls of > 3 args in 386 code fixed, none of them would + have been working correctly. + For version 0.0.8. > Christoph Lameter <clameter@debian.org> has provided a patch for diff --git a/Libc_version b/Libc_version index d169b2f..c5d54ec 100644 --- a/Libc_version +++ b/Libc_version @@ -1 +1 @@ -0.0.8 +0.0.9 @@ -5,10 +5,15 @@ WALLP =-Wtraditional -Wshadow -Wid-clash-14 -Wpointer-arith \ -Wnested-externs -Winline # unproto is yukky, I've included '-w' in the local makefile. -WALL=-Wstrict-prototypes -CCFLAGS =-Wall $(WALL) -O2 -fno-strength-reduce +WALL =-Wstrict-prototypes +ifeq ($(CC),cc) CC =gcc +CCFLAGS =-Wall $(WALL) -O2 -fno-strength-reduce +else +CCFLAGS =-O +endif + CFLAGS =$(CCFLAGS) LDFLAGS =-s @@ -8,11 +8,12 @@ LIBS2= libbsd LIBS= libc $(LIBS2) EXTRAS= man dis88 doselks TESTDIRS= tests -DISTFILES=Makefile Make.defs README Changes README.ash Libc_version make_bcc.bat +DISTFILES=Makefile Make.defs README Changes Libc_version Uninstall DISTDIRS= $(LIBS2) elksemu $(TESTDIRS) $(EXTRAS) +DOSBITS= mkcompile compile.bat later.c default: dummy - @echo You have to do make install as root + @echo "You have to do 'make install' as root" @echo Or: @echo @echo '$ make bcc' @@ -21,19 +22,32 @@ default: dummy @echo '$ su -c "make install-lib"' @echo '$ make elksemu' @echo '$ su -c "make install-emu"' + @echo '$ su -c "make install-man"' @echo @echo 'Other libraries are built with:' @echo '$ su -c "make install-lib2"' @echo - @echo 'Others pieces are: "make tests" and "make extras"' + @echo "Or do 'make install-all' for _everything_" dummy: @if [ -f .runme ] ; then sh .runme ; rm .runme ; fi -install: install-bcc install-lib install-emu +install: install-bcc install-lib install-emu install-man # Do _everything_! -install-all: realclean config install install-lib2 install-extras realclean +install-all: + make realclean + make config + make install-bcc + make install-man + make install-lib-fast + make install-lib-dos + make install-lib-bios + make install-lib-386 + make install-lib + make install-emu + make -C dis88 install + make realclean config: make -C libc config @@ -110,6 +124,9 @@ install-emu: dummy ( echo 'Must do "make library" first' && exit 1 ) make -C elksemu install +install-man: dummy + make -C man install + install-extras: dummy @for i in $(EXTRAS) ; do make -C $$i install || exit 1; done @@ -1,6 +1,6 @@ This is a development environment for ELKS-86 -To install the basic environment you have to do make install as root +To install the basic environment you have to do 'make install' as root Or: $ make bcc @@ -11,7 +11,8 @@ $ make elksemu $ su -c "make install-emu" All from the top directory. -Once this is done new files will be /lib/elksemu, /usr/bcc/* and /usr/bin/bcc +Once this is done new files will be /lib/elksemu, /usr/bcc/*, /usr/bin/bcc +and /usr/bin/as86_encap. The manual pages in the man subdirectory are a start as some pages matched to these programs, there are also some hints for using as86 well. @@ -22,7 +23,7 @@ libraries _and_ include files are compied to these locations by install. After this you may want to install the other libraries, 'fast', 'MSDOS', 'standalone' and Linux-i386. -$ su -c "make install-lib" +$ su -c "make install-lib2" Use these libraries like this: 'FAST' $ bcc -Mf prog.c -o prog @@ -37,17 +38,17 @@ convert them to an odd ELF executable with: $ bcc -N -3 prog.c -o prog $ objcopy -O elf32-i386 prog +If you want to install everything in one go just login as root an do: +$ make install-all + The as86 and ld86 with this are _different_ from the ones needed for the linux-i386 kernel but can replace them, the kernel-i386 ones _will_ _not_ work correctly here! Unfortunatly, the DOSEMU folks have been using the '-r' option of ld86 This version does accept '-r' but it generates _LINUX_ a.out object files. -I think they should really be using 'as86_encap'. - -To compile the various tools as Linux-8086 binaries cd into the relevent -directory and do a "make clean ; make" from there. -Bcc _WILL_ now work this way! Yippee! :-) +I think they should really be using 'as86_encap'. Neverthless this ld86 +will call a program called /usr/bin/ld86r if it's given -r without -N. I _strongly_ suggest you install the kernel patch or load the module in the elksemu directory in your Linux-i386 kernel, it makes things _much_ diff --git a/README.debian b/README.debian deleted file mode 100644 index 42fb799..0000000 --- a/README.debian +++ /dev/null @@ -1,14 +0,0 @@ -ELKS for Debian ---------------- -All the binaries have been precompile for you and installed with the -package. For reference/Documentation purposes the complete sourcecode -is included which you are looking at right now. - -Read the Documentation in this directory to get you going with ELKS. - -There are also manpages for - -as86, ld86, bcc, bcc-cc1 and dis88 included but they might not be current -since they come from bcc for FreeBSD. - -Christoph Lameter <clameter@debian.org> diff --git a/as/Makefile b/as/Makefile index 736d144..3fb2551 100644 --- a/as/Makefile +++ b/as/Makefile @@ -2,12 +2,13 @@ ifneq ($(TOPDIR),) include $(TOPDIR)/Make.defs else -CC=bcc -LDFLAGS=-s +CFLAGS=-O +LIBDIR=/usr/bin +BINDIR=/usr/bin endif # Temp needed for libc-5.4.7 -CFLAGS+=-Dwarn=as_warn +CFLAGS+= -Dwarn=as_warn OBJS =as.o assemble.o error.o express.o \ genbin.o genlist.o genobj.o gensym.o \ @@ -27,11 +28,6 @@ install: all install -m 755 tmp $(BINDIR)/as86_encap -@rm -f tmp -# typeconv.o: dummy -# -cp -p ../ld/typeconv.o . - -dummy: - clean: rm -f *.o as86 @@ -8,6 +8,4 @@ Accept gas format. Decide how to choose between 8-bit and 32-bit branches. 16-bit branches in 32-bit mode are unusable because top 16 bits of PC are messed up. -Limit insns to specified processor (warn for 386 insns on 8086). - Buffer for printing of listing. @@ -42,7 +42,7 @@ char **argv; { #ifdef __AS386_16__ heapptr = sbrk(0); - heapend = ((char*)&argc) - STAKSIZ; + heapend = ((char*)&argc) - STAKSIZ - 16; brk(heapend); if(sbrk(0) != heapend) as_abort("Cannot allocate memory"); @@ -64,6 +64,7 @@ char **argv; initsource(); /* only nec to init for unsupported mem file */ typeconv_init(BIG_ENDIAN, LONG_BIG_ENDIAN); warn.global = TRUE; /* constant */ + last_pass=1; process_args(argc, argv); initscan(); @@ -118,6 +119,7 @@ PUBLIC void initp1p2() { register struct lc_s *lcp; + dirty_pass = 0; ifflag = TRUE; pedata = UNDBIT; /* program entry point not defined */ blockstak = hid_blockstak + MAXBLOCK; @@ -155,6 +157,11 @@ char **argv; char *arg; bool_t isnextarg; char *nextarg = 0; + int opened_file = 0; + +#ifdef I80386 + setcpu(0xF); +#endif if (argc <= 1) usage(); @@ -175,11 +182,13 @@ char **argv; switch (arg[1]) { #ifdef I80386 - case '0': + case '0': case '1': case '2': idefsize = defsize = 0x2; + setcpu(arg[1]-'0'); break; case '3': idefsize = defsize = 0x4; + setcpu(0xF); break; case 'a': asld_compatible = TRUE; @@ -199,6 +208,7 @@ char **argv; #ifdef I80386 case 'j': jumps_long = TRUE; + ++last_pass; break; #endif case 'l': @@ -257,9 +267,18 @@ char **argv; as_abort("source file name too long"); infiln = infil0 = 1; infil = open_input(strcpy(filnamptr, arg)); + opened_file = 1; } } while (--argc != 1); + if( !opened_file ) + { + infiln = infil0 = 1; + infil = open_input(strcpy(filnamptr, "-")); + } +#ifdef I80386 + origcpuid = cpuid; +#endif inidata = (~binaryg & inidata) | (RELBIT | UNDBIT); } /* IMPBIT from inidata unless binaryg */ diff --git a/as/as86_encap b/as/as86_encap index 8e5d4ab..4d50e23 100644 --- a/as/as86_encap +++ b/as/as86_encap @@ -19,6 +19,7 @@ trap "rm -f _$$.* ; exit 99" 1 2 3 15 LIBDIR='%%LIBDIR%%' # Set by make install +[ -d "$LIBDIR" ] || LIBDIR=/usr/bin IFILE="$1" OFILE="$2" @@ -39,7 +40,7 @@ $LIBDIR/as86 "$@" "$IFILE" -b _$$.bin -s _$$.sym || RV=$? [ "$RV" = 0 ] && { ( - cat _$$.sym + sort _$$.sym echo %%%% od -v -t uC _$$.bin ) | \ @@ -75,7 +76,13 @@ $LIBDIR/as86 "$@" "$IFILE" -b _$$.bin -s _$$.sym || RV=$? flg==1 { if(NF == 0) next; printf " "; - for(i=2;i<=NF;i++) { printf("%3d,", $i); bincount++; } + for(i=2;i<=NF;i++) { + if( $i >= 32 && $i <= 127 && $i != 39 && $i != 92 ) + printf("\047%c\047,", $i); + else + printf("%3d,", $i); + bincount++; + } printf "\n"; } END { diff --git a/as/as86_to_data b/as/as86_to_data new file mode 100644 index 0000000..ded1f0e --- /dev/null +++ b/as/as86_to_data @@ -0,0 +1,93 @@ +#!/bin/sh - +# +# This file is simply an example of what can be done using the new binary +# and symbol table output functions. It produces a byte array with the +# symbols in the object as array references within it. +# +# The output is a Linux OMAGIC binary created by ld86 -N, this means the +# object can be linked directly to C-functions created by the same GCC that +# compiled ld86. +# +# Use it in a makefile: +# +# .s86.o: +# as86_to_data $*.s86 $*.o $(AS86FLAGS) +# + +[ $# -lt 2 ] && { + echo "Usage: `basename $0` infile outfile [as86 opts]" 1>&2 + exit 1 +} + +trap "rm -f _$$.* ; exit 99" 1 2 3 15 + +LIBDIR='%%LIBDIR%%' # Set by make install +[ -d "$LIBDIR" ] || LIBDIR=/usr/bin + +IFILE="$1" +OFILE="$2" + +shift ; shift +RV=0 + +$LIBDIR/as86 "$@" "$IFILE" -b _$$.bin -s _$$.sym || RV=$? + +[ "$RV" = 0 ] && { + ( + cat _$$.sym + echo %%%% + od -v -t uC _$$.bin + echo %%%% + ) | \ + awk > _$$.v ' BEGIN{ + startaddr=""; + printf ".text\n.data\n"; + } + /^%%%%$/ { flg++; + next; + } + flg==0 { + if(NF == 0) next; + if( substr($2,1,4) == "0000" ) $2=substr($2,5); + if( $1 == "+" && $4 == "$start" ) + { + if( $2 != "0000" ) startaddr=" - $" $2; + } + else if( substr($3, 1, 1) == "E" && $4 != "start" && $4 != "size" && $4 != "data" ) + { + printf "export _%s\n", $4 + printf "_%s = * + $%s%s\n\n", $4, $2, startaddr; + } + next; + } + flg==1 { + if(NF <= 1) next; + printf " .byte "; + for(i=2;i<NF;i++) printf("%3d,", $i); + printf("%3d", $NF); + printf "\n"; + } + ' + RV=$? +} + +[ "$RV" = 0 ] || { rm -f _$$.* ; exit $RV ; } + +# If you want to see the assembler. +# cp _$$.v `basename $2 .o`.asm + +$LIBDIR/as86 -o _$$.o86 _$$.v || RV=$? + +[ "$RV" = 0 ] || { rm -f _$$.* ; exit $RV ; } + +$LIBDIR/ld86 -r -N _$$.o86 -o _$$.o || RV=$? + +[ "$RV" = 0 ] || { rm -f _$$.* ; exit $RV ; } + +if [ "X$OFILE" = "X-" ] +then cat _$$.o +else mv -f _$$.o "$OFILE" || RV=$? +fi + +rm -f _$$.* +exit $RV diff --git a/as/assemble.c b/as/assemble.c index 1992068..c631905 100644 --- a/as/assemble.c +++ b/as/assemble.c @@ -9,6 +9,7 @@ #include "scan.h" PRIVATE bool_t nocolonlabel; /* set for labels not followed by ':' */ +PRIVATE offset_t oldlabel = 0; PRIVATE void (*routine) P((void)); PRIVATE pfv rout_table[] = { @@ -163,6 +164,13 @@ PUBLIC void assemble() if (nocolonlabel) error(NEEDENDLABEL); #endif + if( label->value_reg_or_op.value != oldlabel) + { + dirty_pass = TRUE; + if( pass == last_pass ) + error(UNSTABLE_LABEL); + } + label->type |= LABIT; /* confirm, perhaps redundant */ if (label->type & REDBIT) { @@ -203,6 +211,7 @@ PRIVATE void asline() fqflag = #endif fdflag = fcflag = FALSE; + cpuwarn(); readline(); getsym(); if (sym != IDENT) /* expect label, mnemonic or macro */ @@ -219,6 +228,8 @@ PRIVATE void asline() else if (!(symptr->type & (MACBIT | MNREGBIT))) /* not macro, op, pseudo-op or register, expect label */ { + oldlabel = symptr->value_reg_or_op.value; + if ((nocolonlabel = (*lineptr - ':')) == 0) /* exported label? */ { sym = COLON; @@ -229,6 +240,26 @@ PRIVATE void asline() if (symptr->type & REDBIT) labelerror(RELAB); label = symptr; + +#if 0 +if(pass==last_pass) +{ + if( ((label->data^lcdata)&~FORBIT) || label->value_reg_or_op.value != lc) + { + printf("Movement %x:%d -> %x:%d\n", + label->data, + label->value_reg_or_op.value, + lcdata, + lc); + } +} +#endif + /* This is a bit dodgy, I think it's ok but ... */ + if (pass && (label->data & RELBIT)) + { + label->data = (label->data & FORBIT) | lcdata; + label->value_reg_or_op.value = lc; + } } else if (checksegrel(symptr)) { @@ -239,12 +270,13 @@ PRIVATE void asline() symptr->type |= EXPBIT; #endif #endif - symptr->data = (symptr->data & FORBIT) | lcdata; /* remember if forward referenced */ + symptr->data = (symptr->data & FORBIT) | lcdata; symptr->value_reg_or_op.value = lc; /* unless changed by EQU,COMM or SET */ label = symptr; } + getsym(); if (sym != IDENT) { @@ -294,12 +326,17 @@ PRIVATE void asline() } } opcode = symptr->value_reg_or_op.op.opcode; +#ifdef I80386 + needcpu((page==0 && ((opcode&0xF0) == 0x60||(opcode&0xF6)==0xC0))?1:0); +#endif routine = rout_table[symptr->value_reg_or_op.op.routine]; getsym(); (*routine)(); if (sym != EOLSYM) error(JUNK_AFTER_OPERANDS); #ifdef I80386 + needcpu(page==PAGE1_OPCODE?2:0); + if (aprefix != 0) ++mcount; if (oprefix != 0) @@ -45,7 +45,7 @@ #ifdef __AS386_16__ # undef INBUFSIZE # define INBUFSIZE 512 -# define STAKSIZ 256 /* table grows up to stack less this */ +# define STAKSIZ 512 /* table grows up to stack less this */ #endif /* booleans */ @@ -325,9 +325,11 @@ enum JUNK_AFTER_OPERANDS, ALREADY, + UNSTABLE_LABEL, /* Warnings. */ -#define MINWARN SHORTB +#define MINWARN CPUCLASH + CPUCLASH, SHORTB }; @@ -84,6 +84,8 @@ PRIVATE char *errormessage[] = "illegal FP register pair", "junk after operands", "already defined", + "label moved in last pass, add -j?", + "instruction illegal for current cpu", "short branch would do", "unknown error", }; diff --git a/as/express.c b/as/express.c index 70f5081..3e93061 100644 --- a/as/express.c +++ b/as/express.c @@ -27,7 +27,7 @@ PUBLIC void chkabs() { if (lastexp.data & RELBIT) { - if (pass != 0) + if (pass == last_pass) error(ABSREQ); expundefined(); } @@ -56,7 +56,7 @@ PUBLIC void nonimpexpres() PUBLIC void showrelbad() { - if (pass != 0) + if (pass == last_pass) error(RELBAD); expundefined(); } @@ -281,7 +281,7 @@ PUBLIC void factor() symptr->data |= FORBIT; lastexp.sym = symptr; } - if (pass == 0) + if (pass != last_pass) { lastexp.data = symptr->data & (FORBIT | RELBIT | UNDBIT | SEGM); @@ -333,7 +333,7 @@ PUBLIC void factor() case STAR: /* context-sensitive, STAR means location counter here */ lastexp.offset = lc; - if ((lastexp.data = lcdata) & UNDBIT && pass != 0) + if ((lastexp.data = lcdata) & UNDBIT && pass == last_pass) experror(UNBLAB); getsym(); return; diff --git a/as/genlist.c b/as/genlist.c index 37d2caf..e1c43ea 100644 --- a/as/genlist.c +++ b/as/genlist.c @@ -349,7 +349,7 @@ PRIVATE void listerrors() do { #ifdef I80386 - if(column) + if(errcol != CODE_LIST_LENGTH) { writenl(); paderrorline(1); } @@ -363,7 +363,7 @@ PRIVATE void listerrors() ++errcol; } #endif - while (column < errptr->position) + while (errptr && errptr->position < 132 && column < errptr->position) { ++column; if (*linep++ == '\t') /* next tab (standard tabs only) */ @@ -381,7 +381,7 @@ PRIVATE void listerrors() } } #ifdef I80386 - writec('^'); + writec('^'); ++errcol; #else if (errcolw < errcol) /* position under error on new line */ { diff --git a/as/globvar.h b/as/globvar.h index e44d88d..aed6aed 100644 --- a/as/globvar.h +++ b/as/globvar.h @@ -80,6 +80,8 @@ EXTERN opcode_t page; EXTERN opcode_t opcode; EXTERN opcode_t postb; /* postbyte, 0 if none */ EXTERN unsigned char pcrflag; /* OBJ_RMASK set if addressing is PC-relative */ +EXTERN int last_pass; /* Pass number of last pass */ +EXTERN int dirty_pass; /* Set if this pass had a label movement */ #ifdef I80386 @@ -91,8 +93,28 @@ EXTERN opcode_t oprefix; /* operand size prefix or 0 */ EXTERN opcode_t sprefix; /* segment prefix or 0 */ EXTERN opcode_t sib; /* scale-index-base byte */ +EXTERN int cpuid; /* Assembler instruction limit flag */ +EXTERN int origcpuid; /* Assembler instruction limit flag */ + #endif /* miscellaneous */ extern char hexdigit[]; + +/* cpuid functions */ +#ifdef I80386 +#ifndef __AS386_16__ +#define iscpu(x) (cpuid>=(x)) +#define needcpu(x) do{ if(cpuid<(x)) {error(CPUCLASH); cpuid|=0x10;} }while(0) +#define setcpu(x) (cpuid=(x)) +#define cpuwarn() (cpuid&=0xF) +#endif +#endif + +#ifndef setcpu +#define needcpu(x) +#define setcpu(x) +#define cpuwarn() +#endif + @@ -105,7 +105,7 @@ PUBLIC void pmacro() error(LABEXP); else if (symptr->type & LABIT || symptr->data & FORBIT) error(RELAB); - else if (pass == 0 || symptr->type & REDBIT) + else if (pass != last_pass || symptr->type & REDBIT) /* copy on pass 0, also pass 1 if redefined */ { saving = TRUE; @@ -12,7 +12,7 @@ #define is8bitadr(offset) ((offset_t) offset < 0x100) #define is8bitsignedoffset(offset) ((offset_t) (offset) + 0x80 < 0x100) -#define pass2 pass +#define pass2 (pass==last_pass) FORWARD void mshort2 P((void)); FORWARD reg_pt regchk P((void)); @@ -537,6 +537,7 @@ register struct ea_s *eap; postb = baseind16[eap->base + 0x4 * eap->index]; } } + needcpu(asize==4?3:0); if (asize != defsize) aprefix = 0x67; if (eap->base == NOREG) @@ -867,6 +868,7 @@ register struct ea_s *eap; if ((eap->size = regsize[eap->base]) > 0x1 && eap->size != defsize) oprefix = 0x66; eap->displ = lastexp; + needcpu(eap->size==4?3:0); return; } if (sym != lindirect) @@ -906,6 +908,7 @@ register struct ea_s *eap; } if (sym == STAR) { + needcpu(3); /* context-sensitive, STAR means scaled here*/ if (eap->index == NOREG && eap->base == ESPREG) { @@ -958,6 +961,8 @@ register struct ea_s *eap; eap->indcount = 0x1; /* compatibility kludge */ if (!leading_displ) eap->displ = lastexp; + + needcpu(eap->size==4?3:0); } PRIVATE void getimmed(eap, immed_count) @@ -1076,7 +1081,11 @@ PUBLIC void mbcc() kgerror(REL_REQ); else { +#ifdef iscpu + if (iscpu(3)) +#else if (defsize != 0x2) +#endif { page = PAGE1_OPCODE; ++mcount; @@ -1100,6 +1109,7 @@ PUBLIC void mbcc() PUBLIC void mbswap() { + needcpu(4); ++mcount; Gd(&target); opcode |= rm[target.base]; @@ -1192,7 +1202,8 @@ PUBLIC void mcall() } else if (opcode == JMP_SHORT_OPCODE) { - if (jumps_long) + if (jumps_long && + (pass!=0 && !is8bitsignedoffset(lastexp.offset - lc - 2))) { opcode = JMP_OPCODE; lbranch(0x83); @@ -1250,7 +1261,12 @@ PUBLIC void mcalli() if (!(lastexp.data & (FORBIT | RELBIT | UNDBIT)) && tsize == 0x2 && (offset_t) (lastexp.offset + 0x8000L) >= 0x18000L) - datatoobig(); + { + tsize=4; + if( tsize != defsize ) oprefix = 0x66; + /* datatoobig(); */ + } + needcpu(tsize==4?3:0); mcount += tsize; source.size = 0x2; buildimm(&source, FALSE); @@ -1287,6 +1303,7 @@ PUBLIC void menter() mcount += 2; lastexp = target.displ; /* getimmed(&source) wiped it out */ } + needcpu(1); } /* arpl r/m16,r16 (Intel manual opcode chart wrongly says EwRw) */ @@ -1638,6 +1655,7 @@ PUBLIC void mgroup2() opcode |= 0x2; else if (source.displ.offset != 0x1) { + needcpu(1); opcode -= 0x10; source.size = 0x1; buildimm(&source, FALSE); @@ -1649,6 +1667,7 @@ PUBLIC void mgroup2() PUBLIC void mgroup6() { + needcpu(2); ++mcount; Ew(&target); oprefix = 0x0; @@ -1659,6 +1678,7 @@ PUBLIC void mgroup6() PUBLIC void mgroup7() { + needcpu(2); /* I think INVLPG is actually 386 */ ++mcount; if (opcode == 0x20 || opcode == 0x30) { @@ -1679,6 +1699,7 @@ PUBLIC void mgroup7() PUBLIC void mgroup8() { + needcpu(3); ++mcount; Ev(&target); getcomma(); @@ -1707,6 +1728,7 @@ PUBLIC void mgroup8() PUBLIC void mGvEv() { + needcpu(2); ++mcount; Gv(&source); getcomma(); @@ -1760,6 +1782,7 @@ PUBLIC void mimul() yes_samesize(); if (sym != COMMA && (target.indcount != 0x0 || target.base != NOREG)) { + needcpu(3); page = PAGE1_OPCODE; ++mcount; opcode = 0xAF; @@ -1856,6 +1879,7 @@ PUBLIC void minher32() minher(); if (defsize != 0x4) oprefix = 0x66; + needcpu(3); } /* AAD, AAM */ @@ -1904,16 +1928,44 @@ PUBLIC void mjcc() kgerror(REL_REQ); else { + needcpu(3); page = PAGE1_OPCODE; ++mcount; opcode += 0x10; lbranch(0x84); } } - else if (jumps_long && opcode < 0x80) /* above 0x80 means loop, not long */ - mbcc(); - else + else if (!jumps_long || opcode > 0x80) /* above 0x80 means loop, not long */ mshort(); + else /* mbcc */ + { + getea(&target); + lastexp = target.displ; + + if (pass!=0 && !is8bitsignedoffset(lastexp.offset - lc - 2)) + { + if (target.indcount >= 0x2 || target.base != NOREG) + kgerror(REL_REQ); + + aprefix = opcode ^ 0x1; /* kludged storage for short branch + over */ + oprefix = defsize + 0x1; + mcount += 0x2; + opcode = JMP_OPCODE; + lbranch(0x83); + mcount -= 0x2; + } + else + { + /* 8 bit */ + if (lastexp.data & IMPBIT) + { + error(NONIMPREQ); + lastexp.data = FORBIT | UNDBIT; + } + mshort2(); + } + } } /* JCXZ, JECXZ */ @@ -1966,6 +2018,7 @@ PUBLIC void mmov() if ((source.size = displsize(&target)) != defsize) aprefix = 0x67; mcount += source.size; + needcpu(source.size==4?3:0); } else if (source.base == NOREG) { @@ -1982,6 +2035,7 @@ PUBLIC void mmov() { if (isspecreg(source.base)) { + needcpu(3); page = PAGE1_OPCODE; ++mcount; opcode = 0x0; @@ -2169,6 +2223,7 @@ PUBLIC void msetcc() PUBLIC void mshdouble() { + needcpu(3); ++mcount; Ev(&target); getcomma(); @@ -2834,11 +2889,17 @@ PRIVATE reg_pt regchk() { if (symptr->data & REGBIT) { + int regno = symptr->value_reg_or_op.reg; #ifdef I80386 - if (symptr->value_reg_or_op.reg == ST0REG && !fpreg_allowed) + if (regno == ST0REG && !fpreg_allowed) error(FP_REG_NOT_ALLOWED); + + /* Check cpu */ + needcpu((regno==FSREG||regno==GSREG)?3:0); + needcpu((regno>=EAXREG && regno<=ESPREG)?3:0); + needcpu((regno>=CR0REG && regno<=TR7REG)?3:0); #endif - return symptr->value_reg_or_op.reg; + return regno; } } else if (!(symptr->type & (LABIT | MACBIT | VARBIT))) @@ -31,7 +31,7 @@ int defval; { int newcount; - if (flagptr->global &&pass != 0) + if (flagptr->global && pass == last_pass) { /* bump semaphore count by an expression (default 1), */ /* then set currentflag iff semaphore count is plus */ @@ -192,7 +192,7 @@ unsigned char labits; nonimpexpres(); lastexp.data |= olddata & FORBIT; /* take all but FORBIT from expression */ - if (oldtype & LABIT && !(olddata & UNDBIT)) + if (oldtype & LABIT && !(olddata & UNDBIT) && !pass) /* this is a previously defined label */ /* @@ -228,7 +228,7 @@ unsigned char impbits; error(ALREADY); else if (impbits != 0) { - if (pass != 0) + if (pass == last_pass) ; else if (symptr->type & (EXPBIT | LABIT)) symptr->type |= EXPBIT; @@ -241,7 +241,7 @@ unsigned char impbits; } else { - if (pass != 0) + if (pass == last_pass) { if (!(symptr->type & LABIT)) error(UNLAB); @@ -676,7 +676,7 @@ PUBLIC void pexport() PUBLIC void pfail() { - if(pass) error(FAILERR); + if(pass==last_pass) error(FAILERR); } /* FCB pseudo-op */ @@ -1000,6 +1000,18 @@ PUBLIC void pwarn() PUBLIC void puse16() { defsize = 2; +#ifdef iscpu + if( sym != EOLSYM ) + { + absexpres(); + if (lastexp.data & UNDBIT) + return; + if( lastexp.offset > 15 ) + setcpu((int) lastexp.offset / 100); + else + setcpu((int) lastexp.offset); + } +#endif } /* USE16 pseudo-op */ @@ -1007,6 +1019,19 @@ PUBLIC void puse16() PUBLIC void puse32() { defsize = 4; +#ifdef iscpu + if(!iscpu(3)) setcpu(3); + if( sym != EOLSYM ) + { + absexpres(); + if (lastexp.data & UNDBIT) + return; + if( lastexp.offset > 15 ) + setcpu((int) lastexp.offset / 100); + else + setcpu((int) lastexp.offset); + } +#endif } #endif @@ -1042,7 +1067,7 @@ PUBLIC void showlabel() PRIVATE void setloc(seg) unsigned seg; { - if (pass != 0 && seg != (lcdata & SEGM)) + if (pass == last_pass && seg != (lcdata & SEGM)) putobj((opcode_pt) (seg | OBJ_SET_SEG)); { register struct lc_s *lcp; diff --git a/as/readsrc.c b/as/readsrc.c index b539abd..82be10f 100644 --- a/as/readsrc.c +++ b/as/readsrc.c @@ -208,7 +208,7 @@ PUBLIC void pproceof() error(EOFBLOCK); if (iflevel != 0) error(EOFIF); - if (lcdata & UNDBIT) + if (pass && (lcdata & UNDBIT)) error(EOFLC); lcptr->data = lcdata; lcptr->lc = lc; @@ -232,29 +232,40 @@ PUBLIC void pproceof() lseek(infil, getstak->position, 0); #endif } - else if (!pass) + else if (pass!=last_pass) { - pass = TRUE; - objheader(); /* while pass 1 data all valid */ + pass++; + if( last_pass>2 && last_pass<30 && dirty_pass && pass==last_pass ) + last_pass++; + + if( pass==last_pass ) + objheader(); /* while pass 1 data all valid */ binmbuf = 0; /* reset zero variables */ maclevel = iflevel = blocklevel = totwarn = toterr = linum = macnum = 0; initp1p2(); /* reset other varaiables */ - binaryc = binaryg; + if(pass==last_pass) + binaryc = binaryg; #ifdef I80386 defsize = idefsize; + cpuid = origcpuid; #endif - list.current = list.global; - maclist.current = maclist.global; + if(pass==last_pass) + { + list.current = list.global; + maclist.current = maclist.global; + warn.current = TRUE; + if (warn.semaphore < 0) + warn.current = FALSE; + } - warn.current = TRUE; - if (warn.semaphore < 0) - warn.current = FALSE; if (infiln != 0) infil = open_input(filnamptr); else eol_ptr=0; - binheader(); + + if(pass==last_pass) + binheader(); } else finishup(); diff --git a/bcc/Makefile b/bcc/Makefile index 7e601af..a95c5bc 100644 --- a/bcc/Makefile +++ b/bcc/Makefile @@ -2,17 +2,20 @@ # bcc Makefile # $Id$ # -BCCDEFS=-DLOCALPREFIX="\"/usr/bcc\"" -DDEFARCH=0 ifneq ($(TOPDIR),) include $(TOPDIR)/Make.defs -BCCDEFS=-DLOCALPREFIX="\"$(BCCROOT)\"" -DDEFARCH=0 +BCCDEFS =-DLOCALPREFIX="\"$(BCCROOT)\"" -DDEFARCH=0 else -CC=bcc -Mf -CFLAGS= -LDFLAGS=-s -BINDIR=/usr/bin -LIBDIR=/usr/lib/bcc +CFLAGS =-O +LDFLAGS =-s +BINDIR =/usr/bin +LIBDIR =/usr/lib/bcc +BCCDEFS =-DLOCALPREFIX="\"/usr\"" -DDEFARCH=0 +endif + +ifeq ($(CC),bcc) +CFLAGS=-Mf endif OBJS = bcc-cc1.o codefrag.o debug.o declare.o express.o exptree.o floatop.o \ @@ -39,33 +39,35 @@ #define EXESUF #endif -#define AS "as86" EXESUF #define BAS86 #define BCC86 -#define CC1 "bcc-cc1" EXESUF + +#define AS "as86" EXESUF +#define CC1 "bcc-cc1" EXESUF #define CC1_MINUS_O_BROKEN FALSE -#define CPP "bcc-cc1" EXESUF /* normally a link to /usr/bin/bcc-cc1 */ -#define CPPFLAGS "-E" -#define CRT0 "crt0.o" -#define GCC "gcc" -#define LD "ld86" EXESUF -#ifndef NO_ANSI_SUPPORT -#define UNPROTO "unproto" EXESUF -#endif +#define CPP "bcc-cc1" EXESUF +#define CPPFLAGS "-E" +#define CRT0 "crt0.o" +#define GCC "gcc" +#define LD "ld86" EXESUF +#define UNPROTO "unproto" EXESUF + #ifdef MSDOS -#define STANDARD_CRT0_0_PREFIX LOCALPREFIX "/lib/" -#define STANDARD_EXEC_PREFIX LOCALPREFIX "/lib/" -#define STANDARD_EXEC_PREFIX_2 "/bin/" -#define DEFAULT_INCLUDE "-I" LOCALPREFIX "/libc/include" -#define DEFAULT_LIBDIR0 "-L" LOCALPREFIX "/lib/" +#define STANDARD_CRT0_0_PREFIX "~/lib/" +#define STANDARD_CRT0_3_PREFIX "~/lib/i386/" +#define STANDARD_EXEC_PREFIX "~/lib/" +#define STANDARD_EXEC_PREFIX_2 "~/bin/" +#define DEFAULT_INCLUDE "-I~/include" +#define DEFAULT_LIBDIR0 "-L~/lib/" +#define DEFAULT_LIBDIR3 "-L~/lib/i386/" #else -#define STANDARD_CRT0_0_PREFIX LOCALPREFIX "/lib/bcc/i86/" -#define STANDARD_CRT0_3_PREFIX LOCALPREFIX "/lib/bcc/i386/" -#define STANDARD_EXEC_PREFIX LOCALPREFIX "/lib/bcc/" -#define STANDARD_EXEC_PREFIX_2 "/usr/bin/" -#define DEFAULT_INCLUDE "-I" LOCALPREFIX "/include" -#define DEFAULT_LIBDIR0 "-L" LOCALPREFIX "/lib/bcc/i86/" -#define DEFAULT_LIBDIR3 "-L" LOCALPREFIX "/lib/bcc/i386/" +#define STANDARD_CRT0_0_PREFIX "~/lib/bcc/i86/" +#define STANDARD_CRT0_3_PREFIX "~/lib/bcc/i386/" +#define STANDARD_EXEC_PREFIX "~/lib/bcc/" +#define STANDARD_EXEC_PREFIX_2 "/usr/bin/" +#define DEFAULT_INCLUDE "-I~/include" +#define DEFAULT_LIBDIR0 "-L~/lib/bcc/i86/" +#define DEFAULT_LIBDIR3 "-L~/lib/bcc/i386/" #endif #ifdef CCC @@ -76,7 +78,7 @@ #define CC1_MINUS_O_BROKEN TRUE #undef STANDARD_CRT0_0_PREFIX #undef STANDARD_CRT0_3_PREFIX -#define STANDARD_CRT0_PREFIX "/usr/local/lib/i386/" +#define STANDARD_CRT0_PREFIX "~/lib/i386/" #endif /* CCC */ #ifdef MC6809 @@ -87,7 +89,7 @@ #undef STANDARD_CRT0_0_PREFIX #undef STANDARD_CRT0_3_PREFIX #undef STANDARD_EXEC_PREFIX -#define STANDARD_EXEC_PREFIX LOCALPREFIX "/lib/bcc/m09/" +#define STANDARD_EXEC_PREFIX "~/lib/bcc/m09/" #endif /* MC6809 */ #define ALLOC_UNIT 16 /* allocation unit for arg arrays */ @@ -114,9 +116,7 @@ struct prefix_s PRIVATE struct arg_s asargs = { AS, }; PRIVATE struct arg_s ccargs = { CC1, CC1_MINUS_O_BROKEN, }; PRIVATE struct arg_s cppargs = { CPP, }; -#ifndef NO_ANSI_SUPPORT PRIVATE struct arg_s unprotoargs = { UNPROTO, TRUE }; -#endif #ifdef STANDARD_CRT0_PREFIX PRIVATE struct prefix_s crt0_prefix = { STANDARD_CRT0_PREFIX, }; #endif @@ -137,6 +137,8 @@ PRIVATE struct arg_s tmpargs; /* = empty */ PRIVATE char *tmpdir; PRIVATE unsigned verbosity; /* = 0 */ +PRIVATE char * localprefix = LOCALPREFIX; + #ifdef REDECLARE_STDC_FUNCTIONS void exit P((int status)); char *getenv P((const char *name)); @@ -162,6 +164,7 @@ int main P((int argc, char **argv)); FORWARD void addarg P((struct arg_s *argp, char *arg)); FORWARD void addprefix P((struct prefix_s *prefix, char *name)); +FORWARD char *expand_tilde P((char * str, int canfree)); FORWARD void fatal P((char *message)); FORWARD char *fixpath P((char *path, struct prefix_s *prefix, int mode)); FORWARD void killtemps P((void)); @@ -170,6 +173,9 @@ FORWARD char *my_mktemp P((void)); FORWARD void my_unlink P((char *name)); FORWARD void outofmemory P((char *where)); FORWARD int run P((char *in_name, char *out_name, struct arg_s *argp)); +#ifdef MSDOS +FORWARD void reset_localprefix P((void)); +#endif FORWARD void set_trap P((void)); FORWARD void show_who P((char *message)); FORWARD void startarg P((struct arg_s *argp)); @@ -202,9 +208,7 @@ char **argv; char *bits_arg; #endif bool_T cc_only = FALSE; -#ifndef NO_ANSI_SUPPORT bool_T ansi_pass = FALSE; -#endif #ifdef CCC bool_T cpp_pass = TRUE; #else @@ -223,6 +227,7 @@ char **argv; #ifdef BAS86 bool_T gnu_objects = FALSE; #endif + bool_T aswarn = FALSE; char *in_name; int length; unsigned ncisfiles = 0; @@ -243,13 +248,15 @@ char **argv; addarg(&asargs, "-j"); #endif addarg(&asargs, "-u"); - addarg(&asargs, "-w"); #ifdef BAS86 addarg(&ldrargs, "-r"); addarg(&ldrargs, "-N"); /* GCC uses native objects */ /* GCC also uses 386 how to add -3 too ? */ #endif +#ifdef MSDOS + reset_localprefix(); +#endif /* Pass 1 over argv to gather compile options. */ for (; --argc != 0;) { @@ -328,6 +335,12 @@ char **argv; case 'v': ++verbosity; break; + case 'w': + aswarn=FALSE; + break; + case 'W': + ++aswarn; + break; case 'I': add_default_inc = 0; break; @@ -341,7 +354,6 @@ char **argv; else if (arg[0] == '-') switch (arg[1]) { -#ifndef NO_ANSI_SUPPORT case 'a': if (!strcmp(arg, "-ansi")) { @@ -352,7 +364,6 @@ char **argv; addarg(&ccargs, "-D__STDC__=0"); #endif addarg(&cppargs, "-D__STDC__=0"); -#endif } break; case 'A': @@ -456,12 +467,19 @@ char **argv; if (errcount != 0) exit(1); + if( !aswarn ) + addarg(&asargs, "-w"); if( patch_exe ) addarg(&ldargs, "-s"); #ifdef BCC86 else if( !bits32 ) addarg(&ldargs, "-i"); #endif + if (verbosity > 2) + { + show_who("localprefix set to "); + writesn(localprefix); + } if ((temp = getenv("BCC_EXEC_PREFIX")) != NUL_PTR) addprefix(&exec_prefix, temp); if( add_default_inc ) @@ -491,11 +509,13 @@ char **argv; #ifdef BAS86 ldrargs.prog = fixpath(ldrargs.prog, &exec_prefix, X_OK); #endif -#ifndef NO_ANSI_SUPPORT unprotoargs.prog=fixpath(unprotoargs.prog, &exec_prefix, X_OK); -#endif if (tmpdir == NUL_PTR && (tmpdir = getenv("TMPDIR")) == NUL_PTR) +#ifdef MSDOS + tmpdir = "."; +#else tmpdir = "/tmp"; +#endif if (prep_only && !prep_line_numbers) addarg(&cppargs, "-P"); @@ -558,18 +578,13 @@ char **argv; { if (cpp_pass) { -#ifndef NO_ANSI_SUPPORT if (prep_only && !ansi_pass) -#else - if (prep_only) -#endif out_name = f_out; else out_name = my_mktemp(); if (run(in_name, out_name, &cppargs) != 0) continue; in_name = out_name; -#ifndef NO_ANSI_SUPPORT if (ansi_pass) { if (prep_only) @@ -581,7 +596,6 @@ char **argv; continue; in_name=out_name; } -#endif } ext = 'i'; } @@ -719,6 +733,8 @@ char **argv; if( patch_exe && link_st == 0 ) linux_patch(f_out); } + if( runerror && f_out != NUL_PTR ) + my_unlink(f_out); killtemps(); return runerror ? 1 : 0; } @@ -810,6 +826,44 @@ static struct aout_exec { close(fd); } +#ifdef MSDOS +PRIVATE void reset_localprefix() +{ + char *ptr, *temp; + + temp = stralloc(progname); + if( (ptr = strrchr(temp, '\\')) != 0 + && temp<ptr-4 && strncmp(ptr-4, "\\BIN", 4) == 0 ) + { + ptr[-4] = 0; + localprefix = temp; + if (verbosity > 2) + { + show_who("localprefix is now "); + writesn(localprefix); + } + } + else + free(temp); +} +#endif + +PRIVATE char * expand_tilde(str, canfree) +char * str; +int canfree; +{ + char * newstr; + char * ptr = strchr(str, '~'); + if( ptr == 0 ) return str; + + newstr = my_malloc(strlen(str)+strlen(localprefix), "expand tilde"); + if( ptr!=str ) memcpy(newstr, str, ptr-str); + strcpy(newstr+(ptr-str), localprefix); + strcat(newstr, ptr+1); + if( canfree ) free(str); + return newstr; +} + PRIVATE void addarg(argp, arg) register struct arg_s *argp; char *arg; @@ -828,7 +882,7 @@ char *arg; outofmemory("addarg"); argp->argv = new_argv; } - argp->argv[argp->argc] = arg; + argp->argv[argp->argc] = expand_tilde(arg, 0); argp->argv[argp->argc = new_argc] = NUL_PTR; } @@ -843,7 +897,7 @@ char *name; else { new_prefix = my_malloc(sizeof *new_prefix, "addprefix"); - new_prefix->name = name; + new_prefix->name = expand_tilde(name, 0); new_prefix->next = NUL_PTR; while (prefix->next != NUL_PTR) prefix = prefix->next; @@ -875,11 +929,10 @@ int mode; writes("readable file "); else writes("executable file "); - writes(path); - writes(" in "); - writesn(prefix->name); } - ppath = stralloc2(prefix->name, path); + ppath = expand_tilde(stralloc2(prefix->name, path), 1); + if (verbosity > 2) + writesn(ppath); if (access(ppath, mode) == 0) return ppath; free(ppath); @@ -912,7 +965,11 @@ PRIVATE char *my_mktemp() char *template; static unsigned tmpnum; +#ifdef MSDOS + p = template = stralloc2(tmpdir, "/$$YYYXXX"); +#else p = template = stralloc2(tmpdir, "/bccYYYYXXXX"); +#endif p += strlen(p); digits = getpid(); @@ -944,6 +1001,7 @@ char *name; show_who("unlinking "); writesn(name); } + if (verbosity > 4) return; if (unlink(name) < 0) { if( !runerror || verbosity > 1) @@ -1069,7 +1127,14 @@ PRIVATE void set_trap() PRIVATE void show_who(message) char *message; { +#ifdef MSDOS + char * ptr; + ptr = strrchr(progname, '\\'); + if(ptr) ptr++; else ptr = progname; + writes(ptr); +#else writes(progname); +#endif writes(": "); writes(message); } diff --git a/bcc/bcc.exe b/bcc/bcc.exe Binary files differnew file mode 100644 index 0000000..db47d08 --- /dev/null +++ b/bcc/bcc.exe diff --git a/bcc/output.c b/bcc/output.c index 514dc8e..fb7f1bf 100644 --- a/bcc/output.c +++ b/bcc/output.c @@ -291,14 +291,14 @@ int c; inc bx mov [_outbufptr],bx cmp bx,[_outbuftop] - jae OUTBYTE.FLUSH + jae Outbyte.Flush # if !__FIRST_ARG_IN_AX__ jmp dx # else ret # endif -OUTBYTE.FLUSH: +Outbyte.Flush: # if !__FIRST_ARG_IN_AX__ push dx # endif @@ -320,10 +320,10 @@ OUTBYTE.FLUSH: inc ecx mov [_outbufptr],ecx cmp ecx,[_outbuftop] - jae OUTBYTE.FLUSH + jae Outbyte.Flush ret -OUTBYTE.FLUSH: +Outbyte.Flush: br _flushout # endasm #endif /* __AS386_32__ */ diff --git a/bcc/preproc.c b/bcc/preproc.c index 6cace78..030214b 100644 --- a/bcc/preproc.c +++ b/bcc/preproc.c @@ -68,11 +68,7 @@ PRIVATE void asmcontrol() asmmode = TRUE; if (orig_cppmode) -#ifndef ASM_BARE - outstr("#asm"); -#else outstr("#asm\n"); -#endif else { outstr("!BCC_ASM\n"); diff --git a/bootblocks/Makefile b/bootblocks/Makefile index 0ed6e1d..9a4ccd9 100644 --- a/bootblocks/Makefile +++ b/bootblocks/Makefile @@ -14,7 +14,7 @@ nothing: all: makeboot monitor.out bin CSRC=minix.c -SSRC=tarboot.s tiny.s com_bcc.s tich.s sysboot.s bootlist.s +SSRC=tarboot.s skip.s com_bcc.s tich.s sysboot.s bootlist.s mbr.s msdos.s encap: $(SSRC:s=v) $(CSRC:c=v) bin: $(SSRC:s=bin) $(CSRC:c=bin) @@ -39,13 +39,16 @@ minix.s: minix.c makeboot: tarboot.v sysboot.v makeboot.c $(HOSTCC) $(HOSTCCFLAGS) -o makeboot makeboot.c +dosboot: dosboot.c sysboot.v skip.v msdos.v + $(HOSTCC) $(HOSTCCFLAGS) -o dosboot dosboot.c + clean: - rm -f monitor makeboot minix.s *.o *.bin *.out *.lst *.sym *.v + rm -f monitor makeboot dosboot minix.s *.o *.bin *.out *.lst *.sym *.v tgz: minix.bin monitor.out makeboot tar cfV bootblocks.tar ENIAC monitor.out \ README Makefile \ - $(MSRC) standalone.c makeboot.c \ + $(MSRC) dosboot.c makeboot.c \ $(CSRC) $(SSRC) \ makeboot minix.bin makeboot bootblocks.tar @@ -53,7 +56,7 @@ tgz: minix.bin monitor.out makeboot distribution: tar czf /tmp/bootblocks.tar.gz README Makefile \ - $(MSRC) standalone.c makeboot.c \ + $(MSRC) dosboot.c makeboot.c \ $(CSRC) $(SSRC) .SUFFIXES: .bin .v diff --git a/bootblocks/bootlist.s b/bootblocks/bootlist.s index 889842a..9230796 100644 --- a/bootblocks/bootlist.s +++ b/bootblocks/bootlist.s @@ -11,6 +11,8 @@ ! Stack top is at abs location 64k. ! +! PS: This hasn't been tested much ... make that at all! + BOOTSEG = 0x07c0 LOADSEG = 0x07e0 ! Just after boot sector. @@ -24,7 +26,7 @@ reloc = 1 *linear ! Auto configure of bootpart. macro locn if *-start>?1 - fail + fail! ?1 endif .blkb ?1 + start-* mend diff --git a/bootblocks/com_bcc.s b/bootblocks/com_bcc.s index 26daff3..061575f 100644 --- a/bootblocks/com_bcc.s +++ b/bootblocks/com_bcc.s @@ -46,7 +46,7 @@ impure: ! ax is now offset 'tween CS&DS ! Check for overlap end_of_code: if end_of_code>hitme - fail + fail! At end_of_code endif .org ((ENDOFF)<<4)-1 diff --git a/bootblocks/dosboot.c b/bootblocks/dosboot.c new file mode 100644 index 0000000..72b8d25 --- /dev/null +++ b/bootblocks/dosboot.c @@ -0,0 +1,72 @@ + +#include <stdio.h> + +#include "sysboot.v" +#include "msdos.v" +#include "skip.v" + +char buffer[512]; + +struct bblist { + char * name; + char * data; + char * desc; +} bblocks[] = { + { "bare", sysboot_data, "Bare bootblock, lockup if booted" }, + { "dosfs", msdos_data, "Boots file BOOTFILE.SYS from dosfs" }, + { "skip", skip_data, "Bypasses floppy boot with message" }, + 0 +}; + +char * progname = ""; + +main(argc, argv) +int argc; +char ** argv; +{ + FILE * fd; + struct bblist *ptr = bblocks; + int i; + + progname = argv[0]; + + if( argc != 3 ) Usage(); + + for(;ptr->name; ptr++) if( strcmp(argv[1], ptr->name) == 0 ) break; + if( ptr->name == 0 ) Usage(); + + fd = fopen(argv[2], "r+"); + if( fd == 0 ) + { + fprintf(stderr, "Cannot open %s\n", argv[2]); + exit(1); + } + if( fread(buffer, 512, 1, fd) != 1 ) + { + fprintf(stderr, "Cannot read boot block\n"); + exit(1); + } + for(i=0; i<sysboot_dosfs_stat; i++) + buffer[i] = ptr->data[i]; + for(i=sysboot_codestart; i<512; i++) + buffer[i] = ptr->data[i]; + + rewind(fd); + if( fwrite(buffer, 512, 1, fd) != 1 ) + { + fprintf(stderr, "Cannot write boot block\n"); + exit(1); + } + fclose(fd); +} + +Usage() +{ + struct bblist *ptr = bblocks; + + fprintf(stderr, "Usage: %s bootname /dev/fd0\n", progname); + fprintf(stderr, "Blocks\n"); + for(;ptr->name; ptr++) + fprintf(stderr, "\t%s\t%s\n", ptr->name, ptr->desc); + exit(1); +} diff --git a/bootblocks/mbr.s b/bootblocks/mbr.s new file mode 100644 index 0000000..e190be2 --- /dev/null +++ b/bootblocks/mbr.s @@ -0,0 +1,153 @@ +! +! This is a 'Master Boot Record' following the MSDOS 'standards'. +! This BB successfully boots MSDOS or Linux. +! +! In addition it has the facility to load and execute a small program +! (of 8 extents) before the boot blocks are checked. +! + +! Lowest available is $0500, MSDOS appears to use $0600 ... I wonder why? +ORGADDR=$0500 +preboot=1 ! Include the pre-boot loader ? + +! Include standard layout +org ORGADDR +include sysboot.s + +org ORGADDR+$7 +.ascii "ELKS MBR Copyright 1996, Robert de Bath" + +! Start after dos fsstat data, not strictly required. +org codestart + cli ! Assume _nothing_! + cld + mov bx,#$7C00 ! Pointer to start of BB. + xor ax,ax ! Segs all to zero + mov ds,ax + mov es,ax + mov ss,ax + mov sp,bx ! SP Just below BB + mov cx,#$100 ! Move 256 words + mov si,bx ! From default BB + mov di,#ORGADDR ! To the correct address. + rep + movsw + jmpi cont,#0 ! Set CS:IP correct. +cont: + sti ! Let the interrupts back in. + +! +! Next check for a pre-boot load. + + if preboot + push bx + mov si,#pre_boot_table + lodsw + mov di,ax ! First word is execute address +more_boot: + lodsw + test ax,ax + jz load_done + mov bx,ax ! word 1 address + lodsw + mov cx,ax ! word 2 CX, head/sector + lodsw + mov dx,ax ! word 3 DX, drive, cylinder + lodsw ! word 4 AX, $02, sector count + int $13 + jnc more_boot ! This doesn't retry, with a HD it shouldn't be bad. + jc disk_error +load_done: + call [di] +exec_done: + pop bx + endif + +! Now check the partition table, must use SI as pointer cause that's what the +! partition boot blocks expect. + + mov si,#partition_1 +check_active: + cmp byte [si],#$80 ! Flag for activated partition + jz found_active + add si,#partition_2-partition_1 + cmp si,#bootblock_magic + jnz check_active + + mov si,#no_bootpart ! Message & boot + jmp no_boot + +found_active: + mov di,#6 ! Max retries, int list says 3 ... double it + mov dx,[si] ! dh = Drive head, dl = $80 ie HD drive 0 + mov cx,[si+2] ! cx = Sector & head encoded for int $13 + ! bx is correct +retry: + mov ax,#$0201 ! Read 1 sector + int $13 ! Disk read. + jnc sector_loaded + +! Error, reset and retry + xor ax,ax + int $13 ! Disk reset + + dec di + jnz retry ! Try again + +disk_error: + mov si,#disk_read_error + jmp no_boot ! Sorry it ain't gonna work. + +sector_loaded: + mov di,#$7DFE ! End of sector loaded + cmp [di],#$AA55 ! Check for magic + jnz check_active ! No? Try next partition. + + mov bp,si ! LILO says some BBs use bp rather than si + jmpi #$7C00,#0 ! Go! + +! Fatal errors ........... +no_boot: ! SI now has pointer to error message + lodsb + cmp al,#0 + jz EOS + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp no_boot +EOS: + cmp si,#press_end ! After msg output 'press key' message + jz keyboot + mov si,#press_key + jmp no_boot + +keyboot: ! Wait for a key then reboot + xor ax,ax + int $16 + int $19 ! This should be OK as we haven't touched anything. + jmpi $0,$FFFF ! Wam! Try or die! + +no_bootpart: + .asciz "No bootable partition" +disk_read_error: + .asciz "Error loading system" +press_key: + .asciz "\r\nPress a key to reboot" +press_end: + + if preboot +return: + ret + +export pre_boot_table +pre_boot_table: + .word return + .word 0 + endif + +! Now make sure this isn't to big! + if *>partition_1 + fail! Partition overlap + endif + +!THE END diff --git a/bootblocks/msdos.s b/bootblocks/msdos.s new file mode 100644 index 0000000..1e71f31 --- /dev/null +++ b/bootblocks/msdos.s @@ -0,0 +1,253 @@ +! +! This is a bootblock to load an execute a standalone program from an +! MSDOS filesystem on a floppy disk. +! +! The program is divided into two parts, the first 512 bytes contains a +! loader to fetch one block from a file called 'BOOTFILE.SYS' from the +! root directory of the disk. The second 512, which is stored in this file, +! loads the executable using functions supplied by the first. +! +! The 2nd part is loaded as if it's a floppy boot block and can be used to +! store, for instance, a LILO boot block to let LILO boot from an MSDOS +! floppy. +! +! The second part is NOT yet complete! +! +ORGADDR=$0500 + +use16 + +! Absolute position macro, fails if code before it is too big. +macro locn + if *-start>?1 + fail! *-start>?1 + endif + .blkb ?1 + start-* +mend + +org ORGADDR +start: +include sysboot.s + +! Data into the temp area, 30 clear bytes +org floppy_temp +root_count: .blkw 1 +old_bpb: .blkw 2 +bios_disk: .blkb 12 + + locn(codestart-start) + + cld ! Assume _nothing_! + mov bx,#$7C00 ! Pointer to start of BB. + xor ax,ax ! Segs all to zero + mov ds,ax + mov es,ax + mov ss,ax + mov sp,bx ! SP Just below BB + mov cx,#$100 ! Move 256 words + mov si,bx ! From default BB + mov di,#ORGADDR ! To the correct address. + rep + movsw + jmpi cont,#0 ! Set CS:IP correct. +cont: + sti ! Let the interrupts back in. + +! Need to fix BPB for fd0 to correct sectors (Like linux bootblock does) + mov di,#bios_disk + mov bp,#0x78 +! 0:bx is parameter table address + push ds + lds si,[bp] + +! ds:si is source + + mov cx,#6 +! copy 12 bytes + push di + rep + movsw + pop di + pop ds + +! New BPB is 0:di + mov [bp],di + mov 2[bp],ax + + mov al,[dos_spt] + mov 4[di],al + +! For each sector in root dir +! For each dir entry +! If entry name is == boot_name +! then load and call sector + + ! First dir = dos_fatlen*dos_nfat+dos_resv + mov ax,[dos_fatlen] + mov dl,[dos_nfat] + xor dh,dh + mul dx + add ax,[dos_resv] + mov di,ax + ! DI is sector number of first root dir sector. + + mov ax,[dos_nroot] + mov [root_count],ax + add ax,#15 + mov cl,#4 + shr ax,cl + add ax,di + mov bp,ax ! bp is first data sector. + +nextsect: + call linsect + mov ax,#$0201 + int $13 + jc floppy_error + +! ... foreach dir entry + mov si,bx +nextentry: + +! test entry name + push si + push di + mov di,#boot_name + mov cx,#11 + rep + cmpsb + pop di + pop si + je got_entry + + add si,#32 + cmp si,#512 + jnz nextentry + + inc di + sub [root_count],#16 + jp nextsect + jmp no_system + +got_entry: + mov ax,[si+26] ! Cluster number of start of file + test ax,ax + jz no_system ! Make sure we have a block. + + mov di,ax ! Save the cluster number we are loading. + call linclust + + mov ax,#$0201 + int $13 + jc floppy_error + + mov bx,#7 + mov ax,#$0E3E + int $10 + + jmpi $7C00,0 ! No magics, just go. + +! Convert a cluster number into a CHS in CX:DX +linclust: + sub ax,#2 + mov dl,[dos_clust] + xor dh,dh + mul dx + add ax,bp + mov di,ax + ! JMP linsect ... + +! +! This function converts a linear sector number in DI +! into a CHS representation in CX:DX +! +linsect: + xor dx,dx + mov ax,di + div [dos_spt] + inc dx + mov cl,dl ! Sector num + xor dx,dx ! Drive 0 + shr ax,#1 ! Assume dos_heads == 2 + adc dh,#0 ! Head num + mov ch,al ! Cylinder + ret + +no_system: +floppy_error: + + mov si,#error_msg +no_boot: ! SI now has pointer to error message + lodsb + cmp al,#0 + jz EOS + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp no_boot +EOS: + xor ax,ax + int $16 + int $19 ! This should be OK as we haven't touched anything. + jmpi $0,$FFFF ! Wam! Try or die! + +error_msg: + .asciz "\r\nError during initial boot\r\nPress a key:" + +export boot_name +boot_name: + .ascii "BOOTFILESYS" +name_end: +! NNNNNNNNEEE +! +!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +! +! Part 2, loaded like a boot block by part 1 +! ... Here we will allow some assumptions (cause we've set them) +fat_table = ORGADDR+$400 ! Where to load the fat + +locn(512) +part2_addr: + push di + mov cx,#$100 ! Move 256 words + mov si,#$7C00 ! From default BB + mov di,#part2_addr ! To the correct address. + rep + movsw + jmpi cont2,#0 ! Set CS:IP correct. +cont2: + +! 1) Load FAT + ! This assumes all of FAT1 is on the first track, this is normal + mov ax,[dos_fatlen] + mov ah,#2 + mov bx,#fat_table + mov cx,[dos_resv] ! Fat starts past bootblock + inc cx + xor dx,dx ! Head zero + int $13 + !jc floppy_error + + mov bx,#$7C00 + pop di ! Cluster to start load. + + ! load whole cluster +next_cluster: + + + call next_fat + cmp di,#0 + jnz next_cluster + br maincode + +next_fat: + !mov ax,di + !mov bx,ax + !shr ax,#1 + !add bx,ax + + +! The end ... place a marker. +locn(1023) + .byte $FF +maincode: diff --git a/bootblocks/relocate.c b/bootblocks/relocate.c index 121699e..37396a1 100644 --- a/bootblocks/relocate.c +++ b/bootblocks/relocate.c @@ -58,6 +58,7 @@ unsigned newseg; /* The actual jump ... */ memseg = newseg; + #asm mov ax,ds mov bx,cs diff --git a/bootblocks/skip.s b/bootblocks/skip.s new file mode 100644 index 0000000..8de5ada --- /dev/null +++ b/bootblocks/skip.s @@ -0,0 +1,83 @@ +! +! This floppy bootblock bypasses the floppy boot ... +! + +BOOTDISK = 0x80 +ORGADDR = $0600 + +use16 +org ORGADDR +start: +include sysboot.s + +org codestart + cli ! Assume _nothing_! + cld + mov bx,#$7C00 ! Pointer to start of BB. + xor ax,ax ! Segs all to zero + mov ds,ax + mov es,ax + mov ss,ax + mov sp,bx ! SP Just below BB + mov cx,#$100 ! Move 256 words + mov si,bx ! From default BB + mov di,#ORGADDR ! To the correct address. + rep + movsw + jmpi cont,#0 ! Set CS:IP correct. +cont: + sti ! Let the interrupts back in. + + mov si,#mesg + call prtmsg + + mov di,#5 +hcode: + mov ax,#$0201 ! Read 1 sector + mov cx,#$0001 ! From sector 1 + mov dx,#BOOTDISK ! Of the hard drive head zero + int $13 + jc error + jmpi $7c00,0 + +error: + mov si,#mesg2 + call prtmsg + + dec di + jz reboot + + mov si,#mesg3 + call prtmsg + jmp hcode + + if BOOTDISK = 0x80 +mesg: .asciz "Bypassing floppy boot\r\n" + else +mesg: .asciz "Booting drive two\r\n" + endif + +mesg2: .asciz "Disk error\r\n" +mesg3: .asciz "Retrying\r\n" +mesg4: .asciz "Press a key:" + +prtmsg: + lodsb + cmp al,#0 + jz EOS + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp prtmsg +EOS: + ret + +reboot: + mov si,#mesg4 + call prtmsg + + xor ax,ax + int $16 + int $19 ! This should be OK as we haven't touched anything. + jmpi $0,$FFFF ! Wam! Try or die! + diff --git a/bootblocks/standalone.c b/bootblocks/standalone.c deleted file mode 100644 index 57634d4..0000000 --- a/bootblocks/standalone.c +++ /dev/null @@ -1,309 +0,0 @@ - -#include <errno.h> -#asm -entry _int_80 ! Tell ld86 we really do need this file. - ! then call the init stuff before main. - - loc 1 ! Make sure the pointer is in the correct segment -auto_func: ! Label for bcc -M to work. - .word _pre_main ! Pointer to the autorun function - .word no_op ! Space filler cause segs are padded to 4 bytes. - .text ! So the function after is also in the correct seg. -#endasm - -void int_80(); - -static void pre_main() -{ - /* Set the int 0x80 pointer to here */ - __set_es(0); - __doke_es(0x80*4+0, int_80); - __doke_es(0x80*4+2, __get_cs()); - bios_coninit(); -} - -void int_80() -{ -#asm -SYS_EXIT=1 -SYS_FORK=2 -SYS_READ=3 -SYS_WRITE=4 -SYS_OPEN=5 -SYS_CLOSE=6 -SYS_CHDIR=12 -SYS_LSEEK=19 -ENOSYS=38 - - push es - push si - push di - push dx - push cx - push bx - cmp ax,#SYS_READ - jne L1 - call _func_read - jmp L0 -L1: - cmp ax,#SYS_WRITE - jne L2 - call _func_write - jmp L0 -L2: - cmp ax,#SYS_LSEEK - jne L3 - call _func_lseek - jmp L0 -L3: - cmp ax,#SYS_EXIT - jne L4 - call _func_exit - jmp L0 -L4: - mov ax,#-ENOSYS -L0: - pop bx - pop cx - pop dx - pop di - pop si - pop es - iret -#endasm -} - -func_lseek() { return -38; } - -func_write(bx,cx,dx,di,si,es) -int bx,dx; -char * cx; -{ - register int v, c; - if(bx == 1 || bx == 2) - { - for(v=dx; v>0; v--) - { - c= *cx++; - if( c == '\n') bios_putc('\r'); - bios_putc(c); - } - return dx; - } - return -EBADF; -} - -func_read(bx,cx,dx,di,si,es) -int bx,dx; -char * cx; -{ - if(bx == 0) return read_line(cx, dx); - return -EBADF; -} - -read_line(buf, len) -char * buf; -int len; -{ - int ch; - int pos=0; - - if( len == 1 ) - { - buf[0]=((ch=bios_getc())&0xFF?ch&0xFF:((ch>>8)&0xFF|0x80)); - return 1; - } - - for(ch=0;;) - { - if(ch != '\003') - { - ch = bios_getc(); - if( pos == 0 && (ch&0xFF) == 0 ) - { - buf[0] = ((ch>>8)|0x80); - return 1; - } - ch &= 0x7F; - } - if( ch == '\r' ) - { - bios_putc('\r'); bios_putc('\n'); - buf[pos++] = '\n'; - return pos; - } - if( ch >= ' ' && ch != 0x7F && pos < len-1) - bios_putc(buf[pos++] = ch); - else if( (ch == '\003' || ch == '\b') && pos > 0 ) - { - bios_putc('\b'); bios_putc(' '); bios_putc('\b'); - pos--; - } - else if( ch == '\003' ) - return 0; - else - bios_putc('\007'); - } -} - -#define CTRL(x) ((x)&0x1F) -static int last_attr = 0x07; -static int con_mode; -static int con_size = 0x184F; -static int con_colour = 0; - -bios_coninit() -{ -#asm - mov ax,#$0F00 - int $10 - mov _con_mode,ax -#endasm - if( (con_mode &0xFF) > 39 ) con_size = (con_size&0xFF00) + (con_mode&0xFF); - if( (con_mode&0xFF00) != 0x700) - con_colour = 1; -} - -bios_putc(c) -int c; -{ -static char tbuf[3]; -static int tcnt=0; - if(tcnt) - { - tbuf[tcnt++] = c; - if( tcnt < 3 && (tbuf[0] != CTRL(']') || tbuf[1] < '`' || tbuf[1] > 'p')) - return; - if( tbuf[0] == CTRL('P') ) - { - if( tbuf[1] >= 32 && tbuf[1] <= 56 - && tbuf[2] >= 32 && tbuf[2] <= 111 ) - asm_cpos((tbuf[1]-32), (tbuf[2]-32)); - } - else - { - if( tbuf[1] >= '`' ) - last_attr = ( (tbuf[1]&0xF) | (last_attr&0xF0)); - else - last_attr = ( (tbuf[2]&0xF) | ((tbuf[1]&0xF)<<4)); - - if( !con_colour ) - last_attr = (last_attr&0x88) + ((last_attr&7)?0x07:0x70); - } - tcnt=0; - return; - } - if( c & 0xE0 ) { asm_colour(last_attr) ; asm_putc(c); } - else switch(c) - { - case CTRL('L'): - asm_cpos(0,0); - asm_cls(); - break; - case CTRL('P'): - case CTRL(']'): - tbuf[tcnt++] = c; - break; - default: - asm_putc(c); - break; - } - return; -} - -static asm_putc(c) -{ -#asm -#if !__FIRST_ARG_IN_AX__ - mov bx,sp - mov ax,[bx+2] -#endif - mov ah,#$0E - mov bx,#7 - int $10 -#endasm -} - -static asm_colour(c) -{ -#asm -#if __FIRST_ARG_IN_AX__ - mov bx,ax -#else - mov bx,sp - mov bx,[bx+2] -#endif - mov ah,#$08 - int $10 - mov ah,#$09 - mov cx,#1 - int $10 -#endasm -} - -static asm_cls() -{ -#asm - push bp ! Bug in some old BIOS's - !mov ax,#$0500 - !int $10 - mov ax,#$0600 - mov bh,_last_attr - mov cx,#$0000 - mov dx,_con_size - int $10 - pop bp -#endasm -} - -static asm_cpos(r,c) -{ -#asm -#if __FIRST_ARG_IN_AX__ - mov bx,sp - mov dh,al - mov ax,[bx+2] - mov dl,al -#else - mov bx,sp - mov ax,[bx+2] - mov dh,al - mov ax,[bx+4] - mov dl,al -#endif - mov ah,#$02 - mov bx,#7 - int $10 -#endasm -} - -bios_getc() -{ -#asm - xor ax,ax - int $16 -#endasm -} - -static void be_safe() -{ -#asm - iret -#endasm -} - -func_exit(bx,cx,dx,di,si,es) /* AKA reboot! */ -{ - __set_es(0); - __doke_es(0xE6*4+2,__get_cs()); - __doke_es(0xE6*4+0,be_safe); -#asm - mov ax,#$FFFF - int $E6 ! Try to exit DOSEMU - mov ax,#$0040 ! If we get here we're not in dosemu. - mov es,ax - seg es - mov [$72],#$1234 ! Warm reboot. - jmpi $0000,$FFFF -#endasm -} diff --git a/bootblocks/sysboot.s b/bootblocks/sysboot.s index 496b7a5..622488f 100644 --- a/bootblocks/sysboot.s +++ b/bootblocks/sysboot.s @@ -19,37 +19,41 @@ j codestart .blkb sysboot_start+3-* public dosfs_stat dosfs_stat: -.blkb 8 ! System ID -.word 0 ! Sector size -.byte 0 ! Cluster size -.word 0 ! Res-sector -.byte 0 ! FAT count -.word 0 ! Root dir entries -.word 0 ! Sector count (=0 if large FS) -.byte 0 ! Media code -.word 0 ! FAT length -.word 0 ! Sect/Track -.word 0 ! Heads -.long 0 ! Hidden sectors -! Here down is DOS 4+ -.long 0 ! Large FS sector count -.byte 0 ! Phys drive +dos_sysid: .blkb 8 ! System ID +dos_sect: .word 0 ! Sector size +dos_clust: .byte 0 ! Cluster size +dos_resv: .word 0 ! Res-sector +dos_nfat: .byte 0 ! FAT count +dos_nroot: .word 0 ! Root dir entries +dos_maxsect: .word 0 ! Sector count (=0 if large FS) +dos_media: .byte 0 ! Media code +dos_fatlen: .word 0 ! FAT length +dos_spt: .word 0 ! Sect/Track +dos_heads: .word 0 ! Heads +dos_hidden: .long 0 ! Hidden sectors + +! Here down is DOS 4+ and probably not needed for floppy boots. +floppy_temp: + +dos4_maxsect: .long 0 ! Large FS sector count +dos4_phy_drive: .byte 0 ! Phys drive .byte 0 ! Reserved .byte 0 ! DOS 4 -.long 0 ! Serial number -.blkb 11 ! Disk Label (DOS 4+) -.blkb 8 ! FAT type +dos4_serial: .long 0 ! Serial number +dos4_label: .blkb 11 ! Disk Label (DOS 4+) +dos4_fattype: .blkb 8 ! FAT type .blkb sysboot_start+0x3E-* public codestart codestart: - hlt + jmp codestart ! Partition table public partition_1 public partition_2 public partition_3 public partition_4 +public bootblock_magic .blkb sysboot_start+0x1BE-* partition_1: @@ -72,6 +76,7 @@ partition_4: .long 0 ! Linear position (0 based) .long 0 ! Linear length +bootblock_magic: .blkb sysboot_start+0x1FE-* .word 0xAA55 diff --git a/bootblocks/tarboot.s b/bootblocks/tarboot.s index ffa8db6..0fb85d3 100644 --- a/bootblocks/tarboot.s +++ b/bootblocks/tarboot.s @@ -25,7 +25,7 @@ DEBUG=1 ! Print dots ... macro locn if *-start>?1 - fail + fail! ?1 endif .blkb ?1 + start-* mend diff --git a/bootblocks/tiny.s b/bootblocks/tiny.s deleted file mode 100644 index 6090cd3..0000000 --- a/bootblocks/tiny.s +++ /dev/null @@ -1,55 +0,0 @@ -! -! This floppy bootblock bypasses the floppy boot ... -! - -BOOTSEG = 0x07c0 -BOOTDISK = 0x80 - -! Apparently on startup the only things we can assume are that we start at -! `start` (ABS addr $07C00) and we`ll have a few bytes of stack storage... - -! So first set DS=ES= 0x07c0 - include sysboot.s - .blkb codestart-* - -start: - mov ax,#BOOTSEG - mov ds,ax - mov es,ax - -! Print 'mesg' - mov ah,#0x03 ! read cursor pos - xor bh,bh - int 0x10 - - mov cx,#(emesg-mesg) - mov bp,#mesg - mov bx,#$7 ! page 0, attribute 7 (normal) - mov ax,#$1301 ! write string, move cursor - int $10 - -nogood: - xor si,si - mov di,#$0200 - mov cx,#$0100 - rep - movw - jmpi hcode,#BOOTSEG+$20 - -hcode: - mov ax,#$0201 ! Read 1 sector - xor bx,bx ! In the boot area - mov cx,#$0001 ! From sector 1 - mov dx,#BOOTDISK ! Of the hard drive head zero - int $13 - jc hcode ! Keep trying forever! - jmpi $7c00,0 - - -mesg: - if BOOTDISK = 0x80 -.ascii "Bypassing floppy boot\r\n" - else -.ascii "Booting drive two\r\n" - endif -emesg: diff --git a/compile.bat b/compile.bat new file mode 100644 index 0000000..814548e --- /dev/null +++ b/compile.bat @@ -0,0 +1,508 @@ +@echo off
+if not exist later.exe cl -nologo -O later.c %LIB%\setargv.obj -link /NOE
+
+later bcc/bcc.obj bcc/bcc.c
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -c -Fobcc\bcc.obj bcc\bcc.c
+if errorlevel 1 goto exit_now
+later bin/bcc.exe bcc/bcc.obj
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -o bin\bcc.exe bcc\bcc.obj %LIB%\setargv.obj -link /NOE
+if errorlevel 1 goto exit_now
+
+later bcc/bcc-cc1.obj bcc/bcc-cc1.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/bcc-cc1.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/bcc-cc1.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/bcc-cc1.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\bcc-cc1.obj bcc\bcc-cc1.c
+if errorlevel 1 goto exit_now
+later bcc/assign.obj bcc/assign.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/assign.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/assign.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/assign.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\assign.obj bcc\assign.c
+if errorlevel 1 goto exit_now
+later bcc/codefrag.obj bcc/codefrag.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/codefrag.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/codefrag.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/codefrag.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\codefrag.obj bcc\codefrag.c
+if errorlevel 1 goto exit_now
+later bcc/debug.obj bcc/debug.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/debug.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/debug.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/debug.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\debug.obj bcc\debug.c
+if errorlevel 1 goto exit_now
+later bcc/declare.obj bcc/declare.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/declare.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/declare.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/declare.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\declare.obj bcc\declare.c
+if errorlevel 1 goto exit_now
+later bcc/express.obj bcc/express.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/express.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/express.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/express.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\express.obj bcc\express.c
+if errorlevel 1 goto exit_now
+later bcc/exptree.obj bcc/exptree.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/exptree.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/exptree.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/exptree.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\exptree.obj bcc\exptree.c
+if errorlevel 1 goto exit_now
+later bcc/floatop.obj bcc/floatop.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/floatop.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/floatop.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/floatop.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\floatop.obj bcc\floatop.c
+if errorlevel 1 goto exit_now
+later bcc/function.obj bcc/function.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/function.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/function.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/function.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\function.obj bcc\function.c
+if errorlevel 1 goto exit_now
+later bcc/gencode.obj bcc/gencode.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/gencode.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/gencode.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/gencode.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\gencode.obj bcc\gencode.c
+if errorlevel 1 goto exit_now
+later bcc/genloads.obj bcc/genloads.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/genloads.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/genloads.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/genloads.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\genloads.obj bcc\genloads.c
+if errorlevel 1 goto exit_now
+later bcc/glogcode.obj bcc/glogcode.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/glogcode.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/glogcode.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/glogcode.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\glogcode.obj bcc\glogcode.c
+if errorlevel 1 goto exit_now
+later bcc/hardop.obj bcc/hardop.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/hardop.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/hardop.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/hardop.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\hardop.obj bcc\hardop.c
+if errorlevel 1 goto exit_now
+later bcc/input.obj bcc/input.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/input.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/input.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/input.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\input.obj bcc\input.c
+if errorlevel 1 goto exit_now
+later bcc/label.obj bcc/label.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/label.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/label.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/label.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\label.obj bcc\label.c
+if errorlevel 1 goto exit_now
+later bcc/loadexp.obj bcc/loadexp.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/loadexp.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/loadexp.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/loadexp.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\loadexp.obj bcc\loadexp.c
+if errorlevel 1 goto exit_now
+later bcc/longop.obj bcc/longop.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/longop.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/longop.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/longop.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\longop.obj bcc\longop.c
+if errorlevel 1 goto exit_now
+later bcc/output.obj bcc/output.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/output.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/output.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/output.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\output.obj bcc\output.c
+if errorlevel 1 goto exit_now
+later bcc/preproc.obj bcc/preproc.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/preproc.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/preproc.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/preproc.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\preproc.obj bcc\preproc.c
+if errorlevel 1 goto exit_now
+later bcc/preserve.obj bcc/preserve.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/preserve.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/preserve.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/preserve.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\preserve.obj bcc\preserve.c
+if errorlevel 1 goto exit_now
+later bcc/scan.obj bcc/scan.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/scan.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/scan.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/scan.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\scan.obj bcc\scan.c
+if errorlevel 1 goto exit_now
+later bcc/softop.obj bcc/softop.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/softop.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/softop.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/softop.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\softop.obj bcc\softop.c
+if errorlevel 1 goto exit_now
+later bcc/state.obj bcc/state.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/state.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/state.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/state.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\state.obj bcc\state.c
+if errorlevel 1 goto exit_now
+later bcc/table.obj bcc/table.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/table.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/table.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/table.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\table.obj bcc\table.c
+if errorlevel 1 goto exit_now
+later bcc/type.obj bcc/type.c bcc/align.h bcc/byteord.h bcc/condcode.h bcc/const.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/type.obj bcc/gencode.h bcc/input.h bcc/label.h bcc/os.h bcc/output.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/type.obj bcc/parse.h bcc/proto.h bcc/reg.h bcc/sc.h bcc/scan.h bcc/sizes.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bcc/type.obj bcc/table.h bcc/type.h bcc/types.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fobcc\type.obj bcc\type.c
+if errorlevel 1 goto exit_now
+later lib/bcc-cc1.exe bcc/bcc-cc1.obj bcc/assign.obj bcc/codefrag.obj bcc/debug.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later lib/bcc-cc1.exe bcc/declare.obj bcc/express.obj bcc/exptree.obj bcc/floatop.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later lib/bcc-cc1.exe bcc/function.obj bcc/gencode.obj bcc/genloads.obj bcc/glogcode.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later lib/bcc-cc1.exe bcc/hardop.obj bcc/input.obj bcc/label.obj bcc/loadexp.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later lib/bcc-cc1.exe bcc/longop.obj bcc/output.obj bcc/preproc.obj bcc/preserve.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later lib/bcc-cc1.exe bcc/scan.obj bcc/softop.obj bcc/state.obj bcc/table.obj bcc/type.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 goto done_bcc-cc1
+if exist doslib.lib del doslib.lib
+lib doslib.lib +bcc\assign.obj +bcc\codefrag.obj +bcc\debug.obj; >NUL
+lib doslib.lib +bcc\declare.obj +bcc\express.obj +bcc\exptree.obj; >NUL
+lib doslib.lib +bcc\floatop.obj +bcc\function.obj +bcc\gencode.obj; >NUL
+lib doslib.lib +bcc\genloads.obj +bcc\glogcode.obj +bcc\hardop.obj; >NUL
+lib doslib.lib +bcc\input.obj +bcc\label.obj +bcc\loadexp.obj +bcc\longop.obj; >NUL
+lib doslib.lib +bcc\output.obj +bcc\preproc.obj +bcc\preserve.obj; >NUL
+lib doslib.lib +bcc\scan.obj +bcc\softop.obj +bcc\state.obj +bcc\table.obj; >NUL
+lib doslib.lib +bcc\type.obj; >NUL
+cl -Ml -o lib\bcc-cc1.exe bcc\bcc-cc1.obj doslib.lib
+if errorlevel 1 goto exit_now
+if exist doslib.lib del doslib.lib
+if exist doslib.bak del doslib.bak
+:done_bcc-cc1
+
+later as/as.obj as/as.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/as.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/as.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\as.obj as\as.c
+if errorlevel 1 goto exit_now
+later as/assemble.obj as/assemble.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/assemble.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/assemble.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\assemble.obj as\assemble.c
+if errorlevel 1 goto exit_now
+later as/error.obj as/error.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/error.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/error.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\error.obj as\error.c
+if errorlevel 1 goto exit_now
+later as/express.obj as/express.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/express.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/express.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\express.obj as\express.c
+if errorlevel 1 goto exit_now
+later as/genbin.obj as/genbin.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/genbin.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/genbin.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\genbin.obj as\genbin.c
+if errorlevel 1 goto exit_now
+later as/genlist.obj as/genlist.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/genlist.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/genlist.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\genlist.obj as\genlist.c
+if errorlevel 1 goto exit_now
+later as/genobj.obj as/genobj.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/genobj.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/genobj.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\genobj.obj as\genobj.c
+if errorlevel 1 goto exit_now
+later as/gensym.obj as/gensym.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/gensym.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/gensym.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\gensym.obj as\gensym.c
+if errorlevel 1 goto exit_now
+later as/keywords.obj as/keywords.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/keywords.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/keywords.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\keywords.obj as\keywords.c
+if errorlevel 1 goto exit_now
+later as/macro.obj as/macro.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/macro.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/macro.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\macro.obj as\macro.c
+if errorlevel 1 goto exit_now
+later as/mops.obj as/mops.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/mops.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/mops.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\mops.obj as\mops.c
+if errorlevel 1 goto exit_now
+later as/pops.obj as/pops.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/pops.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/pops.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\pops.obj as\pops.c
+if errorlevel 1 goto exit_now
+later as/readsrc.obj as/readsrc.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/readsrc.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/readsrc.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\readsrc.obj as\readsrc.c
+if errorlevel 1 goto exit_now
+later as/scan.obj as/scan.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/scan.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/scan.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\scan.obj as\scan.c
+if errorlevel 1 goto exit_now
+later as/table.obj as/table.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/table.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/table.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\table.obj as\table.c
+if errorlevel 1 goto exit_now
+later as/typeconv.obj as/typeconv.c as/address.h as/byteord.h as/const.h as/file.h as/flag.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/typeconv.obj as/globvar.h as/macro.h as/opcode.h as/proto.h as/scan.h as/source.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later as/typeconv.obj as/syshead.h as/type.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Foas\typeconv.obj as\typeconv.c
+if errorlevel 1 goto exit_now
+later bin/as.exe as/as.obj as/assemble.obj as/error.obj as/express.obj as/genbin.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bin/as.exe as/genlist.obj as/genobj.obj as/gensym.obj as/keywords.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bin/as.exe as/macro.obj as/mops.obj as/pops.obj as/readsrc.obj as/scan.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later bin/as.exe as/table.obj as/typeconv.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 goto done_as
+if exist doslib.lib del doslib.lib
+lib doslib.lib +as\assemble.obj +as\error.obj +as\express.obj +as\genbin.obj; >NUL
+lib doslib.lib +as\genlist.obj +as\genobj.obj +as\gensym.obj +as\keywords.obj; >NUL
+lib doslib.lib +as\macro.obj +as\mops.obj +as\pops.obj +as\readsrc.obj; >NUL
+lib doslib.lib +as\scan.obj +as\table.obj +as\typeconv.obj; >NUL
+cl -Ml -o bin\as.exe as\as.obj doslib.lib
+if errorlevel 1 goto exit_now
+if exist doslib.lib del doslib.lib
+if exist doslib.bak del doslib.bak
+:done_as
+
+later ld/ld.obj ld/ld.c ld/align.h ld/ar.h ld/bindef.h ld/byteord.h ld/config.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later ld/ld.obj ld/const.h ld/globvar.h ld/obj.h ld/syshead.h ld/type.h ld/x86_aout.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fold\ld.obj ld\ld.c
+if errorlevel 1 goto exit_now
+later ld/dumps.obj ld/dumps.c ld/align.h ld/ar.h ld/bindef.h ld/byteord.h ld/config.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later ld/dumps.obj ld/const.h ld/globvar.h ld/obj.h ld/syshead.h ld/type.h ld/x86_aout.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fold\dumps.obj ld\dumps.c
+if errorlevel 1 goto exit_now
+later ld/io.obj ld/io.c ld/align.h ld/ar.h ld/bindef.h ld/byteord.h ld/config.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later ld/io.obj ld/const.h ld/globvar.h ld/obj.h ld/syshead.h ld/type.h ld/x86_aout.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fold\io.obj ld\io.c
+if errorlevel 1 goto exit_now
+later ld/linksyms.obj ld/linksyms.c ld/align.h ld/ar.h ld/bindef.h ld/byteord.h ld/config.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later ld/linksyms.obj ld/const.h ld/globvar.h ld/obj.h ld/syshead.h ld/type.h ld/x86_aout.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fold\linksyms.obj ld\linksyms.c
+if errorlevel 1 goto exit_now
+later ld/readobj.obj ld/readobj.c ld/align.h ld/ar.h ld/bindef.h ld/byteord.h ld/config.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later ld/readobj.obj ld/const.h ld/globvar.h ld/obj.h ld/syshead.h ld/type.h ld/x86_aout.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fold\readobj.obj ld\readobj.c
+if errorlevel 1 goto exit_now
+later ld/table.obj ld/table.c ld/align.h ld/ar.h ld/bindef.h ld/byteord.h ld/config.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later ld/table.obj ld/const.h ld/globvar.h ld/obj.h ld/syshead.h ld/type.h ld/x86_aout.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fold\table.obj ld\table.c
+if errorlevel 1 goto exit_now
+later ld/typeconv.obj ld/typeconv.c ld/align.h ld/ar.h ld/bindef.h ld/byteord.h ld/config.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later ld/typeconv.obj ld/const.h ld/globvar.h ld/obj.h ld/syshead.h ld/type.h ld/x86_aout.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fold\typeconv.obj ld\typeconv.c
+if errorlevel 1 goto exit_now
+later ld/writebin.obj ld/writebin.c ld/align.h ld/ar.h ld/bindef.h ld/byteord.h ld/config.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later ld/writebin.obj ld/const.h ld/globvar.h ld/obj.h ld/syshead.h ld/type.h ld/x86_aout.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fold\writebin.obj ld\writebin.c
+if errorlevel 1 goto exit_now
+later ld/writex86.obj ld/writex86.c ld/align.h ld/ar.h ld/bindef.h ld/byteord.h ld/config.h
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later ld/writex86.obj ld/const.h ld/globvar.h ld/obj.h ld/syshead.h ld/type.h ld/x86_aout.h
+if errorlevel 3 goto exit_now
+if errorlevel 1 cl -Ml -nologo -O -DPOSIX_HEADERS_MISSING -c -Fold\writex86.obj ld\writex86.c
+if errorlevel 1 goto exit_now
+later lib/ld.exe ld/ld.obj ld/dumps.obj ld/io.obj ld/linksyms.obj ld/readobj.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 later lib/ld.exe ld/table.obj ld/typeconv.obj ld/writebin.obj ld/writex86.obj
+if errorlevel 3 goto exit_now
+if not errorlevel 1 goto done_ld
+if exist doslib.lib del doslib.lib
+lib doslib.lib +ld\dumps.obj +ld\io.obj +ld\linksyms.obj +ld\readobj.obj; >NUL
+lib doslib.lib +ld\table.obj +ld\typeconv.obj +ld\writebin.obj; >NUL
+lib doslib.lib +ld\writex86.obj; >NUL
+cl -Ml -o lib\ld.exe ld\ld.obj doslib.lib
+if errorlevel 1 goto exit_now
+if exist doslib.lib del doslib.lib
+if exist doslib.bak del doslib.bak
+:done_ld
+
+:exit_now
diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 9e0f423..0000000 --- a/debian/changelog +++ /dev/null @@ -1,25 +0,0 @@ -elks (0.0.7-3) unstable;urgency=? - - * Replaced man pages by more correct ones. - * Added bootblock and standalone examples - * Improved method for creation of binary installation, /usr/src/elks - isn't strictly needed now but included for example code. - * Debian mods included in original distribution. - -elks (0.0.7-2) unstable;urgency=high - - * Permissions of /usr/src/elks/tiny wrong - * README.debian and changelog.DEBIAN included - - -- Christoph Lameter <clameter@debian.org> Sun, 22 Sep 1996 9:00:00 -0800 - -elks (0.0.7-1) unstable;urgency=medium - - * Distribution from linux.mit.edu/pub/ELKS/Dev86 taken and customized - for debian - * Added manpages from FreeBSD (might not be totally up to date) - * I hope elks will enable the debian project to build the bootloader - syslinux under Linux and no longer under DOS. -Local variables: -mode: debian-changelog -End: diff --git a/debian/control b/debian/control deleted file mode 100644 index 4059d3e..0000000 --- a/debian/control +++ /dev/null @@ -1,23 +0,0 @@ -Source: elks -Section: devel -Priority: optional -Maintainer: Christoph Lameter <clameter@waterf.org> -Standards-Version: 2.1.0.0 - -Package: elks -Architecture: any -Depends: ${shlibs:Depends} -Description: Development environment for 8086 Software development - ELKS-86 = Embedded Linux Kernel Environemtn for 8086. The project - attempts to provide a running Linux system for 8086 CPUs. - . - It contains a working assember, linker and C-compiler for 8086 cpus - which is important for the development of boot loaders or BIOS related - code. C-Library and example code are also provided. - . - ELKS-86 contains an upgraded version of as86 which is used to compile the - linux kernel. - . - ELKS-86 can also be build on an MS-DOS system. This module will install the - complete source code for ELKS-86 in addition to the binaries! You need the - stuff to work with! diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 62b47d8..0000000 --- a/debian/copyright +++ /dev/null @@ -1,3 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - diff --git a/debian/rules b/debian/rules deleted file mode 100644 index ad4d3f4..0000000 --- a/debian/rules +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/make -f -# Sample debian.rules file - for GNU Hello (1.3). -# Copyright 1994,1995 by Ian Jackson. -# I hereby give you perpetual unlimited permission to copy, -# modify and relicense this file, provided that you do not remove -# my name from the file itself. (I assert my moral right of -# paternity under the Copyright, Designs and Patents Act 1988.) -# This file may have to be extensively modified - -# There used to be `source' and `diff' targets in this file, and many -# packages also had `changes' and `dist' targets. These functions -# have been taken over by dpkg-source, dpkg-genchanges and -# dpkg-buildpackage in a package-independent way, and so these targets -# are obsolete. - -package=elks - -build: - $(checkdir) - -rm -rf elks - mkdir elks - cp -a * elks - rm -r elks/debian - make bcc library elksemu - cd dis88;make - touch build - -clean: - $(checkdir) - -rm -f build - -make realclean - -rm `find . -name "*~"` - -rm -rf debian/tmp debian/files* elks - -binary-indep: checkroot build - $(checkdir) -# There are no architecture-independent files to be uploaded -# generated by this package. If there were any they would be -# made here. - -binary-arch: checkroot build - $(checkdir) - -rm -rf debian/tmp - install -d debian/tmp debian/tmp/DEBIAN - install -d -g root -m 755 -o root debian/tmp/usr/doc/copyright \ - debian/tmp/usr/src debian/tmp/usr/man/man1 \ - debian/tmp/usr/bin debian/tmp/lib debian/tmp/usr/doc/examples - make install DIST=`pwd`/debian/tmp - cd dis88;make install install-lib2 DIST=../debian/tmp -# Include complete source - cp -a elks debian/tmp/usr/src -# And changelog - install -m644 debian/changelog debian/tmp/usr/src/elks/changelog.DEBIAN -# Documentation links - ln -s /usr/src/elks debian/tmp/usr/doc/$(package) - ln -s /usr/src/elks debian/tmp/usr/doc/examples/$(package) - install -m644 debian/copyright debian/tmp/usr/doc/copyright/$(package) -# Manpages from FreeBSD - install -m644 man/*.1 dis88/*.1 debian/tmp/usr/man/man1 - dpkg-shlibdeps bcc/bcc - dpkg-gencontrol - chown -R root.root debian/tmp - chmod -R g-ws debian/tmp - dpkg --build debian/tmp .. - -define checkdir -# Must have ELKS installed to compile!! - test -f debian/rules -a -f /usr/bin/bcc -endef - -# Below here is fairly generic really - -binary: binary-indep binary-arch - -source diff: - @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false - -checkroot: - $(checkdir) - test root = "`whoami`" - -.PHONY: binary binary-arch binary-indep clean checkroot diff --git a/debian/substvars b/debian/substvars deleted file mode 100644 index cb92a43..0000000 --- a/debian/substvars +++ /dev/null @@ -1 +0,0 @@ -shlibs:Depends=libc5 (>= 5.2.18) diff --git a/dis88/Makefile b/dis88/Makefile index 0df3b02..56f9390 100644 --- a/dis88/Makefile +++ b/dis88/Makefile @@ -25,7 +25,6 @@ # be necessary to alter the formats of the tables. #CC=bcc -#CFLAGS=-O -A-l -A$*.lst CFLAGS=-O LDFLAGS= @@ -37,7 +36,8 @@ dis88: $(OBJ) $(CC) $(LDFLAGS) -o dis88 $(OBJ) install: dis88 - install -m 755 -s dis88 $(DIST)/usr/bin/dis88 + install -m 755 -s dis88 $(DIST)/usr/bin/dis88 + install -m 644 -s dis88.1 $(DIST)/usr/man/man1/dis88.1 $(OBJ): dis.h a.out.h diff --git a/dis88/dis.h b/dis88/dis.h index aa91312..21bbc2e 100644 --- a/dis88/dis.h +++ b/dis88/dis.h @@ -128,7 +128,8 @@ extern struct exec HDR; /* Holds the object file's header */ /* Macro for byte input primitive */ /* #define FETCH(p) ++PC; p = getchar() & 0xff; objbuf[objptr++] = p */ static int _F_; -#define FETCH(p) (p)=_F_ = Fetch(); if(_F_<0) {printf("???\n"); return; } +#define FETCH(p) (p)=_F_ = Fetch(); if(_F_<0) {printf("???\n"); return FRV; } +#define FRV /* disfp.c */ diff --git a/dis88/dis88.1 b/dis88/dis88.1 index c991ad7..66a48f5 100644 --- a/dis88/dis88.1 +++ b/dis88/dis88.1 @@ -2,7 +2,7 @@ .SH "NAME" dis88 \- 8088 symbolic disassembler .SH "SYNOPSIS" -\fBdis88\fP [ -o ] ifile [ ofile ] +\fBdis88\fP [ -f -o ] ifile [ ofile ] .SH "DESCRIPTION" Dis88 reads ifile, which must be in PC/IX a.out format. It interprets the binary opcodes and data locations, and @@ -23,6 +23,10 @@ feature is used primarily for debugging the disassembler itself, but may provide information of passing interest to users. .PP +If the "-f" option appears, dis88 will attempt to disassemble +any file whatsoever. It has to assume that the file begins +at address zero. +.PP The program always outputs the current machine address before disassembling an opcode. If a symbol table is present, this address is output as an assembler comment; diff --git a/dis88/dismain.c b/dis88/dismain.c index dc150de..0f00b11 100644 --- a/dis88/dismain.c +++ b/dis88/dismain.c @@ -396,8 +396,11 @@ distext() } if ((c = getlab(N_TEXT)) != NULL) printf("%s",c); - f = optab[j].func; - (*f)(j); + if( j>=0 && j<256 ) + { + f = optab[j].func; + (*f)(j); + } fflush(stdout); } diff --git a/dis88/distabs.c b/dis88/distabs.c index 5e11da2..5a6af5e 100644 --- a/dis88/distabs.c +++ b/dis88/distabs.c @@ -196,9 +196,11 @@ struct opcode optab[] = /* Table of opcode data */ "\tseg\tgs", sbhand, 1, 1, /* 0x65 */ "\tuse\top32", sbhand, 1, 1, /* 0x66 */ "\tuse\tadr32", sbhand, 1, 1, /* 0x67 */ - NULL, dfhand, 0, 0, /* 0x68 */ + "\tpush\t", mihand, 3, 3, /* 0x68 */ + /* NULL, dfhand, 0, 0, /* 0x68 */ NULL, dfhand, 0, 0, /* 0x69 */ - NULL, dfhand, 0, 0, /* 0x6a */ + "\tpush\t", mihand, 2, 2, /* 0x6a */ + /* NULL, dfhand, 0, 0, /* 0x6a */ NULL, dfhand, 0, 0, /* 0x6b */ NULL, dfhand, 0, 0, /* 0x6c */ NULL, dfhand, 0, 0, /* 0x6d */ @@ -548,6 +550,9 @@ lookup(addr,type,kind,ext) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#undef FRV +#define FRV "" + char * mtrans(c,m,type) diff --git a/elksemu/Makefile b/elksemu/Makefile index e25f60f..b2b34e8 100644 --- a/elksemu/Makefile +++ b/elksemu/Makefile @@ -2,16 +2,17 @@ # Makefile for elksemu. # +ifeq ($(CC),bcc) +# Use BCC to make a tiny static a.out version. +CFLAGS=-O -3 -N -ansi +else # For gcc with the default compiler -# CFLAGS=-O2 -fno-strength-reduce -Wall -idirafter . $(DEFS) +CFLAGS=-O2 -fno-strength-reduce -Wall -idirafter . $(DEFS) +endif # For gcc making a.out with a basically ELF compiler # CFLAGS=-O2 -fno-strength-reduce -b i486-linuxaout -N -s -static -# Use BCC to make a tiny static a.out version. -CFLAGS=-O -3 -N -ansi -CC=bcc - OBJ=elks.o elks_sys.o elks_signal.o elksemu: $(OBJ) @@ -0,0 +1,38 @@ +
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+main(argc, argv)
+int argc;
+char ** argv;
+{
+ struct stat st;
+ long exe_mtime = 0;
+ int verbose = 0;
+ int ar;
+
+ if( strcmp(argv[1], "+") == 0 ) { verbose++; argc--; argv++; }
+
+ if( stat(argv[1], &st) < 0 )
+ {
+ if( verbose ) printf("%s not found\n", argv[1]);
+ exit(2);
+ }
+ exe_mtime = st.st_mtime;
+
+ for(ar=2; ar<argc; ar++)
+ {
+ if( stat(argv[ar], &st) < 0 )
+ {
+ printf("ERROR: dependent %d not found\n", argv[ar]);
+ exit(3);
+ }
+ if( exe_mtime < st.st_mtime )
+ {
+ if( verbose ) printf("%s out of dat wrt %s \n", argv[1], argv[ar]);
+ exit(1);
+ }
+ }
+ exit(0);
+}
diff --git a/ld/Makefile b/ld/Makefile index a4d2bb7..6351f10 100644 --- a/ld/Makefile +++ b/ld/Makefile @@ -1,11 +1,11 @@ ifneq ($(TOPDIR),) include $(TOPDIR)/Make.defs - -CFLAGS=$(CCFLAGS) -DREL_OUTPUT +CFLAGS =$(CCFLAGS) -DREL_OUTPUT else -CC=bcc -3 -N -LDFLAGS= +LDFLAGS =-s +LIBDIR =/usr/bin +CFLAGS =-O -DREL_OUTPUT endif # May need some of these if the auto-sense fails. diff --git a/ld/bindef.h b/ld/bindef.h index 4ccaf53..2a2d8d8 100644 --- a/ld/bindef.h +++ b/ld/bindef.h @@ -1,4 +1,6 @@ +#ifndef MSDOS +#ifndef NO_AOUT /* Ok, I'm just gonna make it simple ... override this if you like. */ #ifndef A_OUT_INCL #define A_OUT_INCL "a.out.h" @@ -12,12 +14,7 @@ # else # define A_OUT_INCL "bsd-a.out.h" # endif - -# ifdef MSDOS -# define A_OUT_INCL "a_out.h" -# else -# define A_OUT_INCL "a.out.h" /* maybe local copy of <a.out.h> for X-link */ -# endif +# define A_OUT_INCL "a.out.h" /* maybe local copy of <a.out.h> for X-link */ # endif /* BSD_A_OUT */ #endif @@ -48,7 +45,9 @@ # else # define RELOC_INFO_SIZE (sizeof (struct relocation_info)) # endif -# define C_EXT N_EXT +# ifdef N_EXT +# define C_EXT N_EXT +# endif # define C_STAT 0 # define n_was_name n_un.n_name # define n_was_numaux n_other @@ -66,3 +65,10 @@ # define n_was_type n_type # endif /* BSD_A_OUT */ +/* And finally make sure it worked */ +#ifdef C_EXT +#define AOUT_DETECTED 1 +#endif + +#endif /* NO_AOUT */ +#endif /* MSDOS */ @@ -184,6 +184,31 @@ char **argv; } } +#ifdef REL_OUTPUT +#ifndef MSDOS + if( flag['r'] && !flag['N'] ) + { + /* Ok, try for an alternate linker */ + if( strcmp(argv[0], "ld86r") != 0 ) + { + argv[0] = "ld86r"; + execv("/usr/bin/ld86r", argv); + execv("/usr/bin/ld86", argv); + } + } +#endif +#endif + +#ifdef MSDOS + /* MSDOS Native is special, we make a COM file */ + if( flag['N'] ) + { + flag['N'] = 0; + flag['d'] = 1; + text_base_value = 0x100; + } +#endif + /* Headerless executables can't use symbols. */ headerless = flag['d']; if( headerless ) flag['s'] = 1; diff --git a/ld/readobj.c b/ld/readobj.c index da83b0a..137facc 100644 --- a/ld/readobj.c +++ b/ld/readobj.c @@ -77,14 +77,22 @@ bool_pt trace; filepos = SARMAG; while ((filelength = readarheader(&archentry)) > 0) { + unsigned int magic; if (trace) errtrace(archentry, 2); filepos += sizeof(struct ar_hdr); - for (modcount = readfileheader(); modcount-- != 0;) + magic = (unsigned) readsize(2); + if(magic == OMAGIC) { - readmodule(stralloc(filename), archentry); - modlast->textoffset += filepos; + seekin(filepos); + for (modcount = readfileheader(); modcount-- != 0;) + { + readmodule(stralloc(filename), archentry); + modlast->textoffset += filepos; + } } + else if( magic == 0x3C21 ) /* "!<" */ + filelength = SARMAG; seekin(filepos += ld_roundup(filelength, 2, long)); } break; @@ -107,8 +115,8 @@ char **parchentry; arheader.ar_name, sizeof arheader.ar_name); endptr = nameptr + sizeof arheader.ar_name; do - *endptr = 0; - while (endptr > nameptr && *--endptr == ' '); + *endptr-- = 0; + while (endptr > nameptr && (*endptr == ' ' || *endptr == '/')); return strtoul(arheader.ar_size, (char **) NUL_PTR, 0); } diff --git a/ld/writebin.c b/ld/writebin.c index de4b01c..60440f7 100644 --- a/ld/writebin.c +++ b/ld/writebin.c @@ -3,14 +3,18 @@ /* Copyright (C) 1994 Bruce Evans */ -#include "syshead.h" +#ifndef NO_AOUT #define A_OUT_INCL <a.out.h> +#endif + +#include "syshead.h" #include "bindef.h" #include "const.h" #include "obj.h" #include "type.h" #include "globvar.h" +#ifdef AOUT_DETECTED #define btextoffset (text_base_value) #define bdataoffset (data_base_value) #define page_size() 4096 @@ -936,3 +940,15 @@ bin_off_t count; while (count-- > 0) writechar(0); } +#else + +PUBLIC void writebin(outfilename, argsepid, argbits32, argstripflag, arguzp) +char *outfilename; +bool_pt argsepid; +bool_pt argbits32; +bool_pt argstripflag; +bool_pt arguzp; +{ + fatalerror("Native a.out generation not included, sorry"); +} +#endif diff --git a/ld/writex86.c b/ld/writex86.c index 25cc0d6..2b0f00a 100644 --- a/ld/writex86.c +++ b/ld/writex86.c @@ -13,6 +13,12 @@ #define bdataoffset (data_base_value) #define page_size() ((bin_off_t)4096) +#ifdef __ELF__ +#ifndef ELF_SYMS +#define ELF_SYMS 1 +#endif +#endif + # define FILEHEADERLENGTH (headerless?0:A_MINHDR) /* part of header not counted in offsets */ #define DPSEG 2 @@ -94,7 +100,11 @@ bool_pt arguzp; bin_off_t tempoffset; if( reloc_output ) +#ifndef MSDOS fatalerror("Output binformat not configured relocatable, use -N"); +#else + fatalerror("Cannot use -r under MSDOS, sorry"); +#endif sepid = argsepid; bits32 = argbits32; @@ -286,7 +296,7 @@ bool_pt arguzp; (symptr = *symparray) != NUL_PTR; ++symparray) if (symptr->modptr == modptr) { -#ifdef __ELF__ +#if ELF_SYMS if (symptr->name[0] == '_' && symptr->name[1] ) strncpy((char *) extsym.n_name, symptr->name+1, sizeof extsym.n_name); @@ -519,7 +529,8 @@ PRIVATE void writeheader() offtocn((char *) &header.a_entry, page_size(), sizeof header.a_entry); offtocn((char *) &header.a_total, (bin_off_t) - (endoffset < 0x00010000L ? 0x00010000L : endoffset + 0x0008000L), + (endoffset < 0x00008000L ? endoffset+0x8000L : + (endoffset < 0x00010000L ? 0x00010000L : endoffset + 0x0008000L)), sizeof header.a_total); if( FILEHEADERLENGTH ) writeout((char *) &header, FILEHEADERLENGTH); diff --git a/libc/Make.defs b/libc/Make.defs index ff571d7..b4f0c28 100644 --- a/libc/Make.defs +++ b/libc/Make.defs @@ -21,7 +21,7 @@ endif VERMAJOR=0 VERMINOR=0 -VERPATCH=8 +VERPATCH=9 VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH) LIBDEFS='-D__LIBC__="$(VER)"' diff --git a/libc/Makefile b/libc/Makefile index d533320..0359619 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -66,7 +66,7 @@ clean: done dellib: - rm -f libc*.a libdos.a + rm -f *.a ############################################################################## diff --git a/libc/bcc/heap.c b/libc/bcc/heap.c index 6a6ce2c..2cab16e 100644 --- a/libc/bcc/heap.c +++ b/libc/bcc/heap.c @@ -44,7 +44,7 @@ has_change: js go_down add ax,[brk_addr] ! Goin up! jc Enomem - sub bx,#512 ! Safety space 512 bytes + sub bx,#511 ! Safety space 512 bytes cmp bx,ax ! Too close ? jb Enomem diff --git a/libc/bios/bios.c b/libc/bios/bios.c index 18e2448..3059fd9 100644 --- a/libc/bios/bios.c +++ b/libc/bios/bios.c @@ -115,6 +115,27 @@ reti_ins: /****************************************************************************/ +#ifdef L___file_3 + +/* If the block function does track buffering this should be ok ... */ +struct { + int (*block_rw)(); /* Args (rwoc, &buffer, blockno) 1k blocks */ + /* 0 = read, 1 = write */ + /* 2 = open, buffer is fname ptr */ + /* 3 = close, other args ignored */ + long offset; + + int flags; + long block_num; + char buffer[1024]; +} __file_3_data; + +#define FILE3_OPEN 1 /* File is open */ +#define FILE3_DATA 2 /* buffer has valid contents */ +#define FILE3_DIRTY 4 /* buffer has been modified */ + +#endif + #ifdef L_bios_write write(fd,buf,len) int fd,len; diff --git a/libc/include/a.out.h b/libc/include/a.out.h index f6a7b94..bd58346 100644 --- a/libc/include/a.out.h +++ b/libc/include/a.out.h @@ -90,7 +90,7 @@ struct reloc { #define S_BSS ((unsigned short)-4) struct nlist { /* symbol table entry */ - char n_name[24]; /* symbol name */ + char n_name[8]; /* symbol name */ long n_value; /* value */ unsigned char n_sclass; /* storage class */ unsigned char n_numaux; /* number of auxiliary entries (not used) */ diff --git a/libc/include/ctype.h b/libc/include/ctype.h index 3e94272..ed22ef7 100644 --- a/libc/include/ctype.h +++ b/libc/include/ctype.h @@ -5,7 +5,7 @@ #ifndef __CTYPE_H #define __CTYPE_H -extern unsigned char _ctype[]; +extern unsigned char __ctype[]; #define __CT_d 0x01 /* numeric digit */ #define __CT_u 0x02 /* upper case */ @@ -22,17 +22,17 @@ extern unsigned char _ctype[]; #define toascii(c) ((c)&0x7F) /* Note the '!!' is a cast to 'bool' and even BCC deletes it in an if() */ -#define isalnum(c) (!!(_ctype[(int) c]&(__CT_u|__CT_l|__CT_d))) -#define isalpha(c) (!!(_ctype[(int) c]&(__CT_u|__CT_l))) +#define isalnum(c) (!!(__ctype[(int) c]&(__CT_u|__CT_l|__CT_d))) +#define isalpha(c) (!!(__ctype[(int) c]&(__CT_u|__CT_l))) #define isascii(c) (!((c)&~0x7F)) -#define iscntrl(c) (!!(_ctype[(int) c]&__CT_c)) -#define isdigit(c) (!!(_ctype[(int) c]&__CT_d)) -#define isgraph(c) (!(_ctype[(int) c]&(__CT_c|__CT_s))) -#define islower(c) (!!(_ctype[(int) c]&__CT_l)) -#define isprint(c) (!(_ctype[(int) c]&__CT_c)) -#define ispunct(c) (!!(_ctype[(int) c]&__CT_p)) -#define isspace(c) (!!(_ctype[(int) c]&__CT_s)) -#define isupper(c) (!!(_ctype[(int) c]&__CT_u)) -#define isxdigit(c) (!!(_ctype[(int) c]&__CT_x)) +#define iscntrl(c) (!!(__ctype[(int) c]&__CT_c)) +#define isdigit(c) (!!(__ctype[(int) c]&__CT_d)) +#define isgraph(c) (!(__ctype[(int) c]&(__CT_c|__CT_s))) +#define islower(c) (!!(__ctype[(int) c]&__CT_l)) +#define isprint(c) (!(__ctype[(int) c]&__CT_c)) +#define ispunct(c) (!!(__ctype[(int) c]&__CT_p)) +#define isspace(c) (!!(__ctype[(int) c]&__CT_s)) +#define isupper(c) (!!(__ctype[(int) c]&__CT_u)) +#define isxdigit(c) (!!(__ctype[(int) c]&__CT_x)) #endif /* __CTYPE_H */ diff --git a/libc/misc/Makefile b/libc/misc/Makefile index 3db73a7..c7ed8fa 100644 --- a/libc/misc/Makefile +++ b/libc/misc/Makefile @@ -15,7 +15,7 @@ GOBJ=atoi.o atol.o ltoa.o ltostr.o \ ctype.o qsort.o bsearch.o rand.o lsearch.o getopt.o \ itoa.o cputype.o strtol.o crypt.o -UOBJ=getenv.o putenv.o popen.o system.o setenv.o +UOBJ=getenv.o putenv.o popen.o system.o setenv.o getcwd.o ifeq ($(LIB_OS),ELKS) diff --git a/libc/misc/ctype.c b/libc/misc/ctype.c index 1514668..6b6cd3d 100644 --- a/libc/misc/ctype.c +++ b/libc/misc/ctype.c @@ -12,7 +12,7 @@ #undef toupper #undef tolower -unsigned char _ctype[128] = +unsigned char __ctype[128] = { __CT_c, __CT_c, __CT_c, __CT_c, /* 0x00..0x03 */ __CT_c, __CT_c, __CT_c, __CT_c, /* 0x04..0x07 */ diff --git a/libc/misc/getcwd.c b/libc/misc/getcwd.c new file mode 100644 index 0000000..351214c --- /dev/null +++ b/libc/misc/getcwd.c @@ -0,0 +1,109 @@ + +#include <errno.h> +#include <sys/stat.h> +#include <dirent.h> +#include <string.h> +/* + * These functions find the absolute path to the current working directory. + * + * They don't use malloc or large amounts of stack space. + */ + +static char * recurser(); /* Routine to go up tree */ +static char * search_dir(); /* Routine to find the step back down */ +static char * path_buf; +static int path_size; + +static dev_t root_dev; +static ino_t root_ino; + +static struct stat st; + +char * +getcwd(buf, size) +char * buf; +int size; +{ + path_buf = buf; + path_size = size; + + if( size < 3 ) { errno = ERANGE; return 0; } + strcpy(path_buf, "."); + + if( stat("/", &st) < 0 ) return 0; + + root_dev = st.st_dev; + root_ino = st.st_ino; + + return recurser(); +} + +static char * +recurser() +{ + dev_t this_dev; + ino_t this_ino; + if( stat(path_buf, &st) < 0 ) return 0; + this_dev = st.st_dev; + this_ino = st.st_ino; + if( this_dev == root_dev && this_ino == root_ino ) + { + strcpy(path_buf, "/"); + return path_buf; + } + if( strlen(path_buf) + 4 > path_size ) { errno = ERANGE; return 0; } + strcat(path_buf, "/.."); + if( recurser() == 0 ) return 0; + + return search_dir(this_dev, this_ino); +} + +static char * +search_dir(this_dev, this_ino) +dev_t this_dev; +ino_t this_ino; +{ + DIR * dp; + struct dirent * d; + char * ptr; + int slen; + /* The test is for ELKS lib 0.0.9, this should be fixed in the real kernel*/ + int slow_search = (sizeof(ino_t) != sizeof(d->d_ino)); + + if( stat(path_buf, &st) < 0 ) return 0; + if( this_dev != st.st_dev ) slow_search = 1; + + slen = strlen(path_buf); + ptr = path_buf + slen -1; + if( *ptr != '/' ) + { + if( slen + 2 > path_size ) { errno = ERANGE; return 0; } + strcpy(++ptr, "/"); + slen++; + } + slen++; + + dp = opendir(path_buf); + if( dp == 0 ) return 0; + + while( (d=readdir(dp)) != 0 ) + { + if( slow_search || this_ino == d->d_ino ) + { + if( slen + strlen(d->d_name) > path_size ) + { errno = ERANGE; return 0; } + strcpy(ptr+1, d->d_name); + if( stat(path_buf, &st) < 0 ) + continue; + if( st.st_ino == this_ino && st.st_dev == this_dev ) + { + closedir(dp); + return path_buf; + } + } + } + + closedir(dp); + errno = ENOENT; + return 0; +} diff --git a/libc/msdos/Makefile b/libc/msdos/Makefile index 59f38b9..f069699 100644 --- a/libc/msdos/Makefile +++ b/libc/msdos/Makefile @@ -6,8 +6,8 @@ TOP=.. include $(TOP)/Make.defs ASRC=msdos.c -AOBJ= dos_start.o __mkargv.o dos__fconv.o dos_read.o dos_write.o \ - dos_open.o dos_close.o dos_unlink.o dos_lseek.o \ +AOBJ= dos_start.o __mkargv.o __mkenvp.o dos__fconv.o dos_read.o \ + dos_write.o dos_open.o dos_close.o dos_unlink.o dos_lseek.o \ dos_segalloc.o dos_segfree.o dos_setvect.o dos_getvect.o \ dos_isatty.o dos_getmod.o dos_stat.o diff --git a/libc/msdos/msdos.c b/libc/msdos/msdos.c index 390e904..2d23374 100644 --- a/libc/msdos/msdos.c +++ b/libc/msdos/msdos.c @@ -210,6 +210,28 @@ char ** __argv; } #endif +#ifdef L___mkenvp + +#ifdef __AS386_16__ +#asm + loc 1 ! Make sure the pointer is in the correct segment +auto_func: ! Label for bcc -M to work. + .word ___mkenvp ! Pointer to the autorun function + .text ! So the function after is also in the correct seg. +#endasm +#endif + +char ** environ = 0; + +__mkenvp(__argc, __argv, __envp) +int __argc; +char ** __argv; +char ** __envp; +{ + /* FIXME !!! */ +} +#endif + #ifdef L_dos__fconv /* This function converts filenames from unix like to DOS. */ char * diff --git a/libc/syscall/Makefile b/libc/syscall/Makefile index 06728da..b487655 100644 --- a/libc/syscall/Makefile +++ b/libc/syscall/Makefile @@ -16,8 +16,8 @@ LSRC0=syslib0.c LOBJ0=__cstartup.o lseek.o getpid.o getppid.o getuid.o geteuid.o getgid.o \ getegid.o dup2.o dup.o getpgrp.o times.o -ESRC=execve.c -E2OBJ=execl.o execv.o execle.o +ESRC=exec.c +E2OBJ=execl.o execv.o execle.o execlp.o execvp.o EOBJ=execve.o $(E2OBJ) DSRC=dirent.c diff --git a/libc/syscall/execve.c b/libc/syscall/exec.c index 33643ca..411b744 100644 --- a/libc/syscall/execve.c +++ b/libc/syscall/exec.c @@ -1,5 +1,6 @@ #include <errno.h> +#include <sys/stat.h> extern char ** environ; @@ -113,9 +114,91 @@ char ** envp; } #endif -#ifdef L_execvve +#ifdef L_execlp int -execvve(fname, interp, argv, envp) +execlp(fname, arg0) +char * fname, *arg0; +{ + return execvp(fname, &arg0); +} +#endif + +#ifdef L_execvp +int +execvp(fname, argv) +char * fname, **argv; +{ + char *pname = fname, *path; + int besterr = ENOENT; + int flen, plen; + char * bp = sbrk(0); + + if( *fname != '/' && (path = getenv("PATH")) != 0 ) + { + flen = strlen(fname)+2; + + for(;path;) + { + if( *path == ':' || *path == '\0' ) + { + tryrun(fname, argv); + if( errno == EACCES ) besterr = EACCES; + if( *path ) path++; else break; + } + else + { + char * p = strchr(path, ':'); + if(p) *p = '\0'; + plen = strlen(path); + pname = sbrk(plen+flen); + + strcpy(pname, path); + strcat(pname, "/"); + strcat(pname, fname); + + tryrun(pname, argv); + if( errno == EACCES ) besterr = EACCES; + + brk(pname); + pname = fname; + if(p) *p++ = ':'; + path=p; + } + } + } + + tryrun(pname, argv); + brk(bp); + if( errno == ENOENT || errno == 0 ) errno = besterr; + return -1; +} + +static int tryrun(pname, argv) +char * pname; +char ** argv; +{ +static char *shprog[] = {"/bin/sh", "", 0}; + struct stat st; + + if( stat(pname, &st) < 0 ) return; + if( !S_ISREG(st.st_mode) ) return; + +#ifdef __AS386_16__ + __execvve(pname, (void*)0, argv, environ); + if( errno == ENOEXEC ) + { + shprog[1] = pname; + __execvve(shprog[0], shprog, argv, environ); + } +#else + execve(pname, argv, environ); + /* FIXME - running /bin/sh in 386 mode */ +#endif +} + +#ifdef __AS386_16__ +static int +__execvve(fname, interp, argv, envp) char * fname; char ** interp; char ** argv; @@ -206,3 +289,4 @@ char ** envp; return rv; } #endif +#endif diff --git a/libc/syscall/mksys386 b/libc/syscall/mksys386 index be7b2d5..5abcbf8 100644 --- a/libc/syscall/mksys386 +++ b/libc/syscall/mksys386 @@ -50,18 +50,16 @@ awk 'BEGIN{ else if( $4 == "*" ) funcname="__" $1; else funcname=$1; - shortname=substr(funcname,1,12); - if( length(obj) > 60 ) { printf("%s\t\\\n", obj) > "syscall.mak"; obj=" "; } - obj=obj shortname ".o "; + obj=obj funcname ".o "; printf "/* CALL %s */\n\n", $0; - printf("#ifdef L_%s\n", shortname); + printf("#ifdef L_%s\n", funcname); printf("#asm\n"); printf("export _%s\n", funcname); printf("_%s:\n", funcname); @@ -86,27 +84,27 @@ awk 'BEGIN{ else { if( $3 >= 1 ) printf("#if __FIRST_ARG_IN_AX__\n"); - if( $3 >= 5 ) printf(" push edi\n"); - if( $3 >= 4 ) printf(" push esi\n"); - if( $3 >= 5 ) printf(" mov edi,[esp+16]\n"); - if( $3 >= 4 ) printf(" mov esi,[esp+12]\n"); - if( $3 >= 3 ) printf(" mov edx,[esp+8]\n"); - if( $3 >= 2 ) printf(" mov ecx,[esp+4]\n"); if( $3 >= 1 ) printf(" mov ebx,eax\n"); - if( $3 >= 1 ) printf("#else\n"); - if( $3 >= 5 ) printf(" push edi\n"); + if( $3 >= 2 ) printf(" mov ecx,[esp+4]\n"); + if( $3 >= 3 ) printf(" mov edx,[esp+8]\n"); if( $3 >= 4 ) printf(" push esi\n"); - if( $3 >= 5 ) printf(" mov edi,[esp+20]\n"); if( $3 >= 4 ) printf(" mov esi,[esp+16]\n"); - if( $3 >= 3 ) printf(" mov edx,[esp+12]\n"); - if( $3 >= 2 ) printf(" mov ecx,[esp+8]\n"); + if( $3 >= 5 ) printf(" push edi\n"); + if( $3 >= 5 ) printf(" mov edi,[esp+24]\n"); + if( $3 >= 1 ) printf("#else\n"); if( $3 >= 1 ) printf(" mov ebx,[esp+4]\n"); + if( $3 >= 2 ) printf(" mov ecx,[esp+8]\n"); + if( $3 >= 3 ) printf(" mov edx,[esp+12]\n"); + if( $3 >= 4 ) printf(" push esi\n"); + if( $3 >= 4 ) printf(" mov esi,[esp+20]\n"); + if( $3 >= 5 ) printf(" push edi\n"); + if( $3 >= 5 ) printf(" mov edi,[esp+28]\n"); if( $3 >= 1 ) printf("#endif\n"); printf(" mov eax,#%d\n", $2); printf(" int $80\n"); - if( $3 >= 4 ) printf(" pop esi\n"); if( $3 >= 5 ) printf(" pop edi\n"); + if( $3 >= 4 ) printf(" pop esi\n"); printf(" test eax,eax\n"); printf(" jl syscall_err\n"); diff --git a/libc/tests/hd.c b/libc/tests/hd.c index f6af1f9..341185f 100644 --- a/libc/tests/hd.c +++ b/libc/tests/hd.c @@ -1,90 +1,185 @@ + #include <stdio.h> #include <ctype.h> +#include <errno.h> + +int lastnum[16] = {-1}; +long lastaddr = -1; +long offset = 0; -int lastnum[16] = { -1 }; -long lastaddr = -1; +FILE *fd; main(argc, argv) -int argc; -char ** argv; +int argc; +char **argv; { - FILE * fd; - int j, ch; - char buf[20]; - int num[16]; - long offset = 0; - -#ifndef MSDOS - if( argc == 1 ) + int done = 0; + int ar; + int aflag = 1; + + for (ar = 1; ar < argc; ar++) + if (aflag && argv[ar][0] == '-') + switch (argv[ar][1]) + { + case 'r': + return reverse_hd(argc, argv); + case 'o': + offset = strtol(argv[ar] + 2, (void *) 0, 0); + break; + case '-': + aflag = 0; + break; + default: + Usage(); + } + else + { + fd = fopen(argv[ar], "rb"); + if (fd == 0) + fprintf(stderr, "Cannot open file '%s'\n", argv[ar]); + else + { + do_fd(); + fclose(fd); + } + done = 1; + } + + if (!done) +#ifdef MSDOS + Usage(); +#else { fd = stdin; + do_fd(); } - else #endif - { - if( argc == 3 ) offset = strtol(argv[2], (char*)0, 16); - else if( argc != 2 ) - { - fprintf(stderr, "Usage: hd file [hexoffset]\n"); - exit(1); - } - fd = fopen(argv[1], "rb"); - if( fd == 0 ) - { - fprintf(stderr, "Cannot open file '%s'\n", argv[1]); - exit(1); - } - } +} + +Usage() +{ + fprintf(stderr, "Usage: hd [-r]|[[-oOffset] file]\n"); + exit(1); +} + +do_fd() +{ + int j, ch; + char buf[20]; + int num[16]; - /* if( offset ) fseek(fd, offset, 0); */ + if (offset) + fseek(fd, offset, 0); - for(ch=0; ch!=EOF; offset+=16) + for (ch = 0; ch != EOF; offset += 16) { memset(buf, '\0', 16); - for(j=0; j<16; j++) num[j] = -1; - for(j=0; j<16; j++) + for (j = 0; j < 16; j++) + num[j] = -1; + for (j = 0; j < 16; j++) { - ch = fgetc(fd); - if( ch == EOF ) break; + ch = fgetc(fd); + if (ch == EOF) + break; - num[j] = ch; - if( isascii(ch) && isprint(ch) ) buf[j] = ch; - else buf[j] = '.'; + num[j] = ch; + if (isascii(ch) && isprint(ch)) + buf[j] = ch; + else + buf[j] = '.'; } - printline(offset, num, buf, ch==EOF); + printline(offset, num, buf, ch == EOF); } - fclose(fd); } printline(address, num, chr, eofflag) -long address; -int * num; -char * chr; -int eofflag; +long address; +int *num; +char *chr; +int eofflag; { - int j; + int j; - if( lastaddr >= 0 ) + if (lastaddr >= 0) { - for(j=0; j<16; j++) - if( num[j] != lastnum[j] ) - break; - if( j == 16 && !eofflag ) return; - if( lastaddr+16 != address ) - printf("*\n"); + for (j = 0; j < 16; j++) + if (num[j] != lastnum[j]) + break; + if (j == 16 && !eofflag) + { + if (lastaddr + 16 == address) + { + printf("*\n"); + fflush(stdout); + } + return; + } } lastaddr = address; printf("%06lx:", address); - for(j=0; j<16; j++) + for (j = 0; j < 16; j++) { - if( num[j] >= 0 ) - printf(" %02x", num[j]); + if (j == 8) + putchar(' '); + if (num[j] >= 0) + printf(" %02x", num[j]); else - printf(" "); + printf(" "); lastnum[j] = num[j]; num[j] = -1; } printf(" %.16s\n", chr); } + + +/* + * This function takes output from hd and converts it back into a binary + * file + */ + +/* -- 0 1 2 3 4 5 6 7 8 9 a b c d e f */ +static char *datafmt = "%x: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n"; +reverse_hd() +{ + char str[160]; + char * ptr; + int c[16], d[16], x, i, nxtaddr, addr; + + for (i = 0; i < 16; i++) + c[i] = 0; + nxtaddr = 0; + + for (nxtaddr = 0;;) + { + if (gets(str) == NULL) + break; + + str[57] = 0; + ptr = str; + + if( !isxdigit(*ptr) ) continue; + addr = strtol(ptr, &ptr, 16); + if( *ptr == ':' ) ptr++; + + if (nxtaddr == 0) + nxtaddr = addr; + while (nxtaddr < addr) + { + nxtaddr += 16; + for (i = 0; i < 16; i++) + putchar(c[i]); + } + for (i = 0; i < 16 && *ptr; i++) + { + char * ptr2; + c[i] = strtol(ptr, &ptr2, 16); + if( ptr == ptr2 ) break; + putchar(c[i]); + ptr = ptr2; + } + nxtaddr += 16; + } + return 0; +} diff --git a/make_bcc.bat b/make_bcc.bat deleted file mode 100644 index 8266af4..0000000 --- a/make_bcc.bat +++ /dev/null @@ -1,123 +0,0 @@ -@
-@set OPROMPT=%PROMPT%
-@set PROMPT=$g
-@goto mkbcc
-:endbcc
-@goto mkas
-:endas
-@goto mkld
-:endld
-@goto docopy
-@
-:mkbcc
-@
-cd bcc
-set CFLAGS=-O -nologo
-cl %CFLAGS% -c bcc.c
-cl %CFLAGS% -o bcc.exe bcc.obj %LIB%\setargv.obj -link /NOE
-@
-set CFLAGS=-Ml -nologo
-cl %CFLAGS% -c assign.c
-cl %CFLAGS% -c bcc-cc1.c
-cl %CFLAGS% -c codefrag.c
-cl %CFLAGS% -c debug.c
-cl %CFLAGS% -c declare.c
-cl %CFLAGS% -c express.c
-cl %CFLAGS% -c exptree.c
-cl %CFLAGS% -c floatop.c
-cl %CFLAGS% -c function.c
-cl %CFLAGS% -c gencode.c
-cl %CFLAGS% -c genloads.c
-cl %CFLAGS% -c glogcode.c
-cl %CFLAGS% -c hardop.c
-cl %CFLAGS% -c input.c
-cl %CFLAGS% -c label.c
-cl %CFLAGS% -c loadexp.c
-cl %CFLAGS% -c longop.c
-cl %CFLAGS% -c output.c
-cl %CFLAGS% -c preproc.c
-cl %CFLAGS% -c preserve.c
-cl %CFLAGS% -c scan.c
-cl %CFLAGS% -c softop.c
-cl %CFLAGS% -c state.c
-cl %CFLAGS% -c table.c
-cl %CFLAGS% -c type.c
-@
-del \tmp\bcc_lib.lib
-lib \tmp\bcc_lib.lib +assign.obj +declare.obj +gencode.obj +label.obj ;
-lib \tmp\bcc_lib.lib +preserve.obj +type.obj +express.obj +genloads.obj ;
-lib \tmp\bcc_lib.lib +loadexp.obj +scan.obj +exptree.obj +glogcode.obj ;
-lib \tmp\bcc_lib.lib +longop.obj +softop.obj +codefrag.obj +floatop.obj ;
-lib \tmp\bcc_lib.lib +hardop.obj +output.obj +state.obj +debug.obj ;
-lib \tmp\bcc_lib.lib +function.obj +input.obj +preproc.obj +table.obj ;
-@
-cl %CFLAGS% -o bcc-cc1.exe bcc-cc1.obj \tmp\bcc_lib.lib
-del \tmp\bcc_lib.lib
-del \tmp\bcc_lib.bak
-cd ..
-@
-@goto endbcc
-@
-:mkld
-@
-cd ld
-set CFLAGS=-O -Ml -DPOSIX_HEADERS_MISSING -nologo
-@
-cl -c %CFLAGS% writex86.c
-cl -c %CFLAGS% linksyms.c
-cl -c %CFLAGS% dumps.c
-cl -c %CFLAGS% io.c
-cl -c %CFLAGS% ld.c
-cl -c %CFLAGS% readobj.c
-cl -c %CFLAGS% table.c
-cl -c %CFLAGS% typeconv.c
-cl -O -nologo -o ld.exe dumps io ld readobj table typeconv linksyms writex86
-cd ..
-@
-@goto endld
-@
-:mkas
-@
-cd as
-set CFLAGS=-O -Ml -DPOSIX_HEADERS_MISSING -nologo
-cl -c %CFLAGS% readsrc.c
-cl -c %CFLAGS% as.c
-cl -c %CFLAGS% assemble.c
-cl -c %CFLAGS% error.c
-cl -c %CFLAGS% express.c
-cl -c %CFLAGS% genbin.c
-cl -c %CFLAGS% genlist.c
-cl -c %CFLAGS% genobj.c
-cl -c %CFLAGS% gensym.c
-cl -c %CFLAGS% keywords.c
-cl -c %CFLAGS% macro.c
-cl -c %CFLAGS% mops.c
-cl -c %CFLAGS% pops.c
-cl -c %CFLAGS% scan.c
-cl -c %CFLAGS% table.c
-cl -c %CFLAGS% typeconv.c
-@
-del \tmp\as.lib
-lib \tmp\as.lib +assemble.obj +error.obj +express.obj +genbin.obj;
-lib \tmp\as.lib +genlist.obj +genobj.obj +gensym.obj +keywords.obj;
-lib \tmp\as.lib +macro.obj +mops.obj +pops.obj +readsrc.obj;
-lib \tmp\as.lib +scan.obj +table.obj +typeconv.obj;
-@
-cl %CFLAGS% -o as.exe as.obj \tmp\as.lib
-del \tmp\as.lib
-del \tmp\as.bak
-cd ..
-@
-@goto endas
-@
-:docopy
-@
-copy bcc\bcc.exe bin\bcc.exe
-copy bcc\bcc-cc1.exe lib\bcc-cc1.exe
-copy as\as.exe lib\as86.exe
-copy ld\ld.exe lib\ld86.exe
-@
-:endoffile
-@
-@set PROMPT=%OPROMPT%
-@set OPROMPT=
@@ -5,7 +5,7 @@ as86 \- Assembler for 8086..80386 processors .SH SYNOPSIS .B as86 -.RB [ -03agjuw ] +.RB [ -0123agjuw ] .RB [ -lm [ list ]] .RB [ -n\ name ] .RB [ -o\ obj ] @@ -60,10 +60,17 @@ arguments can be '-' for standard in/out. .TP .B -0 -start with 16-bit code segment +start with 16-bit code segment, warn for all instructions > 8086 +.TP +.B -1 +start with 16-bit code segment, warn for all instructions > 80186 +.TP +.B -2 +start with 16-bit code segment, warn for all instructions > 80286 .TP .B -3 -start with 32-bit code segment +start with 32-bit code segment, don't warn for any instructions. (not even +486 or 586) .TP .B -a enable partial compatibility with Minix asld @@ -72,13 +79,17 @@ enable partial compatibility with Minix asld only put global symbols in object or symbol file .TP .B -j -force all jumps to be long, don't use this with hand written assembler -use the +replace short jumps that don't reach with 5 byte sequences, this causes the +assembler to add an extra pass to try to determine if the long jump is +really needed. If you add a second +.B -j +the assembler will keep adding passes until the labels all stabilise (to +a maximum of 30 passes) +Don't use this with hand written assembler use the explicit .B br\ bmi\ bcc -style opcodes or the +style opcodes for 8086 code or the .B jmp\ near -style. The former generates 8086 compatible sequences the latter is 386 only -for the conditional jumps. +style for conditional i386 instructions. .TP .B -l produce list file, filename may follow @@ -205,11 +216,16 @@ Return to stacked assemble location .B GET INCLUDE Insert new file (no quotes on name) .TP -.B USE16 -Define default operand size as 16 bit +.BR USE16\ [ cpu ] +Define default operand size as 16 bit, argument is cpu type the code is +expected to run on (86, 186, 286, 386, 486, 586) instructions for cpus +later than specified give a warning. .TP -.B USE32 -Define default operand size as 32 bit +.BR USE32\ [ cpu ] +Define default operand size as 32 bit, argument is cpu type the code is +expected to run on (86, 186, 286, 386, 486, 586) instructions for cpus +later than specified give a warning. If the cpu is not mentioned the +assembler ensures it is >= 80386. .TP .B END End of compilation for this file. @@ -340,7 +356,12 @@ as(1), ld86(1), bcc(1) The 6809 version does not support -0, -3, -a or -j. If this assembler is compiled with BCC this is classed as a 'small' -compiler, so there is a maximum input line length of 256 characters. +compiler, so there is a maximum input line length of 256 characters +and the instruction to cpu checking is not included. + +The checking for instructions that work on specific cpus is probably +not complete, the distinction between 80186 and 80286 is especially +problematic. The .B .text @@ -156,6 +156,10 @@ error (substitution of some cc passes not supported) print names and args of subprocesses being run. Two or more -v's print names of files being unlinked. Three or more -v's print names of paths being searched. +.TP +.B -W +allow the assembler to generate warnings, useful for finding 80186+ +instructions. .P Other options are passed to the linker, in particular -i-, -lx, -M, -m, -s. The -i option is always passed to the linker but can be cancelled using -i-. @@ -290,7 +294,7 @@ directory to place temporary files (default /tmp) .SH DIRECTORIES All the include, library and compiler components are stored under the .I /usr/bcc -directory under Linux-86, this is laid out the same as a +directory under Linux-i386, this is laid out the same as a .I /usr filesystem and if bcc is to be the primary compiler on a system it should be moved there. The configuration for this is in the diff --git a/mkcompile b/mkcompile new file mode 100644 index 0000000..6995880 --- /dev/null +++ b/mkcompile @@ -0,0 +1,103 @@ +#!/bin/sh + +SRC_BCC='bcc.c' +SRC_CC1='bcc-cc1.c assign.c codefrag.c debug.c declare.c express.c exptree.c + floatop.c function.c gencode.c genloads.c glogcode.c hardop.c input.c + label.c loadexp.c longop.c output.c preproc.c preserve.c scan.c + softop.c state.c table.c type.c' +SRC_AS=' as.c assemble.c error.c express.c genbin.c genlist.c genobj.c gensym.c + keywords.c macro.c mops.c pops.c readsrc.c scan.c table.c typeconv.c' +SRC_LD=' ld.c dumps.c io.c linksyms.c readobj.c table.c typeconv.c + writebin.c writex86.c' + +HDR_BCC='' +HDR_CC1='align.h byteord.h condcode.h const.h gencode.h input.h label.h os.h + output.h parse.h proto.h reg.h sc.h scan.h sizes.h table.h type.h + types.h' +HDR_AS=' address.h byteord.h const.h file.h flag.h globvar.h macro.h opcode.h + proto.h scan.h source.h syshead.h type.h' +HDR_LD=' align.h ar.h bindef.h byteord.h config.h const.h globvar.h obj.h + syshead.h type.h x86_aout.h' + +main() { + echo '@echo off' + echo -n 'if not exist later.exe ' + echo 'cl -nologo -O later.c %LIB%\setargv.obj -link /NOE' + echo + + CFLAGS='-nologo -O' + LDFLAGS='%LIB%\setargv.obj -link /NOE' + ARCH=-Ml + build bcc bcc bin "$HDR_BCC" $SRC_BCC + + CFLAGS='-nologo -O -DPOSIX_HEADERS_MISSING' + LDFLAGS= + ARCH=-Ml + build bcc bcc-cc1 lib "$HDR_CC1" $SRC_CC1 + build as as86 bin "$HDR_AS" $SRC_AS + build ld ld86 lib "$HDR_LD" $SRC_LD + echo ":exit_now" +} + +build() { + DIR="$1" ; shift + PRG="$1" ; shift + BIN="$1" ; shift + HDR="$1" ; shift + OBJ= + BOBJ= + COBJ= + LOBJ= + SRC="$*" + + for i in $SRC + do + j=`basename $i .c` + check_time $DIR/$j.obj $i $HDR + echo -n "if errorlevel 1 " + + echo "cl $ARCH $CFLAGS -c -Fo$DIR\\$j.obj $DIR\\$i" + if [ "$BOBJ" = "" ] + then BOBJ="$DIR\\$j.obj" + else LOBJ="$LOBJ +$DIR\\$j.obj" + fi + COBJ="$COBJ $DIR\\$j.obj" + OBJ="$OBJ $j.obj" + + echo "if errorlevel 1 goto exit_now" + done + + if [ `echo $COBJ | wc -c` -lt 50 ] + then + check_time $BIN/$PRG.exe $OBJ + echo -n "if errorlevel 1 " + echo "cl $ARCH -o $BIN\\$PRG.exe$COBJ $LDFLAGS" + echo "if errorlevel 1 goto exit_now" + else + check_time $BIN/$PRG.exe $OBJ + echo "if not errorlevel 1 goto done_$PRG" + echo "if exist doslib.lib del doslib.lib" + echo $LOBJ | fmt -62 | \ + sed 's/\(.*\)/lib doslib.lib \1; >NUL/' + echo "cl $ARCH -o $BIN\\$PRG.exe $BOBJ doslib.lib $LDFLAGS" + echo "if errorlevel 1 goto exit_now" + echo "if exist doslib.lib del doslib.lib" + echo "if exist doslib.bak del doslib.bak" + echo ":done_$PRG" + fi + echo +} + +check_time() { + TARG="$1" ; shift + + for i + do echo "$DIR/$i" + done | fmt -70 | \ + sed -e "s;\(.*\);later $TARG \1@if errorlevel 3 goto exit_now;" \ + -e '2,$s/^/if not errorlevel 1 /' | \ + tr '@' '\012' +} + +main "$@" | sed 's/$/
/' > compile.bat + |