diff options
49 files changed, 1102 insertions, 549 deletions
@@ -1,5 +1,17 @@ For version 0.16.*. +> Various updates to the bios libc, the vt52 and ansi emulations are + now seperated (and can be both included if needed) and don't have + to be linked. Conio functions work properly in bios and msdos. + +> Added -v (version) + +> as86 and ld86 now delete thier binary outputs if there were errors. + +> Added more 'set' commands generated by '#asm' lines. The new ones begin + with '.' rather than '_' an are based off the 'bp' register rather than + the 'sp' register. + > General clean out of some files that are no longer needed. > as86 modified to use normal malloc routines - no longer has limited diff --git a/Libc_version b/Libc_version deleted file mode 100644 index 201a22c..0000000 --- a/Libc_version +++ /dev/null @@ -1 +0,0 @@ -0.16.2 @@ -0,0 +1,40 @@ +Useful bits for /etc/magic: + +#------------------------------------------------------------------------------ +# Linux 8086 executable +0 lelong&0xFF0000FF 0xC30000E9 Linux-8086 executable, headerless +>5 string . +>>4 string >\0 \b, libc version %s + +0 lelong&0xFF00FFFF 0x04000301 Linux-8086 executable +>2 byte&0x01 !0 \b, unmapped zero page +>2 byte&0x20 0 \b, impure +>2 byte&0x20 !0 +>>2 byte&0x10 !0 \b, A_EXEC +>2 byte&0x02 !0 \b, A_PAL +>2 byte&0x04 !0 \b, A_NSYM +>2 byte&0x08 !0 \b, A_STAND +>2 byte&0x40 !0 \b, A_PURE +>2 byte&0x80 !0 \b, A_TOVLY +>28 long !0 \b, not stripped +>37 string . +>>36 string >\0 \b, libc version %s + +# Other ld86 executable formats ... +0 lelong 0x10200301 Minix-386 executable +>28 long !0 not stripped + +0 lelong 0x10100301 Minix-386 impure executable +>28 long !0 not stripped + +0 lelong&0xFF00FFFF 0x10000301 ld86 I80386 executable +>28 long !0 not stripped + +# Never seen formats. +# 0 belong&0xFFFF00FF 0x0103000B ld86 M68K executable +# 0 belong&0xFFFF00FF 0x0103000C ld86 NS16K executable +# 0 belong&0xFFFF00FF 0x01030017 ld86 SPARC executable + +# AS86/LD86 object files. +# There is _no_ difference between 16 and 32 bit .o files that file can see. +0 string \243\206\001\0 Linux-8086 object file @@ -2,6 +2,8 @@ # This file is part of the Linux-8086 Development environment and is # distributed under the GNU General Public License. +VERSION=0.16.3 + TARGETS= \ clean bcc unproto copt as86 ld86 elksemu \ install install-all install-bcc install-emu install-lib \ @@ -18,10 +20,10 @@ CFLAGS= -O # Some makes take the last of a list as the default ... all: make.fil - PATH="`pwd`/bin:$$PATH" $(MAKE) -f make.fil TOPDIR=`pwd` $@ + PATH="`pwd`/bin:$$PATH" $(MAKE) -f make.fil VERSION=$(VERSION) TOPDIR=`pwd` $@ $(TARGETS): make.fil - PATH="`pwd`/bin:$$PATH" $(MAKE) -f make.fil TOPDIR=`pwd` $@ + PATH="`pwd`/bin:$$PATH" $(MAKE) -f make.fil VERSION=$(VERSION) TOPDIR=`pwd` $@ $(TARGETS): @@ -29,7 +31,7 @@ ld: ld86 as: as86 realclean: - -[ ! -f make.fil ] || $(MAKE) -f make.fil TOPDIR=`pwd` $@ + -[ ! -f make.fil ] || $(MAKE) -f make.fil VERSION=$(VERSION) TOPDIR=`pwd` $@ -rm -f make.fil ifdef ifdef.o make.fil: ifdef makefile.in @@ -70,5 +72,5 @@ Uninstall: @# TO HERE distribution: - @[ `id -u` -eq 0 ] || fakeroot -- sh ./Mk_dist - @[ `id -u` -ne 0 ] || sh ./Mk_dist + @[ `id -u` -eq 0 ] || fakeroot -- sh ./Mk_dist $(VERSION) + @[ `id -u` -ne 0 ] || sh ./Mk_dist $(VERSION) @@ -2,7 +2,7 @@ # # This script builds _and checks_ all the distribution files from my source # directory. It's very selective because I've got a lot of historical and -# other 'junk' in the same directory. (85Mb!) +# other 'junk' in the same directory. (120Mb at the last count!) # trap "exit 1" 1 2 3 15 @@ -13,22 +13,24 @@ TMPSRC=linux86 ARCDIR="$DIR"/dev86arc SRCDIRS='bcc unproto as ar ld copt man elksemu dis88 tests libbsd bin86' -DISTFILES='Libc_version Makefile README COPYING Changes Contributors +DISTFILES='Makefile README COPYING Changes Contributors MAGIC mkcompile GNUmakefile libcompat ifdef.c makefile.in Mk_dist' +VERSION="$1" TMPDIST=$TMPDIR/$TMPSRC rm -rf ${TMPDIR} mkdir -p ${TMPDIST} -#----------------------------------------------------------------------- - -echo Checking version +[ "$VERSION" = '' ] && { + echo 'Usage: $0 <version>' 1>&2 + exit 1 +} -make -s -C libc Libc_version -make -s -C bin86 ungrab -VER=`cat Libc_version` +#----------------------------------------------------------------------- echo Copying most program files. + +make -s -C bin86 ungrab || exit cp -a $DISTFILES $SRCDIRS ${TMPDIST} #----------------------------------------------------------------------- @@ -64,10 +66,10 @@ mkdir ${TMPDIST}/doselks chmod -R og=u-w ${TMPDIST} } -rm -f /tmp/bootblocks.tar.gz /tmp/doselks.tar.gz /tmp/libc-8086-$VER.tar.gz +rm -f /tmp/bootblocks.tar.gz /tmp/doselks.tar.gz /tmp/libc-8086-$VERSION.tar.gz echo Extracting previous version -rm -f $ARCDIR/Dev86src-$VER.tar.gz +rm -f $ARCDIR/Dev86src-$VERSION.tar.gz mkdir ${TMPDIST}.tmp ( cd ${TMPDIST}.tmp @@ -106,31 +108,33 @@ cd ${TMPDIR} mv ${TMPSRC}.old/bootblocks boot.old mv ${TMPSRC}/bootblocks boot -diff -Nurd ${TMPSRC}.old ${TMPSRC} > ${ARCDIR}/Dev86src-$VER.patch +diff -Nurd ${TMPSRC}.old ${TMPSRC} > ${ARCDIR}/Dev86src-$VERSION.patch mv boot.old ${TMPSRC}.old/bootblocks mv boot ${TMPSRC}/bootblocks -diff -Nurd ${TMPSRC}.old/bootblocks ${TMPSRC}/bootblocks >> ${ARCDIR}/Dev86src-$VER.patch +diff -Nurd ${TMPSRC}.old/bootblocks ${TMPSRC}/bootblocks >> ${ARCDIR}/Dev86src-$VERSION.patch -gzip -f9 ${ARCDIR}/Dev86src-$VER.patch +gzip -f9 ${ARCDIR}/Dev86src-$VERSION.patch echo Creating full source archive. -ln -s ${TMPSRC} dev86-$VER -tar cf ${ARCDIR}/Dev86src-$VER.tar dev86-$VER/* -gzip -f9 ${ARCDIR}/Dev86src-$VER.tar +ln -s ${TMPSRC} dev86-$VERSION +tar cf ${ARCDIR}/Dev86src-$VERSION.tar dev86-$VERSION/* +gzip -f9 ${ARCDIR}/Dev86src-$VERSION.tar echo Creating as86 source archive. -ln -s ${TMPSRC}/as as86-$VER -cp -p ${TMPSRC}/man/as86.1 as86-$VER/as86.1 -cp -p ${TMPSRC}/COPYING as86-$VER/COPYING -tar cf ${ARCDIR}/as86-$VER.tar `find as86-$VER/* -prune -type f` +ln -s ${TMPSRC}/as as86-$VERSION +cp -p ${TMPSRC}/man/as86.1 as86-$VERSION/as86.1 +cp -p ${TMPSRC}/COPYING as86-$VERSION/COPYING +echo VERSION=$VERSION > as86-$VERSION/Version +tar cf ${ARCDIR}/as86-$VERSION.tar `find as86-$VERSION/* -prune -type f` gzip -f9 ${ARCDIR}/as86-*.tar echo Creating bin86 source archive. -make -s -C ${TMPSRC}/bin86 grab -ln -s ${TMPSRC}/bin86 bin86-$VER -tar chf ${ARCDIR}/bin86-$VER.tar bin86-$VER +make -s -C ${TMPSRC}/bin86 VERSION=${VERSION} grab +ln -s ${TMPSRC}/bin86 bin86-$VERSION +echo VERSION=$VERSION > bin86-$VERSION/ld/Version +tar chf ${ARCDIR}/bin86-$VERSION.tar bin86-$VERSION make -s -C ${TMPSRC}/bin86 ungrab gzip -f9 ${ARCDIR}/bin86-*.tar @@ -143,16 +147,16 @@ mkdir -p ${TMPDIST}.ins make -C ${TMPDIST} install ARFLAGS=q DIST=${TMPDIST}.ins ELKSSRC=/dev/null || exit make -C ${TMPDIST} other || exit -tar cf ${ARCDIR}/Dev86bin-$VER.tar -C ${TMPDIST}.ins . -rm -f ${ARCDIR}/Dev86clb-$VER.zip Bcc +tar cf ${ARCDIR}/Dev86bin-$VERSION.tar -C ${TMPDIST}.ins . +rm -f ${ARCDIR}/Dev86clb-$VERSION.zip Bcc ln -s ${TMPDIST} Bcc -zip -9rpk ${ARCDIR}/Dev86clb-$VER.zip \ +zip -9rpk ${ARCDIR}/Dev86clb-$VERSION.zip \ Bcc/lib/crt0.o Bcc/lib/libc.a Bcc/lib/libbsd.a \ Bcc/lib/libdos.a Bcc/lib/libc_f.a Bcc/lib/libc_s.a \ Bcc/lib/i386/crt0.o Bcc/lib/i386/libc.a || exit rm Bcc -gzip -9f ${ARCDIR}/Dev86bin-$VER.tar || exit +gzip -9f ${ARCDIR}/Dev86bin-$VERSION.tar || exit echo Process completed. diff --git a/ar/Makefile b/ar/Makefile index 61772df..792a77a 100644 --- a/ar/Makefile +++ b/ar/Makefile @@ -18,7 +18,7 @@ install: ar86 install -m 755 ar86 $(LIBDIR) clean realclean clobber: - rm -f *.o ar86 ar.h rel_aout.h + rm -f *.o ar86 ar ar.h rel_aout.h $(OBJS): ar.h rel_aout.h @@ -293,7 +293,7 @@ extern void replace_members (void); extern void touch_symdef_member (int outdesc, char *outname); extern void two_operations (void); extern void update_symdefs (struct mapelt *map, int archive_indesc); -extern void usage (char *s1, char *s2); +extern void usage (char *s1, int val); extern void write_archive (struct mapelt *map, int appendflag); extern void write_symdef_member (struct mapelt *mapelt, struct mapelt *map, int outdesc, char *outname); #endif @@ -507,7 +507,7 @@ main (argc, argv) break; default: - usage ("invalid operation %d", (void*)operation); + usage ("invalid operation %d", operation); } exit (0); @@ -1994,10 +1994,13 @@ update_symdefs (map, archive_indesc) /* Print error message and usage message, and exit. */ void -usage (s1, s2) - char *s1, *s2; +usage (s1, val) + char *s1; + int val; { - error (s1, s2); + char vbuf[16]; + sprintf(vbuf, "%d", val); + error (s1, vbuf); fprintf (stderr, "\ Usage: %s [d|m|p|q|r|t|x [[abi [position-name] [cilouv]] archive file...\n", program_name); diff --git a/as/Makefile b/as/Makefile index 4dedc8d..5873f14 100644 --- a/as/Makefile +++ b/as/Makefile @@ -1,4 +1,8 @@ +ifeq ($(VERSION),) +include Version +endif + CFLAGS=-O LDFLAGS=-s LIBDIR=/usr/bin @@ -30,6 +34,9 @@ install: all clean realclean clobber: rm -f *.o as86 as86_encap +.c.o: + $(CC) -DVERSION='"$(VERSION)"' $(CFLAGS) -c $< + as.o: const.h type.h byteord.h macro.h file.h flag.h globvar.h assemble.o: const.h type.h address.h globvar.h opcode.h scan.h error.o: const.h type.h @@ -25,6 +25,9 @@ PRIVATE struct schain_s hid_mcpar[MACPSIZ]; /* MACRO params */ PRIVATE struct macro_s hid_macstak[MAXBLOCK]; /* macro stack */ PRIVATE struct sym_s *hid_spt[SPTSIZ]; /* hash table */ +PRIVATE char * binfilename = 0; +PRIVATE char * objfilename = 0; + FORWARD void initp1 P((void)); FORWARD int my_creat P((char *name, char *message)); FORWARD void process_args P((int argc, char **argv)); @@ -77,6 +80,16 @@ PUBLIC void finishup() if (lstfil != STDOUT && (toterr != 0 || totwarn != 0)) summary(STDOUT); statistics(); + + /* If an output binary is in error remove it */ + close(binfil); binfil=0; + close(objfil); objfil=0; + if (toterr != 0) + { + if(binfilename) unlink(binfilename); + if(objfilename) unlink(objfilename); + } + exit(toterr != 0 ? 1 : 0); /* should close output files and check */ } @@ -175,6 +188,11 @@ char **argv; } switch (arg[1]) { + case 'v': + outfd = STDOUT; + writes("as86 version: "); + writesn(VERSION); + exit(1); #ifdef I80386 case '0': case '1': case '2': idefsize = defsize = 0x2; @@ -191,7 +209,7 @@ char **argv; case 'b': if (!isnextarg || binfil != 0) usage(); - binfil = my_creat(nextarg, "error creating binary file"); + binfil = my_creat(binfilename=nextarg, "error creating binary file"); binaryg = TRUE; --argc; ++argv; @@ -234,7 +252,7 @@ char **argv; if (!isnextarg || objfil != 0) usage(); objectg = TRUE; - objfil = my_creat(nextarg, "error creating object file"); + objfil = my_creat(objfilename=nextarg, "error creating object file"); --argc; ++argv; break; diff --git a/as/syshead.h b/as/syshead.h index b3ca9eb..2e06496 100644 --- a/as/syshead.h +++ b/as/syshead.h @@ -18,6 +18,7 @@ #include <fcntl.h> #undef min #undef POSIX_HEADERS_MISSING +#define VERSION "MSDOS Compile" #endif #if __STDC__ && !defined(__minix) diff --git a/bcc/Makefile b/bcc/Makefile index ed4854f..93b122c 100644 --- a/bcc/Makefile +++ b/bcc/Makefile @@ -12,6 +12,8 @@ BINDIR =$(PREFIX)/bin LIBDIR =$(LIBPRE)/lib/bcc BCCDEFS =-DLOCALPREFIX=$(LIBPRE) -DBINDIR=$(BINDIR) -DDEFARCH=0 +BCFLAGS=$(ANSI) $(CFLAGS) $(LDFLAGS) -DVERSION='"$(VERSION)"' + OBJS = bcc-cc1.o codefrag.o debug.o declare.o express.o exptree.o floatop.o \ function.o gencode.o genloads.o glogcode.o hardop.o input.o label.o \ loadexp.o longop.o output.o preproc.o preserve.o scan.o softop.o \ @@ -26,16 +28,16 @@ install: all install -m 755 bcc-cc1 $(LIBDIR)/bcc-cc1 bcc: bcc.c - $(CC) $(ANSI) $(CFLAGS) $(BCCDEFS) $(LDFLAGS) $^ -o $@ + $(CC) $(BCFLAGS) $(BCCDEFS) $^ -o $@ ncc: bcc.c - $(CC) $(ANSI) $(CFLAGS) -DL_TREE -DDEFARCH=0 $(LDFLAGS) $^ -o $@ + $(CC) $(BCFLAGS) -DL_TREE -DDEFARCH=0 $^ -o $@ bcc09: bcc.c - $(CC) $(ANSI) $(CFLAGS) -DMC6809 $(BCCDEFS) $(LDFLAGS) $^ -o $@ + $(CC) $(BCFLAGS) -DMC6809 $(BCCDEFS) $^ -o $@ ccc: bcc.c - $(CC) $(ANSI) $(CFLAGS) -DCCC $(BCCDEFS) $(LDFLAGS) $^ -o $@ + $(CC) $(BCFLAGS) -DCCC $(BCCDEFS) $^ -o $@ bcc-cc1: $(OBJS) $(CC) $(BCCARCH) $(LDFLAGS) $(OBJS) -o bcc-cc1 @@ -41,6 +41,7 @@ #define F_OK 0 /* Test for existence. */ #define L_TREE 1 /* Use different tree style */ #define DEFARCH 0 /* Default to 8086 code */ +#define VERSION "MSDOS Compile" #else #define EXESUF #endif @@ -224,8 +225,6 @@ char ** argv; if (do_compile && next_file->filetype == 'i') run_compile(next_file); if (do_optim && next_file->filetype == 's') run_optim(next_file); if (do_as && next_file->filetype == 's') run_as(next_file); - - if (next_file->filetype == '~') error_count++; } if (do_link && !error_count) @@ -979,7 +978,11 @@ int size; void Usage() { - fatal("Usage: bcc [-ansi] [-options] [-o output] file [files]"); + if (opt_v) + fprintf(stderr, "%s: version %s\n", progname, VERSION); + fprintf(stderr, + "Usage: %s [-ansi] [-options] [-o output] file [files].\n", progname); + exit(1); } void fatal(str) @@ -1134,7 +1137,10 @@ static char ** minienviron[] = { (void) signal(SIGTERM, otsig); (void) signal(SIGCHLD, ocsig); #endif - if (status && file) - file->filetype = '~'; + if (status) + { + if (file) file->filetype = '~'; + error_count++; + } } diff --git a/bcc/codefrag.c b/bcc/codefrag.c index e7961ce..bdcb850 100644 --- a/bcc/codefrag.c +++ b/bcc/codefrag.c @@ -1617,6 +1617,18 @@ offset_T value; outset(); outshex(value); outnl(); +#ifdef FRAMEPOINTER + if (framep) + { + outbyte(LOCALSTARTCHAR); + outstr(funcname); + outbyte(LOCALSTARTCHAR); + outstr(name); + outset(); + outshex(value+sp-framep); + outnl(); + } +#endif } /* shift left register by 1 */ diff --git a/bin86/Makefile b/bin86/Makefile index 4c8dd82..2be62a8 100644 --- a/bin86/Makefile +++ b/bin86/Makefile @@ -48,5 +48,5 @@ grab: mkdir man cp -p ../man/ld86.1 man cp -p ../man/as86.1 man - touch -r ChangeLog . as ld man + touch -r ../Changes . as ld man diff --git a/bootblocks/Makefile b/bootblocks/Makefile index 6efa75b..40e7817 100644 --- a/bootblocks/Makefile +++ b/bootblocks/Makefile @@ -2,15 +2,15 @@ HOSTCC=cc HOSTCCFLAGS=-O BCC=bcc +AS86=as86 +DEFS= CC=$(BCC) -CFLAGS=-ansi -Ms -Oi -O -s +CFLAGS=-ansi -Ms -Oi -O -s $(DEFS) # CFLAGS=-ansi -Ms ASFLAGS=-0 -w MINIXDEFS=-DDOTS -MONDEFS= # LST=-l $*.lst -# CLST=-A-l -A$*.lst default: makeboot makeboot.com monitor.out minix_elks.bin lsys.com @@ -20,7 +20,7 @@ bootsys: bootfile.sys boottar.sys bootminix.sys CSRC=minix.c SSRC=sysboot.s tarboot.s skip.s com_bcc.s tich.s mbr.s msdos.s noboot.s \ - boot_fpy.s + boot_fpy.s killhd.s encap: $(SSRC:s=v) $(CSRC:c=v) minixhd.v msdos16.v bootbin: $(SSRC:s=bin) $(CSRC:c=bin) minixhd.bin msdos16.bin minix_elks.bin @@ -39,10 +39,13 @@ EXTRAS=minix.h elf_info.c elf_info.h standalone.c li86.s \ install: +monitor.com: $(MOBJ) + $(CC) $(CFLAGS) $(MONDEFS) -H0x10000 -d $(MOBJ) -o monitor.com -M > monitor.sym + monitor.out: $(MOBJ) $(CC) $(CFLAGS) $(MONDEFS) -H0x10000 $(MOBJ) -o monitor.out -M > monitor.sym -$(MOBJ): $(MINC) version.h +$(MOBJ): $(MINC) fs_min.o: minix.h bootfile.sys: $(MSRC) $(MINC) @@ -72,13 +75,13 @@ monitor: $(MSRC) $(MINC) bzimage.o: bzimage.c zimage.v minix.s: minix.c Makefile - $(BCC) -Mf -O -DTRY_FLOPPY $(MINIXDEFS) -S minix.c + $(CC) -Mf -O -DTRY_FLOPPY $(MINIXDEFS) -S minix.c minix_elks.s: minix_elks.c Makefile minix.v - $(BCC) -Mf -O $(MINIXDEFS) -S minix_elks.c + $(CC) -Mf -O $(MINIXDEFS) -S minix_elks.c minixhd.s: minix.c Makefile - $(BCC) -Mf -O -DHARDDISK $(MINIXDEFS) -S minix.c -o minixhd.s + $(CC) -Mf -O -DHARDDISK $(MINIXDEFS) -S minix.c -o minixhd.s msdos16.s: msdos.s sed 's/^fatbits=12/fatbits=16/' < msdos.s > msdos16.s @@ -87,19 +90,15 @@ makeboot: makeboot.c $(BOOTBLOCKS) $(HOSTCC) $(HOSTCCFLAGS) -o makeboot makeboot.c makeboot.com: makeboot.c $(BOOTBLOCKS) - $(BCC) -Md -O -o makeboot.com makeboot.c + $(CC) -Md -O -o makeboot.com makeboot.c lsys.com: lsys.c msdos.v msdos16.v - $(BCC) -Md -O -o lsys.com lsys.c - -version.h: - head -1 ../Libc_version | \ - sed 's/\(.*\)/#define VERSION "\1"/' > version.h + $(CC) -Md -O -o lsys.com lsys.c clean realclean: rm -f bootfile.sys boottar.sys bootminix.sys rm -f monitor makeboot bootblocks.tar.gz - rm -f minix.s minixhd.s minix_elks.s version.h msdos16.s + rm -f minix.s minixhd.s minix_elks.s msdos16.s rm -f *.com *.o *.bin *.out *.lst *.sym *.v *.tmp tgz: minix.bin monitor.out makeboot.com makeboot @@ -121,9 +120,7 @@ distribution: .SUFFIXES: .bin .v .s.bin: - $(BCC) -W -c $*.s -A-u- -A-b -A$*.tmp -A-s -A$*.sym $(CLST) - mv $*.tmp $*.bin - -@rm $*.o + $(AS86) -w- -0 -b $*.bin -s $*.sym $*.s $(LST) .s.v: as86_encap $*.s $*.v $*_ $(ASFLAGS) $(LST) diff --git a/bootblocks/README b/bootblocks/README index 81fc634..26abd97 100644 --- a/bootblocks/README +++ b/bootblocks/README @@ -31,9 +31,16 @@ Contents 1.1 ) Master boot sector - This MBR is a very simple one with no frills, being less that 254 bytes - long is can be used as an MBR for a disk with old style 'Disk manager' - partitions. All 16 partitions are bootable. + This MBR is a very simple one with no frills by default. + + The actual code is less that 254 bytes long so it can be used as + an MBR for a disk with old style 'Disk manager' partitions. All 16 + partitions are bootable. + + Option 2 is a boot message that displayed as soon as the MBR loads. + + Option 3 is code to accept a keypress from the user to select which + partition to boot (or the floppy). 1.2 ) Dosfs boot sector @@ -54,8 +61,9 @@ Contents as my testing has gone this is only significant on 8086 machines, all others (286 8Mhz +) are fast enough to keep up at a 1-1 interleve. - But some older versions of superformat defeat this because they do - not correctly calculate intersector gaps. + But some versions of superformat can defeat this because they do + not correctly calculate intersector gaps. I suggest using fdformat + as this uses a 'safe' layout for standard 1440k disks. 1.3 ) Minixfs boot block diff --git a/bootblocks/boot_fpy.s b/bootblocks/boot_fpy.s index ef1f21a..a40d0fa 100644 --- a/bootblocks/boot_fpy.s +++ b/bootblocks/boot_fpy.s @@ -3,36 +3,59 @@ ! ! cat boot_fpy.bin monitor.out > /dev/fd0 ! -! Warning: Disk errors currently cause a hang. -! The boot sector does not end with $AA55 this is not a problem -! with the BIOS but many boot managers will not boot it. ORGADDR=0x0600 -EXEADDR=0x06E0 +EXEADDR=0x0800 ! This must be up to 0x7E0 or 0x0800 LOADSEG=0x0080 ! Must be 512b aligned for DMA +! Padding so you can join with 'cat'. .org EXEADDR-1 -.byte 0xFF ! Marker +.byte 0 + +! This marker is needed by many boot managers (and bochs) but the BIOS does +! NOT require it on a floppy. +if EXEADDR=0x0800 +.org ORGADDR+0x1FE +.word 0xAA55 +endif .org ORGADDR entry start public start start: - mov ax,#$07C0 ! Relocate to ORGADDR - mov ds,ax xor ax,ax - mov es,ax - mov cx,#256 - mov si,ax + mov si,#$7C00 mov di,#ORGADDR + + mov ss,ax + mov sp,di ! Or si or ax + + push ax + pop ds + push ax + pop es + + mov cx,#256 cld rep - movsw + movsw jmpi go,#0 go: - mov ds,ax ! Setup SP & S-regs - mov ss,ax - mov sp,#ORGADDR + +! Grrr, have to load sector 1 in by hand. +if EXEADDR=0x0800 +Loopi: + mov ax,#$0201 ! Read 1 sector + mov bx,#EXEADDR ! Into EXEADDR + mov cx,#$0002 ! From sector 2 + xor dx,dx ! Of the floppy drive head zero + int $13 + jc Loopi +endif + + mov si,#Boot_message + call puts + mov ax,[a_text] ! How many sectors to load mov cl,#4 shr ax,cl @@ -51,7 +74,7 @@ go: ! But occasionally some older machines have really poor BIOSes ! (Some modern ones too) so once we know how many sectors to read ! we switch to reading a track at a time. But we only try it once - ! for each track, normally, as long as the load address is sector + ! for each track. Normally, as long as the load address is sector ! aligned, this will work every time but with some BIOSes we can't ! read a track without messing with the BPB so if the track read ! fails it's one try we fall back to sector reads. @@ -62,10 +85,11 @@ go: ! your BIOS is one of the bad ones you'll have to format your disks ! to a 2:1 interleave. ! - ! BTW: There are some versions of superformat that incorrectly - ! calculate the inter-sector gaps and end up squeezing the sectors - ! to the start of the track. This means that only a full track read - ! is fast enough. + ! BTW: It's very easy to make superformat incorrectly calculate the + ! inter-sector gaps so it ends up squeezing the sectors to the start + ! of the track. This means that only a full track read is fast enough. + ! I suggest you use fdformat as it always uses 'safe' parameters for + ! a 1440k floppy. ! AX = count of sectors mov cx,#2 ! CX = First sector @@ -176,12 +200,37 @@ bad_magic: retf sect_error: - ! TODO Error. - j sect_error + ! Disk error, wait then reboot. + + mov si,#reboot_msg + call puts + + xor ax,ax ! Wait for the user. + int $16 + jmpi $0,$FFFF + +puts: + lodsb + cmp al,#0 + jz EOS + push bx + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + pop bx + jmp puts +EOS: + ret maxsect: .word 0 +reboot_msg: + .asciz "Disk error, press a key to reboot:" + +Boot_message: + .asciz "Boot sector loaded.\r\n" + ! Check for overlap end_of_code: if end_of_code>hitme diff --git a/bootblocks/i86_funcs.c b/bootblocks/i86_funcs.c index dd9ec33..2112141 100644 --- a/bootblocks/i86_funcs.c +++ b/bootblocks/i86_funcs.c @@ -122,7 +122,6 @@ void mem_check() main_mem_top = 16384; return; /* If not standalone don't try */ #else - { #asm int 0x12 ! Amount of boot memory mov cl,#6 @@ -144,12 +143,66 @@ got_ext: mov [_main_mem_top],ax #endasm - } - if( main_mem_top == 0xFFFFL ) - { - /* It say 64Mb-1k - Hmmmm I think it might be 128! */ - } + /* Rest are big memory for 80386+ */ + if( x86 < 3 ) return; + + /* Try int $15 EAX=$E820 */ + { + struct e820_dat { + unsigned long base_lo, base_hi; + unsigned long len_lo, len_hi; + long addr_type; + } e820_item; + long epoll = 0; + + do + { + e820_item.addr_type = 0; +#asm + mov eax,#$E820 + mov ebx,.mem_check.epoll[bp] + mov ecx,#20 + mov edx,#$534D4150 + push ds + pop es + lea di,.mem_check.e820_item[bp] + int $15 + jnc got_e820 + xor ebx,ebx +got_e820: + mov .mem_check.epoll[bp],ebx +#endasm + if (e820_item.addr_type == 1 + && e820_item.base_hi == 0 + && e820_item.base_lo == 0x100000L) + { + /* XXX Later ... */ + if (e820_item.len_hi) main_mem_top = 0x40000; + else + main_mem_top = (e820_item.len_lo >> 10); + return; + } + } + while(epoll); + } + + /* Try int $15 EAX=$E801 */ + { + unsigned int mem_64, mem_16; /* For int $15,AX=$E801 */ +#asm + mov ax,#$E801 + int $15 + jc no_e801 + mov .mem_check.mem_16[bp],ax + mov .mem_check.mem_64[bp],bx +#endasm + main_mem_top = ((unsigned long)mem_64<<6) + mem_16; +#asm +no_e801: +#endasm + } + #endif } diff --git a/bootblocks/killhd.s b/bootblocks/killhd.s new file mode 100644 index 0000000..b4cd3b5 --- /dev/null +++ b/bootblocks/killhd.s @@ -0,0 +1,42 @@ +! +! This program destroys the MBR and the start of the first partition of +! the hard disk. IT DOES NOT HAVE AN 'ARE YOU SURE?' +! + +org $7c00 + +include sysboot.s + +org dos_sysid + .ascii "DEATH" ! System ID + + org codestart + + cld + xor ax,ax + mov es,ax + mov ds,ax + mov ss,ax + mov sp,ax + + mov di,#$8000 + mov cx,#$0400 + rep + stosw ! Zap a space. + + mov dx,#$0080 + mov cx,#$0001 + mov bx,#$8000 + mov ax,#$0301 + int $13 ! Zap the MBR + + mov dx,#$0180 + mov cx,#$0001 + mov bx,#$8000 + mov ax,#$0304 + int $13 ! Zap the first partition boot and super. + + xor ax,ax ! Wait for key + int $16 + jmpi $0,$FFFF ! Reboot + diff --git a/bootblocks/mbr.s b/bootblocks/mbr.s index e633c87..a5e4585 100644 --- a/bootblocks/mbr.s +++ b/bootblocks/mbr.s @@ -10,13 +10,15 @@ ! Space for 12 extra partitions in the 'DiskManager' form that Linux ! _does_ understand. ! -! NB: This needs Dev86 0.15.2 or later +! NB: This needs as86 0.15.2 or later ! Lowest available is $0500, MSDOS appears to use $0600 ... I wonder why? ORGADDR=$0500 preboot=0 ! Include the pre-boot loader. mbrkey=0 ! Option to choose the boot record base on keystroke message=1 ! Display boot message +use512=0 ! Put the end marker at byte 510..512 + diskman=0 ! Disk manager partitions, allows 16 partitions but ! don't overwrite this with a LILO BB. @@ -137,7 +139,7 @@ no_boot: ! SI now has pointer to error message mov si,#crlf call puts tick: - call key_wait + call key_pause j tick else @@ -159,8 +161,7 @@ EOS: keyboot: ! Wait for a key then reboot xor ax,ax int $16 -! int $19 ! This rarely does anything useful... - jmpi $0,$FFFF ! Wam! Try or die! + jmpi $0,$FFFF ! Reboot. press_key: .asciz "\r\nPress return:" @@ -190,9 +191,16 @@ linearise: ! Choose the partition based on a pressed key ... if mbrkey +key_pause: + mov si,#Pause + call puts + j wait_key + key_wait: mov si,#Prompt call puts + +wait_key: mov di,#19 ! Wait for 18-19 ticks next_loop: @@ -214,18 +222,16 @@ bad_key: ret Got_key: + mov ah,#0 ! Clean the kbd buffer. + int $16 + cmp al,#$20 - jnz not_space - mov si,#Pause - j showit -not_space: + jz key_pause ! Recursion !? + mov Showkey,al mov si,#Showkey -showit: call puts - - mov ah,#0 ! Clean the kbd buffer. - int $16 + mov al,Showkey ! ... Now we use our key ... ! 0 => Floppy @@ -270,11 +276,11 @@ EOS: ret Prompt: - .asciz "MBR: " + .asciz "\rMBR 0-4: " Unprompt: - .asciz "\b\b\b\b\b \b\b\b\b\b" + .asciz "\r \r" Pause: - .asciz "\b\b> " + .asciz "\rMBR 0-4> " Showkey: .ascii " " crlf: @@ -393,5 +399,9 @@ diskman_magic: .byte 0xFF endif + if use512 + org ORGADDR+0x1FE + .word 0xAA55 + endif !THE END diff --git a/bootblocks/minix.c b/bootblocks/minix.c index 62b3031..69daa1a 100644 --- a/bootblocks/minix.c +++ b/bootblocks/minix.c @@ -230,8 +230,7 @@ min_nextc: min_eos: ! 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! + jmpi $0,$FFFF ! Reboot. fail_fs: .byte 13,10 diff --git a/bootblocks/monitor.c b/bootblocks/monitor.c index 27f25ea..ed823a6 100644 --- a/bootblocks/monitor.c +++ b/bootblocks/monitor.c @@ -1,6 +1,5 @@ #include "monitor.h" -#include "version.h" char command_buf[256]; @@ -39,13 +38,11 @@ static char minibuf[2] = " "; #ifndef NOCOMMAND if( __get_ds() != 0x1000 ) { - /* First to top of RAM */ - relocator(-1); + /* First out of the way. */ + relocator(3); /* Then align DS to 64k boundry -> DMA is simple. */ relocator(0x1000-__get_ds()+__get_cs()); - /* Oops, relocate down didn't work, try a little higher. */ - if( __get_ds() > 0x1000 ) relocator(2); printf("Relocated to CS=$%04x DS=$%04x\n", __get_cs(), __get_ds()); } #endif @@ -127,7 +124,9 @@ static char minibuf[2] = " "; void init_prog() { + int offt; #ifdef COLOUR + vt52_putch(0); printf("\033E\033Rg\033Sa\033J"); #endif printf("Linux x86"); @@ -170,16 +169,15 @@ void init_prog() } printf("\n"); - printf("There is %dk of boot memory", boot_mem_top/64); + printf("There is %u bytes available", offt-sbrk(0)); + printf(", %dk of boot memory", boot_mem_top/64); if( main_mem_top ) { - printf(" %d.%dM %sof main memory", + printf(", %d.%dM of main memory", (int)(main_mem_top/1024), - (int)((10*main_mem_top)/1024%10), - main_mem_top >= 0xFC00L ?"(perhaps more) ":"" - ); + (int)((10*main_mem_top)/1024%10)); } - printf("\n"); + printf(".\n"); } /****************************************************************************/ diff --git a/bootblocks/msdos.s b/bootblocks/msdos.s index 4e9eb1a..7f8156e 100644 --- a/bootblocks/msdos.s +++ b/bootblocks/msdos.s @@ -213,8 +213,7 @@ no_boot: ! SI now has pointer to error message 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! + jmpi $0,$FFFF ! Reboot. !--------------------------------------------------------------------------- ! This loads the boot program 1 sector at a time, funny thing is it actually diff --git a/bootblocks/skip.s b/bootblocks/skip.s index aed4e40..c33e432 100644 --- a/bootblocks/skip.s +++ b/bootblocks/skip.s @@ -72,8 +72,7 @@ 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! + jmpi $0,$FFFF ! Reboot. mesg2: .asciz "Disk error\r\n" mesg3: .asciz "Retrying\r\n" diff --git a/copt/copt.c b/copt/copt.c index e440f31..cc31541 100644 --- a/copt/copt.c +++ b/copt/copt.c @@ -352,7 +352,7 @@ static void doretval(void) */ static long eval(char *str, int len) { - char *oldcp, *cp, c; + char *cp, c; int state = 0; int i, varnum; @@ -438,7 +438,7 @@ static int match(char *ins, char *pat) char *cp, *oldpat; long val; int varnum; - int len; + int len = 0; while (*ins && *pat) { @@ -811,7 +811,8 @@ static void usage(void) /* * Main program */ -void main(int argc, char **argv) +int +main(int argc, char **argv) { char comment = NOCHAR; char *srcfile = NULL; diff --git a/copt/copt1 b/copt/copt1 Binary files differdeleted file mode 100755 index 2883aba..0000000 --- a/copt/copt1 +++ /dev/null diff --git a/ld/Makefile b/ld/Makefile index 393876c..104a740 100644 --- a/ld/Makefile +++ b/ld/Makefile @@ -1,4 +1,8 @@ +ifeq ($(VERSION),) +include Version +endif + LIBDIR =/usr/bin CFLAGS =-O LDFLAGS = @@ -9,7 +13,7 @@ LDFLAGS = # -DSTANDARD_GNU_A_OUT # a.out.h is like GNU normal. # -DNO_AOUT # a.out.h is like nothing known! # -DEFS =-DREL_OUTPUT -DBUGCOMPAT +DEFS =-DREL_OUTPUT -DBUGCOMPAT -DVERSION='"$(VERSION)"' # An alternative file for a non-standard a.out.h (eg i386 linux on an Alpha) # @@ -127,8 +127,10 @@ int level; PUBLIC void executable() { + if (errcount) + unlink(outputname); #ifndef MSDOS - if (errcount == 0) + else chmod(outputname, outputperms); #endif } @@ -620,6 +622,13 @@ PUBLIC void usage() #endif } +PUBLIC void version_msg() +{ + stderr_out(); + putstr("ld86 version: "); + errexit(VERSION); +} + PUBLIC void use_error(message) char *message; { @@ -99,6 +99,8 @@ char **argv; else switch (arg[1]) { + case 'v': + version_msg(); case 'r': /* relocatable output */ #ifndef REL_OUTPUT #ifndef MSDOS diff --git a/ld/syshead.h b/ld/syshead.h index fa5c23a..8ea2a3a 100644 --- a/ld/syshead.h +++ b/ld/syshead.h @@ -25,6 +25,7 @@ #define SEEK_SET 0 #define STDOUT_FILENO 0 #define STDERR_FILENO 0 +#define VERSION "MSDOS Compile" #endif /******************************************************************************/ @@ -119,6 +119,7 @@ void reserved P((char *name)); void size_error P((int seg, bin_off_t count, bin_off_t size)); void undefined P((char *name)); void usage P((void)); +void version_msg P((void)); void use_error P((char *message)); /* ld.c */ diff --git a/libc/Makefile b/libc/Makefile index 01e05d7..d5887b2 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -9,11 +9,6 @@ else TOP=$(TOPDIR)/libc endif -VERMAJOR=0 -VERMINOR=16 -VERPATCH=2 -VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH) - CC=bcc CCFLAGS=-I -I$(TOP)/include DEFS=-D__LIBC__ @@ -38,13 +33,13 @@ $(LIBC): transfer .config.dir done crt3.o: crt0.c Makefile - $(CC) -c $(CFLAGS) -D__LIBC_VER__='"$(VER)"' -o $@ crt0.c + $(CC) -c $(CFLAGS) -D__LIBC_VER__='"$(VERSION)"' -o $@ crt0.c crt0.o: crt0.c Makefile - $(CC) -c $(CFLAGS) -D__LIBC_VER__='"$(VER)"' -o $@ crt0.c + $(CC) -c $(CFLAGS) -D__LIBC_VER__='"$(VERSION)"' -o $@ crt0.c crtg.o: crt0.c Makefile - $(CC) -c $(CFLAGS) -D__LIBC_VER__='"$(VER)"' -o $@ crt0.c + $(CC) -c $(CFLAGS) -D__LIBC_VER__='"$(VERSION)"' -o $@ crt0.c crtX.o: @echo "You need to define the 'PLATFORM=...' variable," @@ -103,6 +98,3 @@ noconfig: rm -f .config.dir .config.lst .config.tmp ############################################################################ - -Libc_version: - echo $(VER) > ../Libc_version diff --git a/libc/bios/Makefile b/libc/bios/Makefile index 3b01e77..cd97308 100644 --- a/libc/bios/Makefile +++ b/libc/bios/Makefile @@ -8,9 +8,13 @@ AOBJ=bios_start.o bios_isatty.o bios_nofiles.o \ bios_read.o bios_write.o bios_lseek.o bios_close.o BSRC=bios_vid.c -BOBJ=bios_putc.o bios_getc.o bios_getce.o bios_khit.o bios_rdline.o +BOBJ=bios_putch.o bios_getch.o bios_getche.o bios_cputs.o bios_kbhit.o \ + bios_rdline.o -OBJ=$(AOBJ) $(BOBJ) time.o fileops.o fs_dos.o rawio.o +CSRC=bios_min.c +COBJ=bios_putc.o bios_getc.o + +OBJ=$(AOBJ) $(BOBJ) $(COBJ) time.o fileops.o fs_dos.o rawio.o vt52.o ansi.o CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) @@ -24,6 +28,10 @@ $(LIBC)($(AOBJ)): $(ASRC) $(LIBC)($(BOBJ)): $(BSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)($(COBJ)): $(CSRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o else all: @: diff --git a/libc/bios/README b/libc/bios/README index cc883e1..4a35d6e 100644 --- a/libc/bios/README +++ b/libc/bios/README @@ -5,6 +5,7 @@ under the GNU Library General Public License. This is a very simple set of functions for standalone executables. There is a choice as to which console type you want to use, I think -the VT52 clone is best. +the VT52 clone is best. To activate it you have to call 'vt52_putc' +at least once. -Robert diff --git a/libc/bios/ansi.c b/libc/bios/ansi.c new file mode 100644 index 0000000..d049cf8 --- /dev/null +++ b/libc/bios/ansi.c @@ -0,0 +1,262 @@ +/* Copyright (C) 1996 Robert de Bath <robert@mayday.compulink.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#if !__FIRST_ARG_IN_AX__ +#ifdef __AS386_16__ +#ifdef __STANDALONE__ + +#include <bios.h> +#include <errno.h> +int errno; + +extern void (*__smart_putch)(); + +#define CTRL(x) ((x)&0x1F) +static int last_attr = 0x07; +static int con_mode; +static unsigned char con_height = 24, con_width = 79; + +static int con_colour = 0; +static unsigned char con_row, con_col; + +#ifdef ANSI_CON +#define MAX_ARGS 8 +static int colconv[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; +static int vidcnt = 0; +static int ansi_2 = 0; +static int ansi_argc = 0; +static int ansi_argv[MAX_ARGS]; +static void do_ansi(); + +ansi_putch(c) +int c; +{ + if( con_mode==0 ) asm_coninit(); + __smart_putch = ansi_putch; + + if( vidcnt == 0 || c < ' ' || c > '~' ) + { + switch(c & 0xFF) + { + default: + asm_colour(last_attr); + asm_putc(c); + break; + case CTRL('I'): + asm_gpos(); + con_col = ((con_col+8)& -8); + asm_cpos(con_row, con_col); + break; + case CTRL('L'): + asm_cpos(0,0); + asm_cls(); + break; + case CTRL('['): + vidcnt=1; + break; + } + return; + } + + /* ... ansi/vt100 interpretation, this collects _all_ ansi control strings */ + switch(vidcnt) + { + case 1: for(ansi_argc=0; ansi_argc<MAX_ARGS; ansi_argc++) + ansi_argv[ansi_argc] = 0; + ansi_2 = 0; + ansi_argc = 0; + vidcnt++; + + if( c != '[' ) + { + do_ansi(c + 0x1B00, ansi_argc, ansi_argv); + vidcnt = 0; + } + break; + + case 2: if( c == ';' ) + { + if( ansi_argc < MAX_ARGS ) + ansi_argc++; + } + else if( c >= '0' && c <= '9' ) + ansi_argv[ansi_argc] = ansi_argv[ansi_argc] * 10 + c - '0'; + else if( c >= '@' ) + { + do_ansi(c+ansi_2, ++ansi_argc, ansi_argv); + vidcnt = 0; + } + else + ansi_2 = (c<<8); + break; + + default: vidcnt = 0; /* This definitly won't happen ... definitly ... */ + } +} + +void +do_ansi(ctrl, argc, argv) +int ctrl, argc, *argv; +{ + switch(ctrl) + { + case 'A': + case 'B': + case 'C': + case 'D': + asm_gpos(); + if( argv[0] < 1 ) argv[0] = 1; + switch(ctrl) + { + case 'A': if( argv[0]>con_row ) con_row=0; else con_row-=argv[0]; break; + case 'B': if( argv[0]+con_row>con_height ) + con_row = con_height; + else + con_row += argv[0]; + break; + case 'C': if( argv[0]+con_col>con_width ) + con_col = con_width; + else + con_col += argv[0]; + break; + case 'D': if( argv[0]>con_col ) con_col=0; else con_col-=argv[0]; break; + } + asm_cpos(con_row, con_col); + break; + + case 'H': + if( --argv[0] < 0 ) argv[0] = 0; + if( --argv[1] < 0 ) argv[1] = 0; + asm_cpos(argv[0],argv[1]); + break; + case 'J': if( argv[0] == 2 ) asm_cls(); + break; + case 'm': + { + int ar; + for(ar=0; ar<argc; ar++) switch(argv[ar]) + { + case 0: last_attr = 0x07; break; + case 1: last_attr |= 0x08; break; + case 5: last_attr |= 0x80; break; + case 7: last_attr = 0x70; break; + case 30: case 31: case 32: case 33: + case 34: case 35: case 36: case 37: + if( con_colour ) + last_attr = ((last_attr&0xF8)|(colconv[argv[ar]-30])); + break; + case 40: case 41: case 42: case 43: + case 44: case 45: case 46: case 47: + if( con_colour ) + last_attr = ((last_attr&0x8F)|((colconv[argv[ar]-40])<<4)); + break; + default: break; + } + } + } +} +#endif + +static asm_coninit() +{ +#asm + mov ax,#$0F00 + int $10 + mov _con_mode,ax +#endasm + if( (con_mode &0xFF) > 39 ) con_width = (con_mode>>8); + if( (con_mode&0xFF) != 0x7) + con_colour = 1; +} + +static asm_putc(c) +{ +#asm +#if !__FIRST_ARG_IN_AX__ + mov bx,sp + mov ax,[bx+2] +#endif + cmp al,#$0A + jne not_nl + mov ax,#$0E0D + mov bx,#7 + int $10 + mov al,#$0A +not_nl: + mov ah,#$0E + mov bx,#7 + 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 dl,_con_width + mov dh,_con_height + 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 +} + +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_gpos() +{ +#asm + mov ah,#$03 + mov bx,#7 + int $10 + mov [_con_row],dh + mov [_con_col],dl + mov ax,cx +#endasm +} + +#endif +#endif +#endif diff --git a/libc/bios/bios.c b/libc/bios/bios.c index ab592a0..3e10686 100644 --- a/libc/bios/bios.c +++ b/libc/bios/bios.c @@ -82,8 +82,8 @@ not_dos: sti zap_bss: ! Clear the BSS - mov ax,ds - mov es,ax ! ES now data seg + push ds + pop es ! ES now data seg mov di,#__edata mov cx,#__end sub cx,di @@ -143,21 +143,19 @@ __exit: seg cs cmp [dos_flag],#0 ! Should we do a DOS exit je do_reboot - int #$20 + mov ax,#$4c00 + int $21 do_reboot: #endif xor ax,ax - mov es,ax + mov ds,ax mov ax,cs - seg es mov [$E6*4+2],ax mov ax,#iret_ins - seg es mov [$E6*4],ax mov ax,#$FFFF int $E6 ! Try to exit DOSEMU ! If we get here we`re not in dosemu. - seg es mov [$472],#$1234 ! Warm reboot. jmpi $0000,$FFFF iret_ins: diff --git a/libc/bios/bios_min.c b/libc/bios/bios_min.c new file mode 100644 index 0000000..ef86c4a --- /dev/null +++ b/libc/bios/bios_min.c @@ -0,0 +1,61 @@ +/* Copyright (C) 1996 Robert de Bath <robert@mayday.compulink.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#ifdef __AS386_16__ +#ifdef __STANDALONE__ + +#include <bios.h> + +#ifdef L_bios_putc +bios_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 +} +#endif + +/****************************************************************************/ + +#ifdef L_bios_getc +bios_getc() +{ +#asm + xor ax,ax + int $16 +#endasm +} +#endif + +/****************************************************************************/ + +#ifdef L_bios_khit +bios_khit() +{ +#asm + mov ah,#1 + int $16 + jz nokey + cmp ax,#0 + jnz dort + mov ax,#3 +dort: + ret +nokey: + xor ax,ax +#endasm +} +#endif + +/****************************************************************************/ + +#endif +#endif diff --git a/libc/bios/bios_vid.c b/libc/bios/bios_vid.c index bbe7545..8c55100 100644 --- a/libc/bios/bios_vid.c +++ b/libc/bios/bios_vid.c @@ -3,11 +3,6 @@ * under the GNU Library General Public License. */ -/* Various possible console types */ -#define VT52_CON /* IMO the best, no clear to EOS/EOL tho */ -#define XANSI_CON /* Largest but still not complete */ -#define XDUMB_CON /* Can't do much */ - #if !__FIRST_ARG_IN_AX__ #ifdef __AS386_16__ #ifdef __STANDALONE__ @@ -16,352 +11,102 @@ #include <errno.h> int errno; -#ifdef L_bios_putc -#define CTRL(x) ((x)&0x1F) -static int last_attr = 0x07; -static int con_mode; -static unsigned char con_height = 24, con_width = 79; - -static int con_colour = 0; -static unsigned char con_row, con_col; - -#ifdef VT52_CON -putch(c) -int c; -{ -static int ctrl = 0; - int new_attr; - if( con_mode==0 ) asm_coninit(); - - switch( ctrl ) - { - case 1: - ctrl=0; - switch(c) - { - case 'A': if( con_row ) con_row--; asm_cpos(con_row, con_col); break; - case 'B': if( con_row != con_height ) con_row++; - asm_cpos(con_row, con_col); break; - case 'C': if( con_col != con_height ) con_col++; - asm_cpos(con_row, con_col); break; - case 'D': if( con_col ) con_col--; asm_cpos(con_row, con_col); break; - case 'E': last_attr = 0x07; asm_cls(); - case 'H': asm_cpos(0,0); break; - case 'J': asm_cls(); break; - case 'K': break; - case 'R': ctrl = 2; break; /* Foreground */ - case 'S': ctrl = 3; break; /* Background */ - case 'Y': ctrl = 4; break; /* ttypos */ - } - break; - case 2: ctrl=0; new_attr = (last_attr & 0xF0) + (c&0xF); - if(0) { - case 3: ctrl=0; new_attr = (last_attr & 0x0F) + (c<<4); - } - switch(c) - { - case '_': if( !con_colour ) last_attr = (last_attr&0x88) + 1; - break; - case '!': last_attr = (last_attr&0x88) + 0x70; break; - case ' ': last_attr = 0x07; break; - case '+': last_attr |= 0x08; break; - case '*': last_attr |= 0x80; break; - - default: if( con_colour ) - last_attr = new_attr; - } - break; - case 4: ctrl=5; con_col = c-' '; break; - case 5: ctrl=0; con_row = c-' '; asm_cpos(con_row, con_col); break; - break; - - default: - if( c & 0xE0 ) - { asm_colour(last_attr) ; asm_putc(c); } - else switch(c) - { - default: - asm_putc(c); - break; - case CTRL('I'): - asm_gpos(); - con_col = ((con_col+8)& -8); - asm_cpos(con_row, con_col); - break; - case CTRL('L'): - asm_cpos(0,0); - asm_cls(); - break; - case CTRL('['): - ctrl = 1; - asm_gpos(); - break; - } - break; - } -} -#endif - -#ifdef ANSI_CON -#define MAX_ARGS 8 -static int colconv[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; -static int vidcnt = 0; -static int ansi_2 = 0; -static int ansi_argc = 0; -static int ansi_argv[MAX_ARGS]; -static void do_ansi(); +#ifdef L_bios_putch +void (*__smart_putch)() = 0; putch(c) int c; { - if( con_mode==0 ) asm_coninit(); - - if( vidcnt == 0 || c < ' ' || c > '~' ) - { - switch(c & 0xFF) - { - default: - asm_colour(last_attr); - asm_putc(c); - break; - case CTRL('I'): - asm_gpos(); - con_col = ((con_col+8)& -8); - asm_cpos(con_row, con_col); - break; - case CTRL('L'): - asm_cpos(0,0); - asm_cls(); - break; - case CTRL('['): - vidcnt=1; - break; - } - return; - } - - /* ... ansi/vt100 interpretation, this collects _all_ ansi control strings */ - switch(vidcnt) - { - case 1: for(ansi_argc=0; ansi_argc<MAX_ARGS; ansi_argc++) - ansi_argv[ansi_argc] = 0; - ansi_2 = 0; - ansi_argc = 0; - vidcnt++; - - if( c != '[' ) - { - do_ansi(c + 0x1B00, ansi_argc, ansi_argv); - vidcnt = 0; - } - break; - - case 2: if( c == ';' ) - { - if( ansi_argc < MAX_ARGS ) - ansi_argc++; - } - else if( c >= '0' && c <= '9' ) - ansi_argv[ansi_argc] = ansi_argv[ansi_argc] * 10 + c - '0'; - else if( c >= '@' ) - { - do_ansi(c+ansi_2, ++ansi_argc, ansi_argv); - vidcnt = 0; - } - else - ansi_2 = (c<<8); - break; - - default: vidcnt = 0; /* This definitly won't happen ... definitly ... */ +static int col = 0; + if (__smart_putch) + (*__smart_putch)(c); + else if (c&0xE0) { + col++; + asm_putc(c); } -} - -void -do_ansi(ctrl, argc, argv) -int ctrl, argc, *argv; -{ - switch(ctrl) + else switch(c) { - case 'A': - case 'B': - case 'C': - case 'D': - asm_gpos(); - if( argv[0] < 1 ) argv[0] = 1; - switch(ctrl) - { - case 'A': if( argv[0]>con_row ) con_row=0; else con_row-=argv[0]; break; - case 'B': if( argv[0]+con_row>con_height ) - con_row = con_height; - else - con_row += argv[0]; - break; - case 'C': if( argv[0]+con_col>con_width ) - con_col = con_width; - else - con_col += argv[0]; - break; - case 'D': if( argv[0]>con_col ) con_col=0; else con_col-=argv[0]; break; - } - asm_cpos(con_row, con_col); + case '\t': + do putch(' '); while(col&7); break; - - case 'H': - if( --argv[0] < 0 ) argv[0] = 0; - if( --argv[1] < 0 ) argv[1] = 0; - asm_cpos(argv[0],argv[1]); - break; - case 'J': if( argv[0] == 2 ) asm_cls(); - break; - case 'm': - { - int ar; - for(ar=0; ar<argc; ar++) switch(argv[ar]) - { - case 0: last_attr = 0x07; break; - case 1: last_attr |= 0x08; break; - case 5: last_attr |= 0x80; break; - case 7: last_attr = 0x70; break; - case 30: case 31: case 32: case 33: - case 34: case 35: case 36: case 37: - if( con_colour ) - last_attr = ((last_attr&0xF8)|(colconv[argv[ar]-30])); - break; - case 40: case 41: case 42: case 43: - case 44: case 45: case 46: case 47: - if( con_colour ) - last_attr = ((last_attr&0x8F)|((colconv[argv[ar]-40])<<4)); - break; - default: break; - } - } - } -} -#endif - -#ifdef DUMB_CON -putch(c) -int c; -{ - if( con_mode==0 ) asm_coninit(); - switch(c) - { - default: + case '\n': + asm_putc('\r'); + case '\r': + col = 0; asm_putc(c); break; - case CTRL('L'): - asm_cls(); - case CTRL('^'): - asm_cpos(0,0); - break; - } -} -#endif - -static asm_coninit() -{ + case '\f': + col = 0; #asm - mov ax,#$0F00 - int $10 - mov _con_mode,ax + mov ah,#$0F + int $10 + mov ah,#$00 + int $10 #endasm - if( (con_mode &0xFF) > 39 ) con_width = (con_mode>>8); - if( (con_mode&0xFF) != 0x7) - con_colour = 1; + break; + } } static asm_putc(c) { #asm #if !__FIRST_ARG_IN_AX__ - mov bx,sp - mov ax,[bx+2] + mov bx,sp + mov ax,[bx+2] #endif - cmp al,#$0A - jne not_nl - mov ax,#$0E0D - mov bx,#7 - int $10 - mov al,#$0A -not_nl: - mov ah,#$0E - mov bx,#7 - int $10 + mov ah,#$0E + mov bx,#7 + 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 dl,_con_width - mov dh,_con_height - int $10 - pop bp -#endasm -} +#endif -static asm_cpos(r,c) +/****************************************************************************/ + +#ifdef L_bios_getch +getch() { #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 + xor ax,ax + int $16 #endasm } +#endif + +/****************************************************************************/ -#ifndef DUMB_CON -static asm_colour(c) +#ifdef L_bios_kbhit +kbhit() { #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 + mov ah,#1 + int $16 + jz nokey + cmp ax,#0 + jnz dort + mov ax,#3 +dort: + ret +nokey: + xor ax,ax #endasm } +#endif + +/****************************************************************************/ -static asm_gpos() +#ifdef L_bios_cputs +cputs(str) + char * str; { -#asm - mov ah,#$03 - mov bx,#7 - int $10 - mov [_con_row],dh - mov [_con_col],dl - mov ax,cx -#endasm + while(*str) putch(*str++); } #endif -#endif /****************************************************************************/ -#ifdef L_bios_getce +#ifdef L_bios_getche getche() { static char linebuf[80]; @@ -380,6 +125,33 @@ getche() } #endif +/****************************************************************************/ + +#ifdef L_bios_gotoxy +static gotoxy(x,y) +{ +#asm +#if __FIRST_ARG_IN_AX__ + mov bx,sp + mov dl,al + mov ax,[bx+2] + mov dh,al +#else + mov bx,sp + mov ax,[bx+4] + mov dh,al + mov ax,[bx+2] + mov dl,al +#endif + mov ah,#$02 + mov bx,#7 + int $10 +#endasm +} +#endif + +/****************************************************************************/ + #ifdef L_bios_rdline bios_rdline(buf, len) char * buf; @@ -436,38 +208,7 @@ int len; /****************************************************************************/ -#ifdef L_bios_getc -getch() -{ -#asm - xor ax,ax - int $16 -#endasm -} -#endif - -/****************************************************************************/ - -#ifdef L_bios_khit -kbhit() -{ -#asm - mov ah,#1 - int $16 - jz nokey - cmp ax,#0 - jnz dort - mov ax,#3 -dort: - ret -nokey: - xor ax,ax -#endasm -} -#endif - -/****************************************************************************/ - #endif #endif #endif + diff --git a/libc/bios/vt52.c b/libc/bios/vt52.c new file mode 100644 index 0000000..4574c12 --- /dev/null +++ b/libc/bios/vt52.c @@ -0,0 +1,202 @@ +/* Copyright (C) 1996 Robert de Bath <robert@mayday.compulink.co.uk> + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#if !__FIRST_ARG_IN_AX__ +#ifdef __AS386_16__ +#ifdef __STANDALONE__ + +#include <bios.h> +#include <errno.h> +int errno; + +extern void (*__smart_putch)(); + +#define CTRL(x) ((x)&0x1F) +static int last_attr = 0x07; +static int con_mode; +static unsigned char con_height = 24, con_width = 79; + +static int con_colour = 0; +static unsigned char con_row, con_col; + +vt52_putch(c) +int c; +{ +static int ctrl = 0; + int new_attr; + __smart_putch = vt52_putch(); + + if( con_mode==0 ) asm_coninit(); + + switch( ctrl ) + { + case 1: + ctrl=0; + switch(c) + { + case 'A': if( con_row ) con_row--; asm_cpos(con_row, con_col); break; + case 'B': if( con_row != con_height ) con_row++; + asm_cpos(con_row, con_col); break; + case 'C': if( con_col != con_height ) con_col++; + asm_cpos(con_row, con_col); break; + case 'D': if( con_col ) con_col--; asm_cpos(con_row, con_col); break; + case 'E': last_attr = 0x07; asm_cls(); + case 'H': asm_cpos(0,0); break; + case 'J': asm_cls(); break; + case 'K': break; + case 'R': ctrl = 2; break; /* Foreground */ + case 'S': ctrl = 3; break; /* Background */ + case 'Y': ctrl = 4; break; /* ttypos */ + } + break; + case 2: ctrl=0; new_attr = (last_attr & 0xF0) + (c&0xF); + if(0) { + case 3: ctrl=0; new_attr = (last_attr & 0x0F) + (c<<4); + } + switch(c) + { + case '_': if( !con_colour ) last_attr = (last_attr&0x88) + 1; + break; + case '!': last_attr = (last_attr&0x88) + 0x70; break; + case ' ': last_attr = 0x07; break; + case '+': last_attr |= 0x08; break; + case '*': last_attr |= 0x80; break; + + default: if( con_colour ) + last_attr = new_attr; + } + break; + case 4: ctrl=5; con_col = c-' '; break; + case 5: ctrl=0; con_row = c-' '; asm_cpos(con_row, con_col); break; + break; + + default: + if( c & 0xE0 ) + { asm_colour(last_attr) ; asm_putc(c); } + else switch(c) + { + default: + asm_putc(c); + break; + case CTRL('I'): + asm_gpos(); + con_col = ((con_col+8)& -8); + asm_cpos(con_row, con_col); + break; + case CTRL('L'): + asm_cpos(0,0); + asm_cls(); + break; + case CTRL('['): + ctrl = 1; + asm_gpos(); + break; + } + break; + } +} + +static asm_coninit() +{ +#asm + mov ax,#$0F00 + int $10 + mov _con_mode,ax +#endasm + if( (con_mode &0xFF) > 39 ) con_width = (con_mode>>8); + if( (con_mode&0xFF) != 0x7) + con_colour = 1; +} + +static asm_putc(c) +{ +#asm +#if !__FIRST_ARG_IN_AX__ + mov bx,sp + mov ax,[bx+2] +#endif + cmp al,#$0A + jne not_nl + mov ax,#$0E0D + mov bx,#7 + int $10 + mov al,#$0A +not_nl: + mov ah,#$0E + mov bx,#7 + 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 dl,_con_width + mov dh,_con_height + 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 +} + +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_gpos() +{ +#asm + mov ah,#$03 + mov bx,#7 + int $10 + mov [_con_row],dh + mov [_con_col],dl + mov ax,cx +#endasm +} + +#endif +#endif +#endif + diff --git a/libc/conio/Makefile b/libc/conio/Makefile index 662b0ec..21b0a4d 100644 --- a/libc/conio/Makefile +++ b/libc/conio/Makefile @@ -3,13 +3,10 @@ # under the GNU Library General Public License. ASRC=conio.c -AOBJ=getch.o getche.o kbhit.o putch.o +AOBJ=getch.o getche.o kbhit.o putch.o cputs.o gotoxy.o -BSRC=conio.c -BOBJ=cputs.o - -BIOSOBJ=$(BOBJ) cprintf.o -DOSOBJ=$(AOBJ) $(BOBJ) cprintf.o +BIOSOBJ=cprintf.o +DOSOBJ=$(AOBJ) cprintf.o CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) diff --git a/libc/conio/conio.c b/libc/conio/conio.c index ee311a5..dfe30ee 100644 --- a/libc/conio/conio.c +++ b/libc/conio/conio.c @@ -9,8 +9,7 @@ * I'm not sure if these should be BIOS or dos calls, so I'll assume they're * BIOS calls but I may have to do something about Ctrl-C. * - * These functions are also compiled for __STANDALONE__ so if ^C or DOS - * versions are made this will have to be addressed. + * Not implemented: cgets() cscanf() getpass() ungetch() */ #ifdef L_getch @@ -73,22 +72,26 @@ char * str; } #endif -#if 0 - -cgets() -{ -} - -cscanf() -{ -} - -getpass() -{ -} - -gotoxy() +#ifdef L_gotoxy +static gotoxy(x,y) { +#asm +#if __FIRST_ARG_IN_AX__ + mov bx,sp + mov dl,al + mov ax,[bx+2] + mov dh,al +#else + mov bx,sp + mov ax,[bx+4] + mov dh,al + mov ax,[bx+2] + mov dl,al +#endif + mov ah,#$02 + mov bx,#7 + int $10 +#endasm } - #endif + diff --git a/libc/conio/cprintf.c b/libc/conio/cprintf.c index 5194376..5368c89 100644 --- a/libc/conio/cprintf.c +++ b/libc/conio/cprintf.c @@ -11,7 +11,7 @@ static unsigned char * __numout(long i, int base); int cprintf(char * fmt, ...) { register int c; - int count = 0; + register int count = 0; int type, base; long val; char * cp; diff --git a/libc/include/conio.h b/libc/include/conio.h index 7219a8f..13532d3 100644 --- a/libc/include/conio.h +++ b/libc/include/conio.h @@ -9,6 +9,7 @@ int getch __P((void)); int getche __P((void)); int kbhit __P((void)); int putch __P((int)); +int gotoxy __P((int, int)); #if 0 /* Unimplemented as yet */ char * cgets __P((char *)); diff --git a/libc/include/ctype.h b/libc/include/ctype.h index ed22ef7..a724a4c 100644 --- a/libc/include/ctype.h +++ b/libc/include/ctype.h @@ -21,18 +21,20 @@ extern unsigned char __ctype[]; #define _tolower(c) ((c)^0x20) #define toascii(c) ((c)&0x7F) +#define __CT(c) (__ctype[1+(unsigned char)c]) + /* 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) (!!(__CT(c)&(__CT_u|__CT_l|__CT_d))) +#define isalpha(c) (!!(__CT(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) (!!(__CT(c)&__CT_c)) +#define isdigit(c) (!!(__CT(c)&__CT_d)) +#define isgraph(c) (!(__CT(c)&(__CT_c|__CT_s))) +#define islower(c) (!!(__CT(c)&__CT_l)) +#define isprint(c) (!(__CT(c)&__CT_c)) +#define ispunct(c) (!!(__CT(c)&__CT_p)) +#define isspace(c) (!!(__CT(c)&__CT_s)) +#define isupper(c) (!!(__CT(c)&__CT_u)) +#define isxdigit(c) (!!(__CT(c)&__CT_x)) #endif /* __CTYPE_H */ diff --git a/libc/misc/ctype.c b/libc/misc/ctype.c index 6b6cd3d..0425f00 100644 --- a/libc/misc/ctype.c +++ b/libc/misc/ctype.c @@ -12,8 +12,9 @@ #undef toupper #undef tolower -unsigned char __ctype[128] = +unsigned char __ctype[257] = { + 0, /* -1 */ __CT_c, __CT_c, __CT_c, __CT_c, /* 0x00..0x03 */ __CT_c, __CT_c, __CT_c, __CT_c, /* 0x04..0x07 */ __CT_c, __CT_c|__CT_s, __CT_c|__CT_s, __CT_c|__CT_s, /* 0x08..0x0B */ diff --git a/libc/misc/strtol.c b/libc/misc/strtol.c index bcd3334..d8d62ea 100644 --- a/libc/misc/strtol.c +++ b/libc/misc/strtol.c @@ -18,6 +18,8 @@ * */ +/* TODO: This needs range clamping and setting errno when it's done. */ + #include <ctype.h> #include <stdlib.h> @@ -86,13 +88,16 @@ strtoul(const char *nptr, char **endptr, int base) base=10; number=0; - while (isalnum(*nptr)) + while (isascii(*nptr) && isalnum(*nptr)) { - number= (number*base)+((isalpha(*nptr) ? toupper(*nptr) : *nptr) - - (isdigit(*nptr) ? '0' : 'A' + 9)); - nptr++; - if (*nptr>'0'+base) + int ch = *nptr; + if (islower(ch)) ch = toupper(ch); + ch -= (ch<='9' ? '0' : 'A'-10); + if (ch>base) break; + + number= (number*base)+ch; + nptr++; } /* Some code is simply _impossible_ to write with -Wcast-qual .. :-\ */ diff --git a/makefile.in b/makefile.in index 3cf85c7..5089564 100644 --- a/makefile.in +++ b/makefile.in @@ -16,8 +16,9 @@ ARFLAGS =r CC =%CC% CFLAGS =%CFLAGS% LDFLAGS = -MAKEARG =CC='$(CC)' CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' PREFIX=$(PREFIX) \ - LIBPRE='$(LIBPRE)' LIBDIR='$(LIBDIR)' BINDIR='$(BINDIR)' ANSI='$(ANSI)' +MAKEARG =CC='$(CC)' CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' \ + PREFIX=$(PREFIX) LIBPRE='$(LIBPRE)' LIBDIR='$(LIBDIR)' \ + BINDIR='$(BINDIR)' ANSI='$(ANSI)' VERSION='$(VERSION)' MAKEC=$(MAKE) -C MAKEX= @@ -64,7 +64,7 @@ binary can be either linked by GCC or executed by linux. If the option is also included the linker can generate a QMAGIC executable. .TP .B -Ox -add library libdir-from-search/x to list of files linked +add library or object file libdir-from-search/x to list of files linked .TP .B -T text base address follows (in format suitable for strtoul) |