diff options
-rw-r--r-- | Changes | 80 | ||||
-rw-r--r-- | Libc_version | 2 | ||||
-rw-r--r-- | Make.defs | 10 | ||||
-rw-r--r-- | README | 9 | ||||
-rw-r--r-- | README.ash | 2 | ||||
-rw-r--r-- | as/Makefile | 7 | ||||
-rw-r--r-- | as/TODO | 2 | ||||
-rw-r--r-- | as/as.c | 48 | ||||
-rw-r--r-- | as/as.doc | 169 | ||||
-rwxr-xr-x | as/as86_encap | 40 | ||||
-rw-r--r-- | as/assemble.c | 1 | ||||
-rwxr-xr-x | as/chk | 16 | ||||
-rw-r--r-- | as/const.h | 24 | ||||
-rw-r--r-- | as/error.c | 7 | ||||
-rw-r--r-- | as/express.c | 1 | ||||
-rw-r--r-- | as/file.h | 15 | ||||
-rw-r--r-- | as/genbin.c | 37 | ||||
-rw-r--r-- | as/genlist.c | 58 | ||||
-rw-r--r-- | as/genobj.c | 16 | ||||
-rw-r--r-- | as/gensym.c | 59 | ||||
-rw-r--r-- | as/globvar.h | 7 | ||||
-rw-r--r-- | as/keywords.c | 736 | ||||
-rw-r--r-- | as/macro.c | 13 | ||||
-rw-r--r-- | as/mops.c | 54 | ||||
-rw-r--r-- | as/pops.c | 24 | ||||
-rw-r--r-- | as/proto.h | 5 | ||||
-rw-r--r-- | as/readsrc.c | 343 | ||||
-rw-r--r-- | as/scan.c | 3 | ||||
-rw-r--r-- | as/scan.h | 2 | ||||
-rw-r--r-- | as/syshead.h | 50 | ||||
-rw-r--r-- | as/table.c | 747 | ||||
-rw-r--r-- | as/type.h | 5 | ||||
-rw-r--r-- | as/typeconv.c | 536 | ||||
-rw-r--r-- | bcc/Makefile | 6 | ||||
-rw-r--r-- | bcc/bcc.doc | 9 | ||||
-rw-r--r-- | bcc/codefrag.c | 32 | ||||
-rw-r--r-- | bcc/const.h | 15 | ||||
-rw-r--r-- | bcc/exptree.c | 12 | ||||
-rw-r--r-- | bcc/function.c | 4 | ||||
-rw-r--r-- | bcc/gencode.c | 2 | ||||
-rw-r--r-- | bcc/gencode.h | 2 | ||||
-rw-r--r-- | bcc/genloads.c | 23 | ||||
-rw-r--r-- | bcc/glogcode.c | 4 | ||||
-rw-r--r-- | bcc/hardop.c | 2 | ||||
-rwxr-xr-x | bcc/idcc | 311 | ||||
-rw-r--r-- | bcc/input.c | 9 | ||||
-rw-r--r-- | bcc/label.c | 2 | ||||
-rw-r--r-- | bcc/ncc.c | 215 | ||||
-rw-r--r-- | bcc/scan.c | 12 | ||||
-rw-r--r-- | bcc/state.c | 4 | ||||
-rw-r--r-- | bcc/table.c | 14 | ||||
-rw-r--r-- | bcc/type.c | 2 | ||||
-rw-r--r-- | elksemu/Makefile | 14 | ||||
-rw-r--r-- | elksemu/V-files.tar | bin | 20480 -> 20480 bytes | |||
-rw-r--r-- | elksemu/binfmt_elks.c | 1 | ||||
-rw-r--r-- | elksemu/elks.c | 7 | ||||
-rw-r--r-- | elksemu/elks_sys.c | 5 | ||||
-rw-r--r-- | elksemu/linux/vm86.h | 8 | ||||
-rw-r--r-- | ld/Makefile | 2 | ||||
l--------- | ld/a_out.h | 1 | ||||
-rw-r--r-- | ld/align.h | 14 | ||||
-rw-r--r-- | ld/config.h | 4 | ||||
-rw-r--r-- | ld/io.c | 51 | ||||
-rw-r--r-- | ld/ld.c | 18 | ||||
-rw-r--r-- | ld/obj.h | 4 | ||||
-rw-r--r-- | ld/readobj.c | 22 | ||||
-rw-r--r-- | ld/syshead.h | 121 | ||||
-rw-r--r-- | ld/table.c | 9 | ||||
-rw-r--r-- | ld/type.h | 20 | ||||
-rw-r--r-- | ld/writebin.c | 118 | ||||
-rw-r--r-- | libbsd/libbsd.a | bin | 5936 -> 5936 bytes | |||
-rw-r--r-- | libc/MAGIC | 8 | ||||
-rw-r--r-- | libc/Make.defs | 2 | ||||
-rw-r--r-- | libc/Makefile | 2 | ||||
-rwxr-xr-x | libc/New_subdir | 2 | ||||
-rw-r--r-- | libc/TODO | 48 | ||||
-rw-r--r-- | libc/bcc/ldiv.c | 27 | ||||
-rw-r--r-- | libc/include/stdlib.h | 16 | ||||
-rw-r--r-- | libc/include/sys/cdefs.h | 3 | ||||
-rw-r--r-- | libc/include/sys/times.h | 21 | ||||
-rw-r--r-- | libc/include/time.h | 7 | ||||
-rw-r--r-- | libc/kinclude/linuxmt/types.h | 2 | ||||
-rw-r--r-- | libc/libc.a | bin | 78644 -> 82366 bytes | |||
-rw-r--r-- | libc/misc/Makefile | 17 | ||||
-rw-r--r-- | libc/string/string.c | 2 | ||||
-rw-r--r-- | libc/syscall/Makefile | 2 | ||||
-rw-r--r-- | libc/syscall/syscall.dat | 4 | ||||
-rw-r--r-- | libc/syscall/syslibc.c | 29 | ||||
-rw-r--r-- | libc/time/Config | 1 | ||||
-rw-r--r-- | libc/time/Makefile | 17 | ||||
-rw-r--r-- | libc/time/README | 7 | ||||
-rw-r--r-- | libc/time/asc_conv.c | 46 | ||||
-rw-r--r-- | libc/time/asctime.c | 15 | ||||
-rw-r--r-- | libc/time/ctime.c | 26 | ||||
-rw-r--r-- | libc/time/gmtime.c | 15 | ||||
-rw-r--r-- | libc/time/localtime.c | 22 | ||||
-rw-r--r-- | libc/time/tm_conv.c | 64 | ||||
-rw-r--r-- | make_bcc.bat | 100 |
98 files changed, 3177 insertions, 1555 deletions
@@ -1,46 +1,34 @@ -Sorry silly little Robert has lost his changes file; so I'll have to do this -from the diff ... - -libbsd: Some bsd style stuff from Rick Sladkey, <jrs@world.std.com> - -There's now a module for Linux-i386 > 1.3.? to allow auto loading of elksemu - -The BCC tools will now compile using MSC 5.1, mail me if you'd like the BINs - -BCC has a new keyword 'asm(str)' the constant string argument is passed to -the assembler; (Daniel Horak <horak20@hermes.zcu.cz>) - -All assmenbler that isn't generated by BCC is marked in the *.s by special -comment lines. - -BCC default arguments have been slightly modified again. - bcc -o x x.c # Linux executable - bcc -Mf -o x x.c # Linux executable using caller saves and AX. - bcc -Md -o x x.c # MSDOS COM executable -The default CPU is always 8086. - -Elksemu can (possibly should) now be run suid-root it can then honour suid -and execute only executables. Check elksemu/Security. - -Problem with ELKSemu signal handling fixed, if process was started with -disabled signals it thought they were SIG_DFL. - -More functions added to libc, - __get_es, __get_cs, __strchr_es and friends. - dos_stat.c, dos_isatty.c dos_segalloc, dos_segfree, - -Stdio1 has been removed, It was rather buggy and some people have had problems -because of this. Joel, am I going to get another version ? - -Setvbuf added to stdio2, humm Y'd I miss it ? - -Some process group functions added. - -Quite a few direct system calls have been added to syscall.dat - but there's -no support for them in ELKSemu :-( - -Bug in return value from __lseek corrected. - -cfmakeraw added. - --Rob. +For version 0.0.7. + +I've been making quite a few changes to the assembler: + The 'include' or 'get' command now works. + The '-b' and '-s' options are now quite useful for bootblocks + or encapsulated code. + The standard input is now a valid source for the assemble + (but only on 'big' machines). + Various other functions now work, macros, 'jmp near', + 'jmpi qword $100000,$1000', and other bug fixes. + As86_encap script added. + Some of the 256 char line limits have been removed for non-bcc compiles. + +The linker will now fail more gracefully for reversed 'org's and complain +about too large segments. + +Bcc-cc1 will now compile under itself, with some limitations, and appears +to generate correct output. There are problems tho in that I think the +heap<->stack saftey margin is too short and I've disconnected all code for +floating point features. + +The components will all compile and seem to work quite well using MSC 5.1 +under dos and will probably compile using other dos compilers. BCC cannot +compile itself under dos because the libs to fake the unix syscalls under +dos are currently too large. + +A number of fixes have been added that were apperently in another version +of the tools to aid operation on other machines, there's now a better chance +of these programs working on 'big-endian' machines. + +Various bits and pieces have been added to the libs, including some time +functions (but these need a _small_ way of dealing with "DST"). + +-Rob diff --git a/Libc_version b/Libc_version index 1750564..5a5831a 100644 --- a/Libc_version +++ b/Libc_version @@ -1 +1 @@ -0.0.6 +0.0.7 @@ -1,11 +1,11 @@ -# WALL =-Wall -Wtraditional -Wshadow -Wid-clash-14 -Wpointer-arith \ -# -Wcast-qual -Wcast-align -Wconversion -Waggregate-return \ -# -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls \ -# -Wnested-externs -Winline +WALLP =-Wtraditional -Wshadow -Wid-clash-14 -Wpointer-arith \ + -Wcast-qual -Wcast-align -Wconversion -Waggregate-return \ + -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls \ + -Wnested-externs -Winline # unproto is yukky -WALL=-Wno-comment +WALL=-Wno-comment -Wstrict-prototypes CCFLAGS =-Wall $(WALL) -O2 -fno-strength-reduce LDFLAGS =-s @@ -20,14 +20,19 @@ that /usr/bcc/include is a symlink into this directory. It is now also possible to make libc.a versions for MSDOS and a more compact version with 'CALLER_SAVES' and 'FIRST_ARG_IN_AX'. "Make install-lib2" does this and 'bcc -Md x.c -o x.com" or "bcc x.c -Mf x.c -o x" uses the libs. +To compile bcc using bcc this has to be done. 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, I've just discovered the dosemu folks have been using the +'-r' option of ld86, Grrrrr. Well **** them, they can use as86_encap, it's +better suited to the job anyway. + To compile the various tools as Linux-8086 binaries cd into the relevent -directory and do a "make clean ; make" from there, note you'll have to -do "ld" before "as". Currently bcc won't work this way. +directory and do a "make clean ; make" from there. +Bcc _WILL_ now work this way! Yippee! :-) 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_ @@ -17,7 +17,7 @@ diff -ru ash-linux-0.2/Makefile ash/Makefile # Makefile,v 1.7 1993/08/09 04:58:18 mycroft Exp +CC=bcc -+CFLAGS=-DSHELL ++CFLAGS=-e -DSHELL +LDFLAGS=-s + PROG= sh diff --git a/as/Makefile b/as/Makefile index a4c5456..392b8e6 100644 --- a/as/Makefile +++ b/as/Makefile @@ -8,7 +8,7 @@ endif OBJS =as.o assemble.o error.o express.o \ genbin.o genlist.o genobj.o gensym.o \ - macro.o mops.o pops.o readsrc.o \ + keywords.o macro.o mops.o pops.o readsrc.o \ scan.o table.o typeconv.o all: as86 @@ -20,8 +20,8 @@ install: all install -d $(LIBDIR) install -m 755 as86 $(LIBDIR) -typeconv.o: dummy - -cp -p ../ld/typeconv.o . +# typeconv.o: dummy +# -cp -p ../ld/typeconv.o . dummy: @@ -37,6 +37,7 @@ genlist.o: const.h type.h address.h flag.h file.h globvar.h macro.h scan.h \ source.h genobj.o: const.h type.h address.h file.h globvar.h gensym.o: const.h type.h flag.h file.h globvar.h +keywords.o: const.h type.h globvar.h opcode.h macro.o: const.h type.h globvar.h scan.h macro.h mops.o: const.h type.h globvar.h opcode.h scan.h address.h pops.o: const.h type.h address.h flag.h globvar.h opcode.h scan.h @@ -1,5 +1,3 @@ -6809/const.h is out of date. -Check why `chk' fails. Update 6809/const.h. @@ -5,6 +5,7 @@ in any order (but no repeated file options) */ +#include "syshead.h" #include "const.h" #include "type.h" #include "byteord.h" @@ -15,31 +16,6 @@ #include "flag.h" #include "globvar.h" -#ifdef STDC_HEADERS_MISSING -void exit P((int status)); -void *malloc P((unsigned size)); -char *strcpy P((char *s1, const char *s2)); -unsigned strlen P((const char *s)); -#else -#include <stdlib.h> -#include <string.h> -#endif - -#ifdef MSDOS -#include <sys/types.h> -#include <fcntl.h> -#else -#ifdef POSIX_HEADERS_MISSING -int close P((int fd)); -int creat P((const char *path, int mode)); -int write P((int fd, const void *buf, unsigned nbytes)); -#else -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> -#endif -#endif - PUBLIC char hexdigit[] = "0123456789ABCDEF"; /* XXX - ld uses lower case */ PRIVATE struct block_s hid_blockstak[MAXBLOCK]; /* block stack */ @@ -64,12 +40,21 @@ PUBLIC int main(argc, argv) int argc; char **argv; { +#ifdef __AS386_16__ + heapptr = sbrk(0); + heapend = ((char*)&argc) - STAKSIZ; + brk(heapend); + if(sbrk(0) != heapend) + as_abort("Cannot allocate memory"); +#else +#ifdef SOS_EDOS + heapend = stackreg() - STAKSIZ; +#else heapptr = malloc(USERMEM); heapend = heapptr + USERMEM; if (heapptr == 0) as_abort("cannot allocate memory"); -#ifdef SOS_EDOS - heapend = stackreg() - STAKSIZ; +#endif #endif initp1(); initp1p2(); @@ -116,6 +101,9 @@ PUBLIC void finishup() PRIVATE void initp1() { #ifdef I80386 + idefsize = defsize = 2; /* I think this is probably safer (RDB) */ +#endif +#if 0 idefsize = defsize = sizeof (char *) > 2 ? 4 : 2; #endif lctabtop = lctab + NLOC; @@ -173,7 +161,7 @@ char **argv; do { arg = *++argv; - if (arg[0] == '-') + if (arg[0] == '-' && arg[1] != '\0') { if (arg[2] != 0) usage(); /* no multiple options */ @@ -267,8 +255,8 @@ char **argv; { if (strlen(arg) > FILNAMLEN) as_abort("source file name too long"); - infil = open_input(strcpy(filnamptr, arg)); infiln = infil0 = 1; + infil = open_input(strcpy(filnamptr, arg)); } } while (--argc != 1); @@ -278,7 +266,7 @@ char **argv; PRIVATE void summary(fd) int fd; { - innum = fd; + outfd = fd; writenl(); summ_number(toterr); writesn(" errors"); diff --git a/as/as.doc b/as/as.doc new file mode 100644 index 0000000..99273ef --- /dev/null +++ b/as/as.doc @@ -0,0 +1,169 @@ +as options +---------- + +as [-03agjuw] [-b [bin]] [-lm [list]] [-n name] [-o obj] [-s sym] src + +The 6809 version does not support -0, -3, -a or -j. + +The 'src' file can be '-' for stdin but ONLY on 'big' machines. + +defaults (off or none except for these; no output is produced without a flag): +-03 native +list stdout (beware of clobbering next arg) +name basename of the source name + +-0 start with 16-bit code segment +-3 start with 32-bit code segment +-a enable partial compatibility with asld +-g only put global symbols in object or symbol file +-j force all jumps to be long +-l produce list file, filename may follow +-m print macro expansions in listing +-n name of module follows (goes in object instead of source name) +-o produce object file, filename follows +-b produce a raw binary file, filename may follow +-s produce an ASCII symbol file, filename follows +-u take undefined symbols as imported-with-unspecified segment +-w don't print warnings + +The -u and -w options are perhaps back to front because they are needed for +cc1 output and Minix's make does the wrong thing with .s files left around. +However, all assembler code not written by compilers should assemble with +them turned off. + +The -b flag now produces a 'raw' binary file with no header, if there's no +-s flag the file starts at location 0. The -s generates an ASCII symbol +table, if a binary file doesn't start at location zero the first two items +are the start and end addresses of the binary file. + +BCC is classed as a 'small' compiler, with this there is a maximum line +length of 256 characters. + +Using GASP +---------- + +The Gnu assembler preprocessor provides some reasonable implementations +of user biased pseudo operations. + +It can be invoked as: + gasp [-a] ... file.s [file2.s ...] | as86 [...] - [-o obj] [-b bin] + +Notes: +Gasp generates an error for '.org' commands if you're not using +'alternate' syntax you can use 'org' instead, otherwise use 'block'. + +Export is translated in .global, if you are making a 'bin' file use +'public' or '.define' instead. + +The GASP list options have no support in as86. + +as source +--------- + +Conditionals: + IF, ELSE, ELSEIF, ENDIF Numeric condition + IFC, ELSEIFC String compare (str1,str2) + FAIL .FAIL Generate user error. + +Segments: + .TEXT .ROM .DATA .BSS + .SECT Follow with one of above + LOC Set numeric segment 0=TEXT, 3=DATA,ROM,BSS, 15=MAX + +Lable type definition: + Export label defined in this object: EXPORT PUBLIC .DEFINE + Force linker to include label in a.out: ENTRY + + Define label as external or imported: .GLOBL .GLOBAL + Import list of externally defined labels: EXTRN EXTERN IMPORT .EXTERN + NB: Can't use imports in 'bin' files. + + Mark entry for old binary file (obs) .ENTER + +Data init + 1 byte: DB .DATA1 .BYTE FCB + 2 byte: DW .DATA2 .SHORT FDB .WORD + 4 byte: DD .DATA4 .LONG + String: .ASCII FCC + String+Zero: .ASCIZ + +Data uninit + byte count: .BLKB RMB .SPACE + word count: .BLKW .ZEROW + +Data Common + COMM .COMM LCOMM .LCOMM + +Alignment + .ALIGN .EVEN + +Misc + EQU Define label + SET Define re-definable label + ORG .ORG Set assemble location + BLOCK Set assemble location and stack old one + ENDB Return to stacked assemble location + GET INCLUDE Insert new file (no quotes on name) + USE16 Define default operand size as 16 bit + USE32 Define default operand size as 32 bit + END End of compilation for this file. + .WARN Switch warnings + .LIST Listings on/off (1,-1) + .MACLIST Macro listings on/off (1,-1) + +Macros + MACRO sax + mov ax,#?1 + MEND + sax(1) + +Unimplemented/unused. + IDENT Define object identity string. + SETDP Set DP value on 6809 + .MAP Set binary symbol table map number. + +Registers + BP BX DI SI + EAX EBP EBX ECX EDI EDX ESI ESP + AX CX DX SP + AH AL BH BL CH CL DH DL + CS DS ES FS GS SS + CR0 CR2 CR3 DR0 DR1 DR2 DR3 DR6 DR7 + TR3 TR4 TR5 TR6 TR7 ST + +Operand type specifiers + BYTE DWORD FWORD FAR PTR PWORD QWORD TBYTE WORD NEAR + + +Instructions + +AAA AAD AAM AAS ADC ADD AND ARPL BCC BCS BEQ BGE BGT BHI BHIS BLE BLO +BLOS BLT BMI BNE BOUND BPC BPL BPS BR BVC BVS CALL CALLF CALLI CBW CLC +CLD CLI CMC CMP CMPS CMPSB CMPSD CMPSW CMPW CSEG CWD CWDE CDQ DAA DAS +DSEG DEC DIV ENTER ESEG FSEG GSEG HLT IDIV IMUL IN INC INS INSB INSD +INSW INT INTO INW IRET IRETD J JA JAE JB JBE JC JCXE JCXZ JECXE JECXZ JE +JG JGE JL JLE JMP JMPF JMPI JNA JNAE JNB JNBE JNC JNE JNG JNGE JNL JNLE +JNO JNP JNS JNZ JO JP JPE JPO JS JZ LAHF LDS LEA LEAVE LES LOCK LODB +LODS LODSB LODSD LODSW LODW LOOP LOOPE LOOPNE LOOPNZ LOOPZ MOV MOVS +MOVSB MOVSD MOVSW MOVW MUL NEG NOP NOT OR OUT OUTS OUTSB OUTSD OUTSW +OUTW POP POPA POPAD POPF POPFD PUSH PUSHA PUSHAD PUSHF PUSHFD RCL RCR +ROL ROR REP REPE REPNE REPNZ REPZ RET RETF RETI SAHF SAL SAR SBB SCAB +SCAS SCASB SCASD SCASW SCAW SEG SHL SHR SSEG STC STD STI STOB STOS STOSB +STOSD STOSW STOW SUB TEST WAIT XCHG XLAT XLATB XOR + +F2XM1 FABS FADD FADDP FBLD FBSTP FCHS FCLEX FCOM FCOMP FCOMPP FCOS +FDECSTP FDISI FDIV FDIVP FDIVR FDIVRP FENI FFREE FIADD FICOM FICOMP +FIDIV FIDIVR FILD FIMUL FINCSTP FINIT FIST FISTP FISUB FISUBR FLD FLD1 +FLDL2E FLDL2T FLDCW FLDENV FLDLG2 FLDLN2 FLDPI FLDZ FMUL FMULP FNCLEX +FNDISI FNENI FNINIT FNOP FNSAVE FNSTCW FNSTENV FNSTSW FPATAN FPREM +FPREM1 FPTAN FRNDINT FRSTOR FSAVE FSCALE FSETPM FSIN FSINCOS FSQRT FST +FSTCW FSTENV FSTP FSTSW FSUB FSUBP FSUBR FSUBRP FTST FUCOM FUCOMP +FUCOMPP FWAIT FXAM FXCH FXTRACT FYL2X FYL2XP1 + +BSF BSR BSWAP BT BTC BTR BTS CLTS CMPXCHG INVD INVLPG LAR LFS LGDT LGS +LIDT LLDT LMSW LSL LSS LTR MOVSX MOVZX SETA SETAE SETB SETBE SETC SETE +SETG SETGE SETL SETLE SETNA SETNAE SETNB SETNBE SETNC SETNE SETNG SETNGE +SETNL SETNLE SETNO SETNP SETNS SETNZ SETO SETP SETPE SETPO SETS SETZ +SGDT SIDT SHLD SHRD SLDT SMSW STR VERR VERW WBINVD XADD ADCB ADDB ANDB +CMPB DECB DIVB IDIVB IMULB INB INCB MOVB MULB NEGB NOTB ORB OUTB RCLB +RCRB ROLB RORB SALB SARB SHLB SHRB SBBB SUBB TESTB XCHGB XORB diff --git a/as/as86_encap b/as/as86_encap new file mode 100755 index 0000000..45db468 --- /dev/null +++ b/as/as86_encap @@ -0,0 +1,40 @@ +#!/usr/bin/awk -f +BEGIN{ + started = 0; + prefix=ARGV[1] "_"; + if( 2 in ARGV ) prefix=ARGV[2]; + + sname = prefix "start"; + cmd = ARGV[1] ".sym"; + while(getline < cmd) + { + if(NF == 0) break; + if( substr($2,1,4) == "0000" ) $2=substr($2,5); + if( $1 == "+" && $4 == "$start" ) + { + printf "int %s = 0x%s;\n", sname, $2; + started = 1; + } + else if( substr($3, 1, 1) == "E" && $4 != "start" && $4 != "size" && $4 != "data" ) + { + printf "int %s%s = 0x%s;\n", prefix, $4, $2; + } + } + + if( !started ) + printf "int %s = 0;\n", sname; + + printf "\n"; + printf "char %sdata[] = {\n", prefix; + cmd = "od " ARGV[1] ".bin -v -t uC"; + bincount=0; + while(cmd | getline) + { + if(NF == 0) break; + printf " "; + for(i=2;i<=NF;i++) { printf("%3d,", $i); bincount++; } + printf "\n"; + } + printf "};\n\n"; + printf "int %ssize = %d;\n", prefix, bincount; +} diff --git a/as/assemble.c b/as/assemble.c index 1fdef1a..1992068 100644 --- a/as/assemble.c +++ b/as/assemble.c @@ -1,5 +1,6 @@ /* assemble.c - main loop for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" #include "address.h" @@ -1,9 +1,19 @@ + +compile() +{ + # /lib/elksemu ./as86 -3 "$@" + ./as86 -3 "$@" +} + for i in `ls asm/*.asm` do j=`basename $i .asm` - as86 asm/$j.asm -b $j.bin -o $j.obj > /dev/null - cmp $j.bin bin/$j.bin + compile asm/$j.asm -b $j.bin -o $j.obj > /dev/null cmp $j.obj obj1/$j.obj - rm $j.bin $j.obj + + # compile asm/$j.asm -b $j.bin > /dev/null + # cmp $j.bin bin/$j.bin + + rm -f $j.bin $j.obj $j.asm done @@ -1,5 +1,21 @@ -#define align(x) /* ((x) = ((int) (x) + (4-1)) & ~(4-1)) */ + +/* Speed and space hacks for BCC */ +#ifdef __AS386_16__ #define LOW_BYTE 0 /* must be changed for big-endian */ +#define align(x) /* Don't bother */ + +#endif + +#ifndef align +#ifdef MSDOS +#define align(x) +#endif +#endif + +#ifndef align /* Normal ... */ +#define align(x) ((x) = (void*)(((long) (x) + (4-1)) & ~(4-1))) +#endif + /* const.h - constants for assembler */ @@ -26,6 +42,12 @@ # define STAKSIZ 256 /* table grows up to stack less this */ #endif +#ifdef __AS386_16__ +# undef INBUFSIZE +# define INBUFSIZE 512 +# define STAKSIZ 256 /* table grows up to stack less this */ +#endif + /* booleans */ #define FALSE 0 @@ -1,14 +1,9 @@ /* error.c - error routines for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" -#ifdef STDC_HEADERS_MISSING -char *strcpy P((char *s1, const char *s2)); -#else -#include <string.h> -#endif - PRIVATE char *errormessage[] = { "comma expected", diff --git a/as/express.c b/as/express.c index 54dff2f..70f5081 100644 --- a/as/express.c +++ b/as/express.c @@ -1,5 +1,6 @@ /* express.c - expression handler for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" #include "address.h" @@ -1,12 +1,17 @@ /* file.h - global variables involving files for assembler */ -EXTERN fd_t binfil; /* binary output file (0 = memory) */ EXTERN char *filnamptr; /* file name pointer */ -EXTERN fd_t infil0; /* initial input file */ +EXTERN char *truefilename; /* in case actual source name is a tmpname */ + EXTERN fd_t infil; /* current input file (stacked, 0 = memory) */ -EXTERN unsigned char infiln; /* innum when file was opened */ -EXTERN unsigned char innum; /* counter for calls to open */ + +/* Output fds */ +EXTERN unsigned char outfd; /* output fd for writer fns */ +EXTERN fd_t binfil; /* binary output file (0 = memory) */ EXTERN fd_t lstfil; /* list output file (0 = standard) */ EXTERN fd_t objfil; /* object output file */ EXTERN fd_t symfil; /* symbol table output file */ -EXTERN char *truefilename; /* in case actual source name is a tmpname */ + +/* readsrc internals */ +EXTERN unsigned infil0; /* Number of first input area */ +EXTERN unsigned infiln; /* Number of current input area */ diff --git a/as/genbin.c b/as/genbin.c index ce16405..a36e6a2 100644 --- a/as/genbin.c +++ b/as/genbin.c @@ -1,5 +1,6 @@ /* genbin.c - binary code generation routines for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" #include "address.h" @@ -19,7 +20,8 @@ FORWARD void putbinoffset P((offset_t offset, count_t size)); PUBLIC void binheader() { - if ((innum = binfil) != 0x0) +#ifdef BINSYM + if ((outfd = binfil) != 0x0 && binmbuf_set && binmax >= binmin) { writec(0x0); /* binary header byte */ #ifdef LONG_BINHEADER @@ -30,13 +32,31 @@ PUBLIC void binheader() writew((unsigned) (binfbuf = binmin)); /* program start */ #endif } +#else + if ( ( outfd = symfil ) && binmbuf_set && binmax >= binmin) + { + int sft; + writec('+'); writec(' '); + for(sft=SIZEOF_OFFSET_T*8-4; sft >= 0; sft-=4) + writec(hexdigit[(binmin>>sft) & 0xF]); + writesn(" ----- $start"); + + writec('+'); writec(' '); + for(sft=SIZEOF_OFFSET_T*8-4; sft >= 0; sft-=4) + writec(hexdigit[(binmax>>sft) & 0xF]); + writesn(" ----- $end"); + + binfbuf = binmin; /* program start */ + } +#endif } /* write trailer to binary file */ PUBLIC void bintrailer() { - if ((innum = binfil) != 0x0) +#ifdef BINSYM + if ((outfd = binfil) != 0x0 && (pedata & UNDBIT) != UNDBIT && binmbuf_set) { writec(0xFF); /* binary trailer byte */ writew(0x0); /* further trailer bytes */ @@ -46,6 +66,7 @@ PUBLIC void bintrailer() writew(pedata & UNDBIT ? (unsigned) binmin : (unsigned) progent); #endif } +#endif } /* generate binary code for current line */ @@ -168,16 +189,26 @@ opcode_pt ch; } else { +#if 0 if (binfbuf > binmbuf) + { error(BWRAP); /* file buffer ahead of memory buffer */ + } else +#endif { - innum = binfil; + outfd = binfil; + if( binfbuf != binmbuf) + if( lseek(binfil, (long)(binmbuf-binfbuf), 1) < 0 ) + error(BWRAP); + binfbuf = binmbuf; +#if 0 while (binfbuf < binmbuf) { writec(0x0);/* pad with nulls if file buffer behind */ ++binfbuf; } +#endif writec(ch); binmbuf = ++binfbuf; } diff --git a/as/genlist.c b/as/genlist.c index eb3b277..37d2caf 100644 --- a/as/genlist.c +++ b/as/genlist.c @@ -1,5 +1,6 @@ /* genlist.c - generate listing and error reports for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" #include "address.h" @@ -10,20 +11,6 @@ #include "scan.h" #include "source.h" -#ifdef STDC_HEADERS_MISSING -void *memset P((void *s, int c, unsigned n)); -unsigned strlen P((const char *s)); -#else -#include <string.h> -#endif - -#ifdef POSIX_HEADERS_MISSING -int write P((int fd, const void *buf, unsigned nbytes)); -#else -#include <sys/types.h> -#include <unistd.h> -#endif - #define CODE_LIST_LENGTH (sizeof (struct code_listing_s) - 1) /* length of formatted code listing */ #define MAXERR 6 /* maximum errors listed per line */ @@ -202,9 +189,9 @@ PUBLIC void listline() PRIVATE void list1(fd) fd_t fd; { - innum = fd; + outfd = fd; listcode(); - write(innum, linebuf, (unsigned) (lineptr - linebuf)); + write(outfd, linebuf, (unsigned) (lineptr - linebuf)); writenl(); if (errcount != 0) listerrors(); @@ -349,7 +336,11 @@ PRIVATE void listerrors() char *linep; unsigned char remaining; +#ifdef I80386 + paderrorline(1); +#else paderrorline(CODE_LIST_LENGTH - LINUM_LEN); +#endif remaining = errcount; column = 0; /* column to match with error column */ errcolw = errcol = CODE_LIST_LENGTH; /* working & col number on err line */ @@ -357,6 +348,21 @@ PRIVATE void listerrors() linep = linebuf; do { +#ifdef I80386 + if(column) + { + writenl(); paderrorline(1); + } + writes(errmsg = build_error_message(errptr->errnum, heapptr)); + errcol = strlen(errmsg)+LINUM_LEN+1; + column = 0; linep = linebuf; + errcolw = CODE_LIST_LENGTH; + while (errcolw > errcol) + { + writec('.'); + ++errcol; + } +#endif while (column < errptr->position) { ++column; @@ -366,10 +372,17 @@ PRIVATE void listerrors() ++errcolw; while (errcolw > errcol) { +#ifdef I80386 + writec('.'); +#else writec(' '); +#endif ++errcol; } } +#ifdef I80386 + writec('^'); +#else if (errcolw < errcol) /* position under error on new line */ { writenl(); @@ -378,13 +391,18 @@ PRIVATE void listerrors() writec('^'); writes(errmsg = build_error_message(errptr->errnum, heapptr)); errcol += strlen(errmsg); +#endif ++errptr; } while (--remaining != 0); writenl(); if (erroverflow) { +#ifdef I80386 + paderrorline(1); +#else paderrorline(CODE_LIST_LENGTH - LINUM_LEN); +#endif writesn(build_error_message(FURTHER, heapptr)); } } @@ -407,7 +425,7 @@ unsigned nspaces; PUBLIC void writec(ch) char ch; { - write(innum, &ch, 1); + write(outfd, &ch, 1); } /* write newline */ @@ -429,7 +447,7 @@ offset_t offset; #else u2c2(buf, offset); #endif - write(innum, buf, sizeof buf); + write(outfd, buf, sizeof buf); } /* write string */ @@ -437,7 +455,7 @@ offset_t offset; PUBLIC void writes(s) char *s; { - write(innum, s, strlen(s)); + write(outfd, s, strlen(s)); } /* write string followed by newline */ @@ -457,5 +475,5 @@ unsigned word; char buf[2]; u2c2(buf, (u16_T) word); - write(innum, buf, sizeof buf); + write(outfd, buf, sizeof buf); } diff --git a/as/genobj.c b/as/genobj.c index 2992232..8080265 100644 --- a/as/genobj.c +++ b/as/genobj.c @@ -1,26 +1,12 @@ /* genobj.c - object code generation routines for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" #include "address.h" #include "file.h" #include "globvar.h" -#ifdef STDC_HEADERS_MISSING -char *strcpy P((char *s1, const char *s2)); -char *strrchr P((const char *s, int c)); -unsigned strlen P((const char *s)); -#else -#include <string.h> -#endif - -#ifdef POSIX_HEADERS_MISSING -int write P((int fd, const void *buf, unsigned nbytes)); -#else -#include <sys/types.h> -#include <unistd.h> -#endif - #define OBJBUFSIZE 512 /* size of object code output buffer */ #define isge2byteoffset(offset) ((offset) >= 0x100) #define isge4byteoffset(offset) ((offset) >= 0x10000L) diff --git a/as/gensym.c b/as/gensym.c index c5c6d1b..db9dec4 100644 --- a/as/gensym.c +++ b/as/gensym.c @@ -1,25 +1,12 @@ /* gensym.c - generate symbol table for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" #include "flag.h" #include "file.h" #include "globvar.h" -#ifdef STDC_HEADERS_MISSING -void *memset P((void *s, int c, unsigned n)); -int strcmp P((const char *s1, const char *s2)); -#else -#include <string.h> -#endif - -#ifdef POSIX_HEADERS_MISSING -int write P((int fd, const void *buf, unsigned nbytes)); -#else -#include <sys/types.h> -#include <unistd.h> -#endif - FORWARD int printsym P((register struct sym_s *symptr, unsigned column)); FORWARD void sort P((struct sym_s **array, struct sym_s **top, bool_pt nameflag)); @@ -37,9 +24,11 @@ PUBLIC void gensym() register struct sym_s **hashptr; unsigned label_count; /* number of labels */ unsigned labels_length; /* length of all label strings */ - unsigned label_stringptr; /* offset of label str from start of file */ - register struct sym_s *symptr; struct sym_s **symlptr; /* start of symbol output list */ + register struct sym_s *symptr; +#ifdef BINSYM + unsigned label_stringptr; /* offset of label str from start of file */ +#endif labels_length = label_count = 0; @@ -71,7 +60,7 @@ sort_symbols: heapptr = (char *) (copytop = copyptr); if (list.global) { - innum = lstfil; + outfd = lstfil; writenl(); writesn("Symbols:"); for (copyptr = symlptr, column = 0; copyptr < copytop;) @@ -79,8 +68,37 @@ sort_symbols: if (column != 0) writenl(); } - if ((innum = symfil) != 0) + if ((outfd = symfil) != 0) { +#ifndef BINSYM + for (copyptr = symlptr; copyptr < copytop;) + /* for (copyptr = spt; copyptr < spt_top;) */ + { + int sft; + if((symptr = *copyptr++) == NUL_PTR ) continue; + if( globals_only_in_obj && + !(symptr->type & EXPBIT)) continue; + + writec(hexdigit[symptr->data & SEGM]); + writec(' '); + + for(sft=SIZEOF_OFFSET_T*8-4; sft >= 0; sft-=4) + writec(hexdigit[(symptr->value_reg_or_op.value>>sft) & 0xF]); + + writec(' '); + writec(symptr->type & EXPBIT ? 'E' : '-'); + writec(symptr->type & ENTBIT ? 'N' : '-'); + writec(symptr->data & IMPBIT ? 'I' : '-'); + writec(symptr->data & RELBIT ? 'R' : 'A'); + writec(symptr->type & COMMBIT ? 'C' : '-'); + + writec(' '); + write(outfd, symptr->name, (unsigned) (symptr->length)); + + /* printsym(*copyptr++, 0); */ + writenl(); + } +#else writew(mapnum); label_count *= 2; /* now length of ptr table (2 bytes per ptr) */ label_stringptr = label_count + 6; @@ -104,7 +122,7 @@ sort_symbols: symptr = *copyptr++; writew((unsigned) symptr->value_reg_or_op.value); writec(symptr->type); - write(innum, symptr->name, (unsigned) (symptr->length - 1)); + write(outfd, symptr->name, (unsigned) (symptr->length - 1)); writec(symptr->name[symptr->length - 1] | 0x80); } sort(symlptr, copyptr, FALSE); @@ -114,6 +132,7 @@ sort_symbols: symptr = *copyptr++; writew((unsigned) symptr->next); /* now has string position */ } +#endif } } @@ -137,7 +156,7 @@ unsigned column; outname[length = SYMLIS_NAMELEN] = '+'; } else - outname = (listptr->name + SYMLIS_NAMELEN) - length; + outname = listptr->name; /*(listptr->name + SYMLIS_NAMELEN) - length;*/ symname = symptr->name; do *outname++ = *symname++; diff --git a/as/globvar.h b/as/globvar.h index f2896fb..e44d88d 100644 --- a/as/globvar.h +++ b/as/globvar.h @@ -5,6 +5,7 @@ EXTERN bool_t binaryc; /* current binary code flag */ EXTERN bool_t binaryg; /* global binary code flag */ EXTERN offset_t binmbuf; /* offset in binary code buffer for memory */ +EXTERN bool_t binmbuf_set; /* set to 1 when binmbuf set by org */ EXTERN unsigned char dirpag; /* direct page */ @@ -61,9 +62,13 @@ EXTERN offset_t lc; /* location counter */ EXTERN unsigned char lcdata; /* shows how lc is bound */ /* FORBIT is set if lc is forward referenced */ /* RELBIT is is if lc is relocat. (not ASEG) */ -EXTERN offset_t lcjump; /* lc jump between lines */ +EXTERN offset_t lcjump; /* lc jump between lines */ +#ifdef LOW_BYTE #define mcount (((unsigned char *) &lcjump)[LOW_BYTE]) /* low byte of lcjump */ +#else +#define mcount lcjump /* I think this is just a speed hack */ +#endif EXTERN struct lc_s *lcptr; /* top of current spot in lctab */ EXTERN struct lc_s *lctab; /* start of lctab */ EXTERN struct lc_s *lctabtop; /* top of lctab */ diff --git a/as/keywords.c b/as/keywords.c new file mode 100644 index 0000000..b3c1615 --- /dev/null +++ b/as/keywords.c @@ -0,0 +1,736 @@ +/* keywords.c - keyword tables for assembler */ + +#include "syshead.h" +#include "const.h" +#include "type.h" +#include "globvar.h" +#include "opcode.h" + +/* --- start of keywords --- */ + +/* registers */ +/* the register code (internal to assembler) is given in 1 byte */ +/* the "opcode" field is not used */ + +PUBLIC char regs[] = +{ +#ifdef I80386 + 2, 'B', 'P', BPREG, 0, + 2, 'B', 'X', BXREG, 0, + 2, 'D', 'I', DIREG, 0, + 2, 'S', 'I', SIREG, 0, + + 3, 'E', 'A', 'X', EAXREG, 0, + 3, 'E', 'B', 'P', EBPREG, 0, + 3, 'E', 'B', 'X', EBXREG, 0, + 3, 'E', 'C', 'X', ECXREG, 0, + 3, 'E', 'D', 'I', EDIREG, 0, + 3, 'E', 'D', 'X', EDXREG, 0, + 3, 'E', 'S', 'I', ESIREG, 0, + 3, 'E', 'S', 'P', ESPREG, 0, + + 2, 'A', 'X', AXREG, 0, + 2, 'C', 'X', CXREG, 0, + 2, 'D', 'X', DXREG, 0, + 2, 'S', 'P', SPREG, 0, + + 2, 'A', 'H', AHREG, 0, + 2, 'A', 'L', ALREG, 0, + 2, 'B', 'H', BHREG, 0, + 2, 'B', 'L', BLREG, 0, + 2, 'C', 'H', CHREG, 0, + 2, 'C', 'L', CLREG, 0, + 2, 'D', 'H', DHREG, 0, + 2, 'D', 'L', DLREG, 0, + + 2, 'C', 'S', CSREG, 0, + 2, 'D', 'S', DSREG, 0, + 2, 'E', 'S', ESREG, 0, + 2, 'F', 'S', FSREG, 0, + 2, 'G', 'S', GSREG, 0, + 2, 'S', 'S', SSREG, 0, + + 3, 'C', 'R', '0', CR0REG, 0, + 3, 'C', 'R', '2', CR2REG, 0, + 3, 'C', 'R', '3', CR3REG, 0, + 3, 'D', 'R', '0', DR0REG, 0, + 3, 'D', 'R', '1', DR1REG, 0, + 3, 'D', 'R', '2', DR2REG, 0, + 3, 'D', 'R', '3', DR3REG, 0, + 3, 'D', 'R', '6', DR6REG, 0, + 3, 'D', 'R', '7', DR7REG, 0, + 3, 'T', 'R', '3', TR3REG, 0, + 3, 'T', 'R', '4', TR4REG, 0, + 3, 'T', 'R', '5', TR5REG, 0, + 3, 'T', 'R', '6', TR6REG, 0, + 3, 'T', 'R', '7', TR7REG, 0, + + 2, 'S', 'T', ST0REG, 0, +#endif /* I80386 */ + +#ifdef MC6809 + 1, 'A', AREG, 0, + 1, 'B', BREG, 0, + 2, 'C', 'C', CCREG, 0, + 1, 'D', DREG, 0, + 2, 'D', 'P', DPREG, 0, + 2, 'P', 'C', PCREG, 0, + 3, 'P', 'C', 'R', PCREG, 0, + 1, 'S', SREG, 0, + 1, 'U', UREG, 0, + 1, 'X', XREG, 0, + 1, 'Y', YREG, 0, +#endif + 0 /* end of register list */ +}; + +#ifdef I80386 + +/* type sizes */ +/* the "opcode" field gives the type size */ + +PUBLIC char typesizes[] = +{ + 4, 'B', 'Y', 'T', 'E', BYTEOP, 1, + 5, 'D', 'W', 'O', 'R', 'D', DWORDOP, 4, + 5, 'F', 'W', 'O', 'R', 'D', FWORDOP, 6, + 3, 'F', 'A', 'R', FAROP, 0, + 4, 'N', 'E', 'A', 'R', WORDOP, 2, + 3, 'P', 'T', 'R', PTROP, 0, + 5, 'P', 'W', 'O', 'R', 'D', PWORDOP, 6, + 5, 'Q', 'W', 'O', 'R', 'D', QWORDOP, 8, + 5, 'T', 'B', 'Y', 'T', 'E', TBYTEOP, 10, + 4, 'W', 'O', 'R', 'D', WORDOP, 2, + 0 /* end of typesize list */ +}; + +#endif + +/* ops */ +/* the routine number is given in 1 byte */ +/* the opcode is given in 1 byte (it is not used for pseudo-ops) */ + +PUBLIC char ops[] = +{ + /* pseudo-ops. The "opcode" field is unused and padded with a null byte */ + /* conditionals - must be first */ + 4, 'E', 'L', 'S', 'E', ELSEOP, 0, + 6, 'E', 'L', 'S', 'E', 'I', 'F', ELSEIFOP, 0, + 7, 'E', 'L', 'S', 'E', 'I', 'F', 'C', ELSEIFCOP, 0, + 5, 'E', 'N', 'D', 'I', 'F', ENDIFOP, 0, + 2, 'I', 'F', IFOP, 0, + 3, 'I', 'F', 'C', IFCOP, 0, + + /* unconditionals */ + 6, '.', 'A', 'L', 'I', 'G', 'N', ALIGNOP, 0, + 6, '.', 'A', 'S', 'C', 'I', 'I', FCCOP, 0, + 6, '.', 'A', 'S', 'C', 'I', 'Z', ASCIZOP, 0, + 5, '.', 'B', 'L', 'K', 'B', RMBOP, 0, + 5, '.', 'B', 'L', 'K', 'W', BLKWOP, 0, + 5, 'B', 'L', 'O', 'C', 'K', BLOCKOP, 0, + 4, '.', 'B', 'S', 'S', BSSOP, 0, + 5, '.', 'B', 'Y', 'T', 'E', FCBOP, 0, + 4, 'C', 'O', 'M', 'M', COMMOP, 0, + 5, '.', 'C', 'O', 'M', 'M', COMMOP1, 0, + 5, '.', 'D', 'A', 'T', 'A', DATAOP, 0, + 6, '.', 'D', 'A', 'T', 'A', '1', FCBOP, 0, + 6, '.', 'D', 'A', 'T', 'A', '2', FDBOP, 0, + 6, '.', 'D', 'A', 'T', 'A', '4', FQBOP, 0, + 2, 'D', 'B', FCBOP, 0, + 2, 'D', 'D', FQBOP, 0, + 7, '.', 'D', 'E', 'F', 'I', 'N', 'E', EXPORTOP, 0, + 2, 'D', 'W', FDBOP, 0, + 3, 'E', 'N', 'D', PROCEOFOP, 0, + 4, 'E', 'N', 'D', 'B', ENDBOP, 0, + 6, '.', 'E', 'N', 'T', 'E', 'R', ENTEROP, 0, + 5, 'E', 'N', 'T', 'R', 'Y', ENTRYOP, 0, + 3, 'E', 'Q', 'U', EQUOP, 0, + 5, '.', 'E', 'V', 'E', 'N', EVENOP, 0, + 6, 'E', 'X', 'P', 'O', 'R', 'T', EXPORTOP, 0, + 6, 'E', 'X', 'T', 'E', 'R', 'N', IMPORTOP, 0, + 7, '.', 'E', 'X', 'T', 'E', 'R', 'N', IMPORTOP, 0, + 5, 'E', 'X', 'T', 'R', 'N', IMPORTOP, 0, + 4, 'F', 'A', 'I', 'L', FAILOP, 0, + 5, '.', 'F', 'A', 'I', 'L', FAILOP, 0, + 3, 'F', 'C', 'B', FCBOP, 0, + 3, 'F', 'C', 'C', FCCOP, 0, + 3, 'F', 'D', 'B', FDBOP, 0, + 3, 'G', 'E', 'T', GETOP, 0, + 7, '.', 'G', 'L', 'O', 'B', 'A', 'L', GLOBLOP, 0, + 6, '.', 'G', 'L', 'O', 'B', 'L', GLOBLOP, 0, + 5, 'I', 'D', 'E', 'N', 'T', IDENTOP, 0, + 6, 'I', 'M', 'P', 'O', 'R', 'T', IMPORTOP, 0, + 7, 'I', 'N', 'C', 'L', 'U', 'D', 'E', GETOP, 0, + 5, 'L', 'C', 'O', 'M', 'M', LCOMMOP, 0, + 6, '.', 'L', 'C', 'O', 'M', 'M', LCOMMOP1, 0, + 5, '.', 'L', 'I', 'S', 'T', LISTOP, 0, + 3, 'L', 'O', 'C', LOCOP, 0, + 5, '.', 'L', 'O', 'N', 'G', FQBOP, 0, + 8, '.', 'M', 'A', 'C', 'L', 'I', 'S', 'T', MACLISTOP, 0, + 5, 'M', 'A', 'C', 'R', 'O', MACROOP, 0, + 4, '.', 'M', 'A', 'P', MAPOP, 0, + 3, 'O', 'R', 'G', ORGOP, 0, + 4, '.', 'O', 'R', 'G', ORGOP, 0, + 6, 'P', 'U', 'B', 'L', 'I', 'C', EXPORTOP, 0, + 3, 'R', 'M', 'B', RMBOP, 0, + 4, '.', 'R', 'O', 'M', DATAOP, 0, + 5, '.', 'S', 'E', 'C', 'T', SECTOP, 0, + 3, 'S', 'E', 'T', SETOP, 0, + 5, 'S', 'E', 'T', 'D', 'P', SETDPOP, 0, + 6, '.', 'S', 'H', 'O', 'R', 'T', FDBOP, 0, + 6, '.', 'S', 'P', 'A', 'C', 'E', RMBOP, 0, + 5, '.', 'T', 'E', 'X', 'T', TEXTOP, 0, + 5, 'U', 'S', 'E', '1', '6', USE16OP, 0, + 5, 'U', 'S', 'E', '3', '2', USE32OP, 0, + 5, '.', 'W', 'A', 'R', 'N', WARNOP, 0, + 5, '.', 'W', 'O', 'R', 'D', FDBOP, 0, + 6, '.', 'Z', 'E', 'R', 'O', 'W', BLKWOP, 0, + + /* hardware ops. The opcode field is now used */ +#ifdef I80386 + 3, 'A', 'A', 'A', INHER, 0x37, + 3, 'A', 'A', 'D', INHER_A, 0xD5, + 3, 'A', 'A', 'M', INHER_A, 0xD4, + 3, 'A', 'A', 'S', INHER, 0x3F, + 3, 'A', 'D', 'C', GROUP1, 0x10, + 3, 'A', 'D', 'D', GROUP1, 0x00, + 3, 'A', 'N', 'D', GROUP1, 0x20, + 4, 'A', 'R', 'P', 'L', EwGw, 0x63, + 3, 'B', 'C', 'C', BCC, 0x73, + 3, 'B', 'C', 'S', BCC, 0x72, + 3, 'B', 'E', 'Q', BCC, 0x74, + 3, 'B', 'G', 'E', BCC, 0x7D, + 3, 'B', 'G', 'T', BCC, 0x7F, + 3, 'B', 'H', 'I', BCC, 0x77, + 4, 'B', 'H', 'I', 'S', BCC, 0x73, + 3, 'B', 'L', 'E', BCC, 0x7E, + 3, 'B', 'L', 'O', BCC, 0x72, + 4, 'B', 'L', 'O', 'S', BCC, 0x76, + 3, 'B', 'L', 'T', BCC, 0x7C, + 3, 'B', 'M', 'I', BCC, 0x78, + 3, 'B', 'N', 'E', BCC, 0x75, + 5, 'B', 'O', 'U', 'N', 'D', GvMa, 0x62, + 3, 'B', 'P', 'C', BCC, 0x7B, + 3, 'B', 'P', 'L', BCC, 0x79, + 3, 'B', 'P', 'S', BCC, 0x7A, + 2, 'B', 'R', CALL, JMP_OPCODE, + 3, 'B', 'V', 'C', BCC, 0x71, + 3, 'B', 'V', 'S', BCC, 0x70, + 4, 'C', 'A', 'L', 'L', CALL, JSR_OPCODE, + 5, 'C', 'A', 'L', 'L', 'F', CALLI, 0x9A, + 5, 'C', 'A', 'L', 'L', 'I', CALLI, 0x9A, + 3, 'C', 'B', 'W', INHER16, 0x98, + 3, 'C', 'L', 'C', INHER, 0xF8, + 3, 'C', 'L', 'D', INHER, 0xFC, + 3, 'C', 'L', 'I', INHER, 0xFA, + 3, 'C', 'M', 'C', INHER, 0xF5, + 3, 'C', 'M', 'P', GROUP1, CMP_OPCODE_BASE, + 4, 'C', 'M', 'P', 'S', INHER, CMPSW_OPCODE, + 5, 'C', 'M', 'P', 'S', 'B', INHER, CMPSB_OPCODE, + 5, 'C', 'M', 'P', 'S', 'D', INHER32, CMPSW_OPCODE, + 5, 'C', 'M', 'P', 'S', 'W', INHER16, CMPSW_OPCODE, + 4, 'C', 'M', 'P', 'W', INHER16, CMPSW_OPCODE, + 4, 'C', 'S', 'E', 'G', INHER, 0x2E, + 3, 'C', 'W', 'D', INHER16, 0x99, + 4, 'C', 'W', 'D', 'E', INHER32, 0x98, + 3, 'C', 'D', 'Q', INHER32, 0x99, + 3, 'D', 'A', 'A', INHER, 0x27, + 3, 'D', 'A', 'S', INHER, 0x2F, + 4, 'D', 'S', 'E', 'G', INHER, 0x3E, + 3, 'D', 'E', 'C', INCDEC, 0x08, + 3, 'D', 'I', 'V', DIVMUL, 0x30, + 5, 'E', 'N', 'T', 'E', 'R', ENTER, 0xC8, + 4, 'E', 'S', 'E', 'G', INHER, 0x26, + 4, 'F', 'S', 'E', 'G', INHER, 0x64, + 4, 'G', 'S', 'E', 'G', INHER, 0x65, + 3, 'H', 'L', 'T', INHER, 0xF4, + 4, 'I', 'D', 'I', 'V', DIVMUL, 0x38, + 4, 'I', 'M', 'U', 'L', IMUL, 0x28, + 2, 'I', 'N', IN, 0xEC, + 3, 'I', 'N', 'C', INCDEC, 0x00, + 3, 'I', 'N', 'S', INHER, 0x6D, + 4, 'I', 'N', 'S', 'B', INHER, 0x6C, + 4, 'I', 'N', 'S', 'D', INHER32, 0x6D, + 4, 'I', 'N', 'S', 'W', INHER16, 0x6D, + 3, 'I', 'N', 'T', INT, 0xCD, + 4, 'I', 'N', 'T', 'O', INHER, 0xCE, + 3, 'I', 'N', 'W', IN, 0xED, + 4, 'I', 'R', 'E', 'T', INHER16, 0xCF, + 5, 'I', 'R', 'E', 'T', 'D', INHER32, 0xCF, + 1, 'J', CALL, JMP_SHORT_OPCODE, + 2, 'J', 'A', JCC, 0x77, + 3, 'J', 'A', 'E', JCC, 0x73, + 2, 'J', 'B', JCC, 0x72, + 3, 'J', 'B', 'E', JCC, 0x76, + 2, 'J', 'C', JCC, 0x72, + 4, 'J', 'C', 'X', 'E', JCXZ, 0x2, + 4, 'J', 'C', 'X', 'Z', JCXZ, 0x2, + 5, 'J', 'E', 'C', 'X', 'E', JCXZ, 0x4, + 5, 'J', 'E', 'C', 'X', 'Z', JCXZ, 0x4, + 2, 'J', 'E', JCC, 0x74, + 2, 'J', 'G', JCC, 0x7F, + 3, 'J', 'G', 'E', JCC, 0x7D, + 2, 'J', 'L', JCC, 0x7C, + 3, 'J', 'L', 'E', JCC, 0x7E, + 3, 'J', 'M', 'P', CALL, JMP_SHORT_OPCODE, + 4, 'J', 'M', 'P', 'F', CALLI, 0xEA, + 4, 'J', 'M', 'P', 'I', CALLI, 0xEA, + 3, 'J', 'N', 'A', JCC, 0x76, + 4, 'J', 'N', 'A', 'E', JCC, 0x72, + 3, 'J', 'N', 'B', JCC, 0x73, + 4, 'J', 'N', 'B', 'E', JCC, 0x77, + 3, 'J', 'N', 'C', JCC, 0x73, + 3, 'J', 'N', 'E', JCC, 0x75, + 3, 'J', 'N', 'G', JCC, 0x7E, + 4, 'J', 'N', 'G', 'E', JCC, 0x7C, + 3, 'J', 'N', 'L', JCC, 0x7D, + 4, 'J', 'N', 'L', 'E', JCC, 0x7F, + 3, 'J', 'N', 'O', JCC, 0x71, + 3, 'J', 'N', 'P', JCC, 0x7B, + 3, 'J', 'N', 'S', JCC, 0x79, + 3, 'J', 'N', 'Z', JCC, 0x75, + 2, 'J', 'O', JCC, 0x70, + 2, 'J', 'P', JCC, 0x7A, + 3, 'J', 'P', 'E', JCC, 0x7A, + 3, 'J', 'P', 'O', JCC, 0x7B, + 2, 'J', 'S', JCC, 0x78, + 2, 'J', 'Z', JCC, 0x74, + 4, 'L', 'A', 'H', 'F', INHER, 0x9F, + 3, 'L', 'D', 'S', GvMp, 0xC5, + 3, 'L', 'E', 'A', LEA, 0x8D, + 5, 'L', 'E', 'A', 'V', 'E', INHER, 0xC9, + 3, 'L', 'E', 'S', GvMp, 0xC4, + 4, 'L', 'O', 'C', 'K', INHER, 0xF0, + 4, 'L', 'O', 'D', 'B', INHER, 0xAC, + 4, 'L', 'O', 'D', 'S', INHER, 0xAD, + 5, 'L', 'O', 'D', 'S', 'B', INHER, 0xAC, + 5, 'L', 'O', 'D', 'S', 'D', INHER32, 0xAD, + 5, 'L', 'O', 'D', 'S', 'W', INHER16, 0xAD, + 4, 'L', 'O', 'D', 'W', INHER16, 0xAD, + 4, 'L', 'O', 'O', 'P', JCC, 0xE2, + 5, 'L', 'O', 'O', 'P', 'E', JCC, 0xE1, + 6, 'L', 'O', 'O', 'P', 'N', 'E', JCC, 0xE0, + 6, 'L', 'O', 'O', 'P', 'N', 'Z', JCC, 0xE0, + 5, 'L', 'O', 'O', 'P', 'Z', JCC, 0xE1, + 3, 'M', 'O', 'V', MOV, 0x88, + 4, 'M', 'O', 'V', 'S', INHER, MOVSW_OPCODE, + 5, 'M', 'O', 'V', 'S', 'B', INHER, MOVSB_OPCODE, + 5, 'M', 'O', 'V', 'S', 'D', INHER32, MOVSW_OPCODE, + 5, 'M', 'O', 'V', 'S', 'W', INHER16, MOVSW_OPCODE, + 4, 'M', 'O', 'V', 'W', INHER16, MOVSW_OPCODE, + 3, 'M', 'U', 'L', DIVMUL, 0x20, + 3, 'N', 'E', 'G', NEGNOT, 0x18, + 3, 'N', 'O', 'P', INHER, 0x90, + 3, 'N', 'O', 'T', NEGNOT, 0x10, + 2, 'O', 'R', GROUP1, 0x08, + 3, 'O', 'U', 'T', OUT, 0xEE, + 4, 'O', 'U', 'T', 'S', INHER, 0x6F, + 5, 'O', 'U', 'T', 'S', 'B', INHER, 0x6E, + 5, 'O', 'U', 'T', 'S', 'D', INHER32, 0x6F, + 5, 'O', 'U', 'T', 'S', 'W', INHER16, 0x6F, + 4, 'O', 'U', 'T', 'W', OUT, 0xEF, + 3, 'P', 'O', 'P', PUSHPOP, POP_OPCODE, + 4, 'P', 'O', 'P', 'A', INHER16, 0x61, + 5, 'P', 'O', 'P', 'A', 'D', INHER32, 0x61, + 4, 'P', 'O', 'P', 'F', INHER16, 0x9D, + 5, 'P', 'O', 'P', 'F', 'D', INHER32, 0x9D, + 4, 'P', 'U', 'S', 'H', PUSHPOP, PUSH_OPCODE, + 5, 'P', 'U', 'S', 'H', 'A', INHER16, 0x60, + 6, 'P', 'U', 'S', 'H', 'A', 'D', INHER32, 0x60, + 5, 'P', 'U', 'S', 'H', 'F', INHER16, 0x9C, + 6, 'P', 'U', 'S', 'H', 'F', 'D', INHER32, 0x9C, + 3, 'R', 'C', 'L', GROUP2, 0x10, + 3, 'R', 'C', 'R', GROUP2, 0x18, + 3, 'R', 'O', 'L', GROUP2, 0x00, + 3, 'R', 'O', 'R', GROUP2, 0x08, + 3, 'R', 'E', 'P', INHER, 0xF3, + 4, 'R', 'E', 'P', 'E', INHER, 0xF3, + 5, 'R', 'E', 'P', 'N', 'E', INHER, 0xF2, + 5, 'R', 'E', 'P', 'N', 'Z', INHER, 0xF2, + 4, 'R', 'E', 'P', 'Z', INHER, 0xF3, + 3, 'R', 'E', 'T', RET, 0xC3, + 4, 'R', 'E', 'T', 'F', RET, 0xCB, + 4, 'R', 'E', 'T', 'I', RET, 0xCB, + 4, 'S', 'A', 'H', 'F', INHER, 0x9E, + 3, 'S', 'A', 'L', GROUP2, 0x20, + 3, 'S', 'A', 'R', GROUP2, 0x38, + 3, 'S', 'B', 'B', GROUP1, 0x18, + 4, 'S', 'C', 'A', 'B', INHER, 0xAE, + 4, 'S', 'C', 'A', 'S', INHER, 0xAF, + 5, 'S', 'C', 'A', 'S', 'B', INHER, 0xAE, + 5, 'S', 'C', 'A', 'S', 'D', INHER32, 0xAF, + 5, 'S', 'C', 'A', 'S', 'W', INHER16, 0xAF, + 4, 'S', 'C', 'A', 'W', INHER16, 0xAF, + 3, 'S', 'E', 'G', SEG, 0x06, + 3, 'S', 'H', 'L', GROUP2, 0x20, + 3, 'S', 'H', 'R', GROUP2, 0x28, + 4, 'S', 'S', 'E', 'G', INHER, 0x36, + 3, 'S', 'T', 'C', INHER, 0xF9, + 3, 'S', 'T', 'D', INHER, 0xFD, + 3, 'S', 'T', 'I', INHER, 0xFB, + 4, 'S', 'T', 'O', 'B', INHER, 0xAA, + 4, 'S', 'T', 'O', 'S', INHER, 0xAB, + 5, 'S', 'T', 'O', 'S', 'B', INHER, 0xAA, + 5, 'S', 'T', 'O', 'S', 'D', INHER32, 0xAB, + 5, 'S', 'T', 'O', 'S', 'W', INHER16, 0xAB, + 4, 'S', 'T', 'O', 'W', INHER16, 0xAB, + 3, 'S', 'U', 'B', GROUP1, 0x28, + 4, 'T', 'E', 'S', 'T', TEST, 0x84, + 4, 'W', 'A', 'I', 'T', INHER, WAIT_OPCODE, + 4, 'X', 'C', 'H', 'G', XCHG, 0x86, + 4, 'X', 'L', 'A', 'T', INHER, 0xD7, + 5, 'X', 'L', 'A', 'T', 'B', INHER, 0xD7, + 3, 'X', 'O', 'R', GROUP1, 0x30, + + /* floating point */ + 5, 'F', '2', 'X', 'M', '1', F_INHER, 0x70, + 4, 'F', 'A', 'B', 'S', F_INHER, 0x61, + 4, 'F', 'A', 'D', 'D', F_M4_M8_STST, 0x00, + 5, 'F', 'A', 'D', 'D', 'P', F_STST, 0x60, + 4, 'F', 'B', 'L', 'D', F_M10, 0x74, + 5, 'F', 'B', 'S', 'T', 'P', F_M10, 0x76, + 4, 'F', 'C', 'H', 'S', F_INHER, 0x60, + 5, 'F', 'C', 'L', 'E', 'X', F_W_INHER, 0xE2, + 4, 'F', 'C', 'O', 'M', F_M4_M8_OPTST, 0x02, + 5, 'F', 'C', 'O', 'M', 'P', F_M4_M8_OPTST, 0x03, + 6, 'F', 'C', 'O', 'M', 'P', 'P', F_INHER, 0x19, + 4, 'F', 'C', 'O', 'S', F_INHER, 0x7F, + 7, 'F', 'D', 'E', 'C', 'S', 'T', 'P', F_INHER, 0x76, + 5, 'F', 'D', 'I', 'S', 'I', F_W_INHER, 0xE1, + 4, 'F', 'D', 'I', 'V', F_M4_M8_STST, 0x06, + 5, 'F', 'D', 'I', 'V', 'P', F_STST, 0x67, + 5, 'F', 'D', 'I', 'V', 'R', F_M4_M8_STST, 0x07, + 6, 'F', 'D', 'I', 'V', 'R', 'P', F_STST, 0x66, + 4, 'F', 'E', 'N', 'I', F_W_INHER, 0xE0, + 5, 'F', 'F', 'R', 'E', 'E', F_ST, 0x50, + 5, 'F', 'I', 'A', 'D', 'D', F_M2_M4, 0x20, + 5, 'F', 'I', 'C', 'O', 'M', F_M2_M4, 0x22, + 6, 'F', 'I', 'C', 'O', 'M', 'P', F_M2_M4, 0x23, + 5, 'F', 'I', 'D', 'I', 'V', F_M2_M4, 0x26, + 6, 'F', 'I', 'D', 'I', 'V', 'R', F_M2_M4, 0x27, + 4, 'F', 'I', 'L', 'D', F_M2_M4_M8, 0x30, + 5, 'F', 'I', 'M', 'U', 'L', F_M2_M4, 0x21, + 7, 'F', 'I', 'N', 'C', 'S', 'T', 'P', F_INHER, 0x77, + 5, 'F', 'I', 'N', 'I', 'T', F_W_INHER, 0xE3, + 4, 'F', 'I', 'S', 'T', F_M2_M4, 0x32, + 5, 'F', 'I', 'S', 'T', 'P', F_M2_M4_M8, 0x33, + 5, 'F', 'I', 'S', 'U', 'B', F_M2_M4, 0x24, + 6, 'F', 'I', 'S', 'U', 'B', 'R', F_M2_M4, 0x25, + 3, 'F', 'L', 'D', F_M4_M8_M10_ST, 0x10, + 4, 'F', 'L', 'D', '1', F_INHER, 0x68, + 6, 'F', 'L', 'D', 'L', '2', 'E', F_INHER, 0x6A, + 6, 'F', 'L', 'D', 'L', '2', 'T', F_INHER, 0x69, + 5, 'F', 'L', 'D', 'C', 'W', F_M2, 0x15, + 6, 'F', 'L', 'D', 'E', 'N', 'V', F_M, 0x14, + 6, 'F', 'L', 'D', 'L', 'G', '2', F_INHER, 0x6C, + 6, 'F', 'L', 'D', 'L', 'N', '2', F_INHER, 0x6D, + 5, 'F', 'L', 'D', 'P', 'I', F_INHER, 0x6B, + 4, 'F', 'L', 'D', 'Z', F_INHER, 0x6E, + 4, 'F', 'M', 'U', 'L', F_M4_M8_STST, 0x01, + 5, 'F', 'M', 'U', 'L', 'P', F_STST, 0x61, + 6, 'F', 'N', 'C', 'L', 'E', 'X', F_INHER, 0xE2, + 6, 'F', 'N', 'D', 'I', 'S', 'I', F_INHER, 0xE1, + 5, 'F', 'N', 'E', 'N', 'I', F_INHER, 0xE0, + 6, 'F', 'N', 'I', 'N', 'I', 'T', F_INHER, 0xE3, + 4, 'F', 'N', 'O', 'P', F_INHER, 0x50, + 6, 'F', 'N', 'S', 'A', 'V', 'E', F_M, 0x56, + 6, 'F', 'N', 'S', 'T', 'C', 'W', F_M2, 0x17, + 7, 'F', 'N', 'S', 'T', 'E', 'N', 'V', F_M, 0x16, + 6, 'F', 'N', 'S', 'T', 'S', 'W', F_M2_AX, 0x57, + 6, 'F', 'P', 'A', 'T', 'A', 'N', F_INHER, 0x73, + 5, 'F', 'P', 'R', 'E', 'M', F_INHER, 0x78, + 6, 'F', 'P', 'R', 'E', 'M', '1', F_INHER, 0x75, + 5, 'F', 'P', 'T', 'A', 'N', F_INHER, 0x72, + 7, 'F', 'R', 'N', 'D', 'I', 'N', 'T', F_INHER, 0x7C, + 6, 'F', 'R', 'S', 'T', 'O', 'R', F_M, 0x54, + 5, 'F', 'S', 'A', 'V', 'E', F_W_M, 0x56, + 6, 'F', 'S', 'C', 'A', 'L', 'E', F_INHER, 0x7D, + 6, 'F', 'S', 'E', 'T', 'P', 'M', F_INHER, 0xE4, + 4, 'F', 'S', 'I', 'N', F_INHER, 0x7E, + 7, 'F', 'S', 'I', 'N', 'C', 'O', 'S', F_INHER, 0x7B, + 5, 'F', 'S', 'Q', 'R', 'T', F_INHER, 0x7A, + 3, 'F', 'S', 'T', F_M4_M8_ST, FST_ENCODED, + 5, 'F', 'S', 'T', 'C', 'W', F_W_M2, 0x17, + 6, 'F', 'S', 'T', 'E', 'N', 'V', F_W_M, 0x16, + 4, 'F', 'S', 'T', 'P', F_M4_M8_M10_ST, FSTP_ENCODED, + 5, 'F', 'S', 'T', 'S', 'W', F_W_M2_AX, 0x57, + 4, 'F', 'S', 'U', 'B', F_M4_M8_STST, 0x04, + 5, 'F', 'S', 'U', 'B', 'P', F_STST, 0x65, + 5, 'F', 'S', 'U', 'B', 'R', F_M4_M8_STST, 0x05, + 6, 'F', 'S', 'U', 'B', 'R', 'P', F_STST, 0x64, + 4, 'F', 'T', 'S', 'T', F_INHER, 0x64, + 5, 'F', 'U', 'C', 'O', 'M', F_OPTST, 0x54, + 6, 'F', 'U', 'C', 'O', 'M', 'P', F_OPTST, 0x55, + 7, 'F', 'U', 'C', 'O', 'M', 'P', 'P', F_INHER, 0xA9, + 5, 'F', 'W', 'A', 'I', 'T', INHER, WAIT_OPCODE, + 4, 'F', 'X', 'A', 'M', F_INHER, 0x65, + 4, 'F', 'X', 'C', 'H', F_OPTST, 0x11, + 7, 'F', 'X', 'T', 'R', 'A', 'C', 'T', F_INHER, 0x74, + 5, 'F', 'Y', 'L', '2', 'X', F_INHER, 0x71, + 7, 'F', 'Y', 'L', '2', 'X', 'P', '1', F_INHER, 0x79, +#endif /* I80386 */ + +#ifdef MC6809 + 3, 'A', 'B', 'X', INHER, 0x3A, + 4, 'A', 'D', 'C', 'A', ALL, 0x89, + 4, 'A', 'D', 'C', 'B', ALL, 0xC9, + 4, 'A', 'D', 'D', 'A', ALL, 0x8B, + 4, 'A', 'D', 'D', 'B', ALL, 0xCB, + 4, 'A', 'D', 'D', 'D', ALL, 0xC3, + 4, 'A', 'N', 'D', 'A', ALL, 0x84, + 4, 'A', 'N', 'D', 'B', ALL, 0xC4, + 5, 'A', 'N', 'D', 'C', 'C', IMMED, 0x1C, + 3, 'A', 'S', 'L', ALTER, 0x08, + 4, 'A', 'S', 'L', 'A', INHER, 0x48, + 4, 'A', 'S', 'L', 'B', INHER, 0x58, + 3, 'A', 'S', 'R', ALTER, 0x07, + 4, 'A', 'S', 'R', 'A', INHER, 0x47, + 4, 'A', 'S', 'R', 'B', INHER, 0x57, + 3, 'B', 'C', 'C', SHORT, 0x24, + 3, 'B', 'C', 'S', SHORT, 0x25, + 3, 'B', 'E', 'Q', SHORT, 0x27, + 3, 'B', 'G', 'E', SHORT, 0x2C, + 3, 'B', 'G', 'T', SHORT, 0x2E, + 3, 'B', 'H', 'I', SHORT, 0x22, + 3, 'B', 'H', 'S', SHORT, 0x24, + 4, 'B', 'I', 'T', 'A', ALL, 0X85, + 4, 'B', 'I', 'T', 'B', ALL, 0XC5, + 3, 'B', 'L', 'E', SHORT, 0x2F, + 3, 'B', 'L', 'O', SHORT, 0x25, + 3, 'B', 'L', 'S', SHORT, 0x23, + 3, 'B', 'L', 'T', SHORT, 0x2D, + 3, 'B', 'M', 'I', SHORT, 0x2B, + 3, 'B', 'N', 'E', SHORT, 0x26, + 3, 'B', 'P', 'L', SHORT, 0x2A, + 3, 'B', 'R', 'A', SHORT, 0x20, + 4, 'L', 'B', 'R', 'A', LONG, 0x16, + 3, 'B', 'R', 'N', SHORT, 0x21, + 3, 'B', 'S', 'R', SHORT, 0x8D, + 4, 'L', 'B', 'S', 'R', LONG, 0x17, + 3, 'B', 'V', 'C', SHORT, 0x28, + 3, 'B', 'V', 'S', SHORT, 0x29, + 3, 'C', 'L', 'R', ALTER, 0x0F, + 4, 'C', 'L', 'R', 'A', INHER, 0x4F, + 4, 'C', 'L', 'R', 'B', INHER, 0x5F, + 4, 'C', 'M', 'P', 'A', ALL, 0x81, + 4, 'C', 'M', 'P', 'B', ALL, 0xC1, + 4, 'C', 'M', 'P', 'X', ALL, 0x8C, + 3, 'C', 'O', 'M', ALTER, 0x03, + 4, 'C', 'O', 'M', 'A', INHER, 0x43, + 4, 'C', 'O', 'M', 'B', INHER, 0x53, + 4, 'C', 'W', 'A', 'I', IMMED, 0x3C, + 3, 'D', 'A', 'A', INHER, 0x19, + 3, 'D', 'E', 'C', ALTER, 0x0A, + 4, 'D', 'E', 'C', 'A', INHER, 0x4A, + 4, 'D', 'E', 'C', 'B', INHER, 0x5A, + 4, 'E', 'O', 'R', 'A', ALL, 0x88, + 4, 'E', 'O', 'R', 'B', ALL, 0xC8, + 3, 'E', 'X', 'G', SWAP, 0x1E, + 3, 'I', 'N', 'C', ALTER, 0x0C, + 4, 'I', 'N', 'C', 'A', INHER, 0x4C, + 4, 'I', 'N', 'C', 'B', INHER, 0x5C, + 3, 'J', 'M', 'P', ALTER, 0x0E, + 3, 'J', 'S', 'R', ALTER, 0x8D, + 3, 'L', 'D', 'A', ALL, 0x86, + 3, 'L', 'D', 'B', ALL, 0xC6, + 3, 'L', 'D', 'D', ALL, 0xCC, + 3, 'L', 'D', 'U', ALL, 0xCE, + 3, 'L', 'D', 'X', ALL, 0x8E, + 4, 'L', 'E', 'A', 'S', INDEXD, 0x32, + 4, 'L', 'E', 'A', 'U', INDEXD, 0x33, + 4, 'L', 'E', 'A', 'X', INDEXD, 0x30, + 4, 'L', 'E', 'A', 'Y', INDEXD, 0x31, + 3, 'L', 'S', 'L', ALTER, 0x08, + 4, 'L', 'S', 'L', 'A', INHER, 0x48, + 4, 'L', 'S', 'L', 'B', INHER, 0x58, + 3, 'L', 'S', 'R', ALTER, 0x04, + 4, 'L', 'S', 'R', 'A', INHER, 0x44, + 4, 'L', 'S', 'R', 'B', INHER, 0x54, + 3, 'M', 'U', 'L', INHER, 0x3D, + 3, 'N', 'E', 'G', ALTER, 0x00, + 4, 'N', 'E', 'G', 'A', INHER, 0x40, + 4, 'N', 'E', 'G', 'B', INHER, 0x50, + 3, 'N', 'O', 'P', INHER, 0x12, + 3, 'O', 'R', 'A', ALL, 0x8A, + 3, 'O', 'R', 'B', ALL, 0xCA, + 4, 'O', 'R', 'C', 'C', IMMED, 0x1A, + 4, 'P', 'S', 'H', 'S', SSTAK, 0x34, + 4, 'P', 'S', 'H', 'U', USTAK, 0x36, + 4, 'P', 'U', 'L', 'S', SSTAK, 0x35, + 4, 'P', 'U', 'L', 'U', USTAK, 0x37, + 3, 'R', 'O', 'L', ALTER, 0x09, + 4, 'R', 'O', 'L', 'A', INHER, 0x49, + 4, 'R', 'O', 'L', 'B', INHER, 0x59, + 3, 'R', 'O', 'R', ALTER, 0x06, + 4, 'R', 'O', 'R', 'A', INHER, 0x46, + 4, 'R', 'O', 'R', 'B', INHER, 0x56, + 3, 'R', 'T', 'I', INHER, 0x3B, + 3, 'R', 'T', 'S', INHER, 0x39, + 4, 'S', 'B', 'C', 'A', ALL, 0x82, + 4, 'S', 'B', 'C', 'B', ALL, 0xC2, + 3, 'S', 'E', 'X', INHER, 0x1D, + 3, 'S', 'T', 'A', ALTER, 0x87, + 3, 'S', 'T', 'B', ALTER, 0xC7, + 3, 'S', 'T', 'D', ALTER, 0xCD, + 3, 'S', 'T', 'U', ALTER, 0xCF, + 3, 'S', 'T', 'X', ALTER, 0x8F, + 4, 'S', 'U', 'B', 'A', ALL, 0x80, + 4, 'S', 'U', 'B', 'B', ALL, 0xC0, + 4, 'S', 'U', 'B', 'D', ALL, 0x83, + 3, 'S', 'W', 'I', INHER, 0x3F, + 4, 'S', 'Y', 'N', 'C', INHER, 0x13, + 3, 'T', 'F', 'R', SWAP, 0x1F, + 3, 'T', 'S', 'T', ALTER, 0x0D, + 4, 'T', 'S', 'T', 'A', INHER, 0x4D, + 4, 'T', 'S', 'T', 'B', INHER, 0x5D, +#endif /* MC6809 */ + 0 /* end of ops */ +}; + +PUBLIC char page1ops[] = +{ +#ifdef I80386 + 3, 'B', 'S', 'F', GvEv, 0xBC, + 3, 'B', 'S', 'R', GvEv, 0xBD, + 5, 'B', 'S', 'W', 'A', 'P', BSWAP, 0xC8, + 2, 'B', 'T', GROUP8, 0x20, + 3, 'B', 'T', 'C', GROUP8, 0x38, + 3, 'B', 'T', 'R', GROUP8, 0x30, + 3, 'B', 'T', 'S', GROUP8, 0x28, + 4, 'C', 'L', 'T', 'S', INHER, 0x06, + 7, 'C', 'M', 'P', 'X', 'C', 'H', 'G', ExGx, 0xA6, + 4, 'I', 'N', 'V', 'D', INHER, 0x08, + 6, 'I', 'N', 'V', 'L', 'P', 'G', GROUP7, 0x38, + 3, 'L', 'A', 'R', GvEv, 0x02, + 3, 'L', 'F', 'S', GvMp, 0xB4, + 4, 'L', 'G', 'D', 'T', GROUP7, 0x10, + 3, 'L', 'G', 'S', GvMp, 0xB5, + 4, 'L', 'I', 'D', 'T', GROUP7, 0x18, + 4, 'L', 'L', 'D', 'T', GROUP6, 0x10, + 4, 'L', 'M', 'S', 'W', GROUP7, 0x30, + 3, 'L', 'S', 'L', GvEv, 0x03, + 3, 'L', 'S', 'S', GvMp, 0xB2, + 3, 'L', 'T', 'R', GROUP6, 0x18, + 5, 'M', 'O', 'V', 'S', 'X', MOVX, 0xBE, + 5, 'M', 'O', 'V', 'Z', 'X', MOVX, 0xB6, + 4, 'S', 'E', 'T', 'A', SETCC, 0x97, + 5, 'S', 'E', 'T', 'A', 'E', SETCC, 0x93, + 4, 'S', 'E', 'T', 'B', SETCC, 0x92, + 5, 'S', 'E', 'T', 'B', 'E', SETCC, 0x96, + 4, 'S', 'E', 'T', 'C', SETCC, 0x92, + 4, 'S', 'E', 'T', 'E', SETCC, 0x94, + 4, 'S', 'E', 'T', 'G', SETCC, 0x9F, + 5, 'S', 'E', 'T', 'G', 'E', SETCC, 0x9D, + 4, 'S', 'E', 'T', 'L', SETCC, 0x9C, + 5, 'S', 'E', 'T', 'L', 'E', SETCC, 0x9E, + 5, 'S', 'E', 'T', 'N', 'A', SETCC, 0x96, + 6, 'S', 'E', 'T', 'N', 'A', 'E', SETCC, 0x92, + 5, 'S', 'E', 'T', 'N', 'B', SETCC, 0x93, + 6, 'S', 'E', 'T', 'N', 'B', 'E', SETCC, 0x97, + 5, 'S', 'E', 'T', 'N', 'C', SETCC, 0x93, + 5, 'S', 'E', 'T', 'N', 'E', SETCC, 0x95, + 5, 'S', 'E', 'T', 'N', 'G', SETCC, 0x9E, + 6, 'S', 'E', 'T', 'N', 'G', 'E', SETCC, 0x9C, + 5, 'S', 'E', 'T', 'N', 'L', SETCC, 0x9D, + 6, 'S', 'E', 'T', 'N', 'L', 'E', SETCC, 0x9F, + 5, 'S', 'E', 'T', 'N', 'O', SETCC, 0x91, + 5, 'S', 'E', 'T', 'N', 'P', SETCC, 0x9B, + 5, 'S', 'E', 'T', 'N', 'S', SETCC, 0x99, + 5, 'S', 'E', 'T', 'N', 'Z', SETCC, 0x95, + 4, 'S', 'E', 'T', 'O', SETCC, 0x90, + 4, 'S', 'E', 'T', 'P', SETCC, 0x9A, + 5, 'S', 'E', 'T', 'P', 'E', SETCC, 0x9A, + 5, 'S', 'E', 'T', 'P', 'O', SETCC, 0x9B, + 4, 'S', 'E', 'T', 'S', SETCC, 0x98, + 4, 'S', 'E', 'T', 'Z', SETCC, 0x94, + 4, 'S', 'G', 'D', 'T', GROUP7, 0x00, + 4, 'S', 'I', 'D', 'T', GROUP7, 0x08, + 4, 'S', 'H', 'L', 'D', SH_DOUBLE, 0xA4, + 4, 'S', 'H', 'R', 'D', SH_DOUBLE, 0xAC, + 4, 'S', 'L', 'D', 'T', GROUP6, 0x00, + 4, 'S', 'M', 'S', 'W', GROUP7, 0x20, + 3, 'S', 'T', 'R', GROUP6, 0x08, + 4, 'V', 'E', 'R', 'R', GROUP6, 0x20, + 4, 'V', 'E', 'R', 'W', GROUP6, 0x28, + 6, 'W', 'B', 'I', 'N', 'V', 'D', INHER, 0x09, + 4, 'X', 'A', 'D', 'D', ExGx, 0xC0, +#endif /* I80386 */ + +#ifdef MC6809 + 4, 'L', 'B', 'C', 'C', LONG, 0x24, + 4, 'L', 'B', 'C', 'S', LONG, 0x25, + 4, 'L', 'B', 'E', 'Q', LONG, 0x27, + 4, 'L', 'B', 'G', 'E', LONG, 0x2C, + 4, 'L', 'B', 'G', 'T', LONG, 0x2E, + 4, 'L', 'B', 'H', 'I', LONG, 0x22, + 4, 'L', 'B', 'H', 'S', LONG, 0x24, + 4, 'L', 'B', 'L', 'E', LONG, 0x2F, + 4, 'L', 'B', 'L', 'O', LONG, 0x25, + 4, 'L', 'B', 'L', 'S', LONG, 0x23, + 4, 'L', 'B', 'L', 'T', LONG, 0x2D, + 4, 'L', 'B', 'M', 'I', LONG, 0x2B, + 4, 'L', 'B', 'N', 'E', LONG, 0x26, + 4, 'L', 'B', 'P', 'L', LONG, 0x2A, + 4, 'L', 'B', 'R', 'N', LONG, 0x21, + 4, 'L', 'B', 'V', 'C', LONG, 0x28, + 4, 'L', 'B', 'V', 'S', LONG, 0x29, + 4, 'C', 'M', 'P', 'D', ALL, 0x83, + 4, 'C', 'M', 'P', 'Y', ALL, 0x8C, + 3, 'L', 'D', 'S', ALL, 0xCE, + 3, 'L', 'D', 'Y', ALL, 0x8E, + 3, 'S', 'T', 'S', ALTER, 0xCF, + 3, 'S', 'T', 'Y', ALTER, 0x8F, + 4, 'S', 'W', 'I', '2', INHER, 0x3F, +#endif /* MC6809 */ + 0 /* end of page 1 ops */ +}; + +PUBLIC char page2ops[] = +{ +#ifdef MC6809 + 4, 'C', 'M', 'P', 'S', ALL, 0x8C, + 4, 'C', 'M', 'P', 'U', ALL, 0x83, + 4, 'S', 'W', 'I', '3', INHER, 0x3F, +#endif + 0 /* end of page 2 ops */ +}; + +#ifdef I80386 +# ifdef MNSIZE +PUBLIC char bytesizeops[] = +{ + 4, 'A', 'D', 'C', 'B', GROUP1, 0x10, + 4, 'A', 'D', 'D', 'B', GROUP1, 0x00, + 4, 'A', 'N', 'D', 'B', GROUP1, 0x20, + 4, 'C', 'M', 'P', 'B', GROUP1, CMP_OPCODE_BASE, + 4, 'D', 'E', 'C', 'B', INCDEC, 0x08, + 4, 'D', 'I', 'V', 'B', DIVMUL, 0x30, + 5, 'I', 'D', 'I', 'V', 'B', DIVMUL, 0x38, + 5, 'I', 'M', 'U', 'L', 'B', IMUL, 0x28, + 3, 'I', 'N', 'B', IN, 0xEC, + 4, 'I', 'N', 'C', 'B', INCDEC, 0x00, + 4, 'M', 'O', 'V', 'B', MOV, 0x88, + 4, 'M', 'U', 'L', 'B', DIVMUL, 0x20, + 4, 'N', 'E', 'G', 'B', NEGNOT, 0x18, + 4, 'N', 'O', 'T', 'B', NEGNOT, 0x10, + 3, 'O', 'R', 'B', GROUP1, 0x08, + 4, 'O', 'U', 'T', 'B', OUT, 0xEE, + 4, 'R', 'C', 'L', 'B', GROUP2, 0x10, + 4, 'R', 'C', 'R', 'B', GROUP2, 0x18, + 4, 'R', 'O', 'L', 'B', GROUP2, 0x00, + 4, 'R', 'O', 'R', 'B', GROUP2, 0x08, + 4, 'S', 'A', 'L', 'B', GROUP2, 0x20, + 4, 'S', 'A', 'R', 'B', GROUP2, 0x38, + 4, 'S', 'H', 'L', 'B', GROUP2, 0x20, + 4, 'S', 'H', 'R', 'B', GROUP2, 0x28, + 4, 'S', 'B', 'B', 'B', GROUP1, 0x18, + 4, 'S', 'U', 'B', 'B', GROUP1, 0x28, + 5, 'T', 'E', 'S', 'T', 'B', TEST, 0x84, + 5, 'X', 'C', 'H', 'G', 'B', XCHG, 0x86, + 4, 'X', 'O', 'R', 'B', GROUP1, 0x30, + 0 /* end of byte size ops */ +}; +# endif /* MNSIZE */ +#endif /* I80386 */ + +/* --- end of keywords --- */ @@ -1,5 +1,6 @@ /* macro.c - expand macros for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" #include "globvar.h" @@ -8,12 +9,6 @@ #define EXTERN #include "macro.h" -#ifdef STDC_HEADERS_MISSING -int strncmp P((const char *s1, const char *s2, unsigned n)); -#else -#include <string.h> -#endif - /* Enter macro: stack macro and get its parameters. Parameters form a linked list of null-terminated strings of form @@ -137,8 +132,12 @@ PUBLIC void pmacro() getsym_nolookup(); if (sym == IDENT) { - if (lineptr == symname + 4 && strncmp(symname, "MEND", 4) == 0) + if (lineptr == symname + 4 && + ( strncmp(symname, "MEND", 4) == 0 || strncmp(symname, "mend", 4) == 0) ) + { + getsym(); break; + } } else if (sym != MACROARG) { @@ -1,5 +1,6 @@ /* mops.c - handle pseudo-ops */ +#include "syshead.h" #include "const.h" #include "type.h" #include "globvar.h" @@ -952,7 +953,8 @@ register struct ea_s *eap; else getsym(); } - else if (!leading_immed && idefsize <= 0x2) + /* RDB */ + else if (!leading_immed && defsize <= 0x2) eap->indcount = 0x1; /* compatibility kludge */ if (!leading_displ) eap->displ = lastexp; @@ -1113,14 +1115,23 @@ PUBLIC void mcall() far_diff = 0x0; if (sym == IDENT && (symptr = gsymptr)->type & MNREGBIT && - symptr->data & SIZEBIT && - symptr->value_reg_or_op.op.routine == FAROP) + symptr->data & SIZEBIT ) { - far_diff = 0x8; - getsym(); + if(symptr->value_reg_or_op.op.routine == FAROP) + { + far_diff = 0x8; + getsym(); + } + if(symptr->value_reg_or_op.op.routine == WORDOP && + opcode == JMP_SHORT_OPCODE) + { + opcode = JMP_OPCODE; + getsym(); + } } indirect = FALSE; - if (asld_compatible && idefsize <= 0x2) + + if (asld_compatible && defsize <= 0x2) { calljmp_kludge = 0x2; if (sym == INDIRECT) @@ -1136,6 +1147,7 @@ PUBLIC void mcall() calljmp_kludge = 0x0; if (sym == COLON) { + int tsize = target.size?target.size:defsize; if (opcode == JMP_SHORT_OPCODE) opcode = JMP_OPCODE; ++mcount; @@ -1151,10 +1163,10 @@ PUBLIC void mcall() opcode = 0x9A; lastexp = source.displ; if (!(lastexp.data & (FORBIT | RELBIT | UNDBIT)) && - defsize == 0x2 && + tsize == 0x2 && (offset_t) (lastexp.offset + 0x8000L) >= 0x18000L) datatoobig(); - mcount += defsize; + mcount += tsize; target.size = 0x2; buildimm(&target, FALSE); } @@ -1228,6 +1240,7 @@ PUBLIC void mcalli() } else { + int tsize = target.size?target.size:defsize; getcomma(); getea(&source); yesimmed(&source); @@ -1235,10 +1248,10 @@ PUBLIC void mcalli() { lastexp = target.displ; if (!(lastexp.data & (FORBIT | RELBIT | UNDBIT)) && - defsize == 0x2 && + tsize == 0x2 && (offset_t) (lastexp.offset + 0x8000L) >= 0x18000L) datatoobig(); - mcount += defsize; + mcount += tsize; source.size = 0x2; buildimm(&source, FALSE); } @@ -1878,7 +1891,26 @@ PUBLIC void mint() PUBLIC void mjcc() { - if (jumps_long && opcode < 0x80) /* above 0x80 means loop - not long */ + /* First look for j* near */ + if (sym == IDENT && + gsymptr->type & MNREGBIT && + gsymptr->data & SIZEBIT && + gsymptr->value_reg_or_op.op.routine == WORDOP && + opcode < 0x80) + { + getsym(); + getea(&target); + if (target.indcount >= 0x2 || target.base != NOREG) + kgerror(REL_REQ); + else + { + page = PAGE1_OPCODE; + ++mcount; + opcode += 0x10; + lbranch(0x84); + } + } + else if (jumps_long && opcode < 0x80) /* above 0x80 means loop, not long */ mbcc(); else mshort(); @@ -1,5 +1,6 @@ /* pops.c - handle pseudo-ops for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" #include "address.h" @@ -12,7 +13,7 @@ PRIVATE bool_t elseflag; /* set if ELSE/ELSEIF are enabled */ /* depends on zero = FALSE init */ PRIVATE bool_t lcommflag; -FORWARD void bumpsem P((struct flags_s *flagptr)); +FORWARD void bumpsem P((struct flags_s *flagptr, int defval)); FORWARD void constdata P((unsigned size)); FORWARD void docomm P((void)); FORWARD void doelseif P((pfv func)); @@ -24,8 +25,9 @@ FORWARD struct sym_s *needlabel P((void)); FORWARD void showredefinedlabel P((void)); FORWARD void setloc P((unsigned seg)); -PRIVATE void bumpsem(flagptr) +PRIVATE void bumpsem(flagptr, defval) register struct flags_s *flagptr; +int defval; { int newcount; @@ -34,7 +36,7 @@ register struct flags_s *flagptr; /* bump semaphore count by an expression (default 1), */ /* then set currentflag iff semaphore count is plus */ if (sym == EOLSYM) - lastexp.offset = 1; + lastexp.offset = defval; else { absexpres(); @@ -674,7 +676,7 @@ PUBLIC void pexport() PUBLIC void pfail() { - error(FAILERR); + if(pass) error(FAILERR); } /* FCB pseudo-op */ @@ -848,7 +850,14 @@ PUBLIC void plcomm1() PUBLIC void plist() { - bumpsem(&list); + bumpsem(&list, 1); +} + +/* .NOLIST pseudo-op */ + +PUBLIC void pnolist() +{ + bumpsem(&list, -1); } /* LOC pseudo-op */ @@ -871,7 +880,7 @@ PUBLIC void ploc() PUBLIC void pmaclist() { - bumpsem(&maclist); + bumpsem(&maclist, 1); } /* .MAP pseudo-op */ @@ -899,6 +908,7 @@ PUBLIC void porg() { accumulate_rmb(lastexp.offset - lc); binmbuf = lc = lastexp.offset; + binmbuf_set = 1; popflags = POPLC; } } @@ -980,7 +990,7 @@ PUBLIC void ptext() PUBLIC void pwarn() { - bumpsem(&warn); + bumpsem(&warn, -1); } #ifdef I80386 @@ -177,6 +177,7 @@ void pimport P((void)); void plcomm P((void)); void plcomm1 P((void)); void plist P((void)); +void pnolist P((void)); void ploc P((void)); void pmaclist P((void)); void pmap P((void)); @@ -211,6 +212,10 @@ struct sym_s *lookup P((void)); void statistics P((void)); /* type.c */ +u2_pt c2u2 P((char *buf)); +u4_t c4u4 P((char *buf)); +u2_pt cnu2 P((char *buf, unsigned count)); +u4_t cnu4 P((char *buf, unsigned count)); void u2c2 P((char *buf, u16_pt offset)); void u4c4 P((char *buf, u32_T offset)); void u2cn P((char *buf, u16_pt offset, unsigned count)); diff --git a/as/readsrc.c b/as/readsrc.c index f74db84..b539abd 100644 --- a/as/readsrc.c +++ b/as/readsrc.c @@ -1,9 +1,6 @@ -#define MAXLINE 256 /* when this is made bigger, fix pfcc not - * to store the string length in a byte- - * sized variable */ - /* readsrc.c - read source files for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" #include "flag.h" @@ -15,37 +12,26 @@ #define EXTERN #include "source.h" -#ifdef POSIX_HEADERS_MISSING -#define O_RDONLY 0 -typedef long off_t; -int close P((int fd)); -off_t lseek P((int fd, off_t offset, int whence)); -int open P((const char *path, int oflag, ...)); -int read P((int fd, void *buf, unsigned nbytes)); -#else -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> -#endif +/* + * Ok, lots of hack & slash here. + * 1) Added BIG buffer to load entire _primary_ file into memory. + * 2) This means primay file can be standard input. + * 3) Fixed so 'get/include' processing now works. + * 4) Altered for a 'normal' style buffer otherwise (MINIBUF) + * 5) Have the option of completely unbuffered if you need the last Kb. + * + * RDB. + */ -struct fcbstruct /* file control block structure */ -{ - fd_t fd; /* file descriptor */ - char *lineptr; /* current spot in line */ - char *buf; /* start of buffer (after partial line) */ - char *first; /* start of partial line before buf */ - char *limit; /* end of used part of input buffer */ - int blocksize; /* chars from last read and partial line flag */ - struct fbufstruct *includer;/* buffer of file which included current one */ -}; +#ifndef __AS386_16__ +#ifndef BIGBUFFER +#define BIGBUFFER 1 /* For most machines we have the memory */ +#endif +#endif -struct fbufstruct /* file buffer structure */ -{ - struct fcbstruct fcb; /* status after opening an include sub-file */ - char fpartline[MAXLINE + 1];/* buffer for partial line */ - char fbuf[INBUFSIZE + 1]; /* buffer to read into */ - char fname[1]; /* file name (variable length), 1 for null */ -}; +#ifndef MINIBUF +#define MINIBUF 1 /* Add in a reasonable buffer */ +#endif struct get_s /* to record included files */ { @@ -59,27 +45,27 @@ PRIVATE char hid_filnambuf[FILNAMLEN + 1]; /* buffer for file name */ PRIVATE struct get_s hid_getstak[MAXGET]; /* GET stack */ PRIVATE struct get_s *getstak; /* ptr */ -PRIVATE struct fcbstruct input; /* current input file control block */ - /* input.lineptr is not kept up to date */ - /* input.fd depends on zero init */ -PRIVATE struct fbufstruct xyz; -PRIVATE struct fbufstruct *inputbuf; /* current input file buffer */ - /* its fcb only to date in includes */ +#if BIGBUFFER == 1 +PRIVATE char *mem_start, *mem_end; +#endif PRIVATE char hid_linebuf[LINLEN]; /* line buffer */ +PRIVATE char *eol_ptr; + PRIVATE char *maclinebuf; PRIVATE char *maclineptr; +#if MINIBUF == 1 +PRIVATE void inp_seek P((int fd, long posn)); +PRIVATE long inp_tell P((int fd)); +PRIVATE int inp_line P((int fd, char * buf, int size)); +#endif + FORWARD void clearsource P((void)); FORWARD void line_too_long P((void)); PRIVATE void clearsource() { - input.includer = inputbuf; - inputbuf = &xyz; - input.first = input.limit = input.buf = inputbuf->fbuf; - *(lineptr = linebuf = input.first - 1) = EOLCHAR; - input.blocksize = 0; } PRIVATE void line_too_long() @@ -93,7 +79,7 @@ PRIVATE void line_too_long() PUBLIC void initsource() { filnamptr = hid_filnambuf; - getstak = hid_getstak + MAXGET; + getstak = hid_getstak; clearsource(); /* sentinel to invoke blank skipping */ } @@ -101,9 +87,67 @@ PUBLIC fd_t open_input(name) char *name; { fd_t fd; +#if BIGBUFFER == 1 + off_t filelength = -1; - if ((unsigned) (fd = open(name, O_RDONLY)) > 255) + if( mem_start == 0 && strcmp(name, "-") == 0 ) + fd = 0; + else +#endif + if ((unsigned) (fd = open(name, O_RDONLY|O_BINARY)) > 255) as_abort("error opening input file"); + +#if BIGBUFFER == 1 + if( mem_start == 0 ) + { + if(fd) + { + struct stat st; + if( fstat(fd, &st) >= 0 ) + filelength = st.st_size; + if( filelength > (((unsigned)-1)>>1)-3 ) + { + mem_end = mem_start = "\n\n"; + goto cant_do_this; + } + } + if( filelength > 0 ) + { + if( (mem_start = malloc(filelength+2)) == 0 ) + { + mem_end = mem_start = "\n\n"; + goto cant_do_this; + } + filelength = read(fd, mem_start, filelength); + } + else + { + size_t memsize = 0; + int cc; + filelength = 0; + + for(;;) + { + if( filelength >= memsize ) + mem_start = realloc(mem_start, (memsize+=16000)+4); + if(mem_start == 0) + as_abort("Cannot allocate memory for BIG buffer"); + cc = read(fd, mem_start+filelength, + (size_t)(memsize-filelength)); + if( cc <= 0 ) break; + filelength+=cc; + } + } + *(mem_end=mem_start+filelength) = '\n'; + mem_end[1] = '\0'; + + infiln = infil0 = 0; /* Assemble from memory */ + if(fd) close(fd); + fd = -1; + } +cant_do_this: +#endif + clearsource(); return fd; } @@ -116,27 +160,36 @@ char *name; PUBLIC void pget() { -#if OLD if (infiln >= MAXGET) error(GETOV); else { + char save; + skipline(); listline(); + + getstak->fd = infil; + getstak->line = linum; if (infiln != 0) - { - --getstak; - getstak->fd = infil; - getstak->line = linum; - getstak->position = lseek(infil, 0L, 1) - (inbufend - inbufptr); - ++infiln; - linum = 0; - infil = open_input(lineptr - 1); - } - } +#if MINIBUF == 1 + getstak->position = inp_tell(infil); #else - as_abort("get/include pseudo-op not implemented"); + getstak->position = lseek(infil, 0L, 1); #endif + else + getstak->position = (off_t)eol_ptr; + ++getstak; + ++infiln; + linum = 0; + + for(lineptr=symname; *lineptr != EOLCHAR; lineptr++) + if( *lineptr <= ' ' ) break; + save = *lineptr; *lineptr = '\0'; + infil = open_input(symname); + *lineptr = save; + getsym(); + } } /* process end of file */ @@ -148,8 +201,6 @@ PUBLIC void pproceof() { if (infiln != 0) close(infil); - if (lineptr == linebuf) - list.current = FALSE; /* don't list line after last unless error */ if (infiln == infil0) /* all conditionals must be closed before end of main file (not GETs) */ { @@ -165,14 +216,21 @@ PUBLIC void pproceof() /* macros must be closed before end of all files */ if (macload) error(EOFMAC); - listline(); /* last line or line after last if error */ + if (linebuf != lineptr) + listline(); /* last line or line after last if error */ if (infiln != infil0) { + --getstak; infil = getstak->fd; linum = getstak->line; - if (--infiln != 0) + if (--infiln == 0) + eol_ptr = (void*)getstak->position; + else +#if MINIBUF == 1 + inp_seek(infil, getstak->position); +#else lseek(infil, getstak->position, 0); - ++getstak; +#endif } else if (!pass) { @@ -194,6 +252,8 @@ PUBLIC void pproceof() warn.current = FALSE; if (infiln != 0) infil = open_input(filnamptr); + else + eol_ptr=0; binheader(); } else @@ -211,6 +271,8 @@ PUBLIC void pproceof() PUBLIC void readline() { + int cc = 0; + listpre = FALSE; /* not listed yet */ if (maclevel != 0) { @@ -285,56 +347,127 @@ PUBLIC void readline() lineptr = maclineptr; macflag = FALSE; } -again: + /* End of macro expansion processing */ + +again: /* On EOF for main or included files */ ++linum; - ++lineptr; /* if eof, this is input.limit + 1 */ - if (input.blocksize != 0) /* and this routine just resets eof */ + +#if BIGBUFFER == 1 + if( infiln == 0 ) { - if (lineptr < input.limit) /* move back partial line */ - { - register char *col; - - col = input.buf; - while ((*--col = *--input.limit) != EOLCHAR) - ; - input.first = col + 1; - ++input.limit; - input.blocksize = 0; - } - else /* may be non-terminated line, don't stop */ - lineptr = input.limit; + if( eol_ptr == 0 ) eol_ptr = mem_start-1; + else *eol_ptr = '\n'; + linebuf = lineptr = eol_ptr + 1; + cc = (mem_end - linebuf); + + /* memchr not strchr 'cause some implementations of strchr are like: + memchr(x,y,strlen(x)); this is _BAD_ with BIGBUFFER + */ + if((eol_ptr = memchr(linebuf, '\n', cc)) == 0 && cc > 0) + cc = -1; } - if (lineptr == input.limit) + else +#endif { - lineptr = input.first; - input.blocksize = read(infil, input.buf, INBUFSIZE); - if (input.blocksize < 0) - as_abort("error reading input"); - if (input.blocksize == 0) - { - clearsource(); - pproceof(); - if (macload) - { - symname = lineptr; - return; /* macro not allowed across eof */ - } - goto again; - } - input.first = input.buf; - *(input.limit = input.buf + input.blocksize) = EOLCHAR; + lineptr = linebuf = hid_linebuf; + *(hid_linebuf+sizeof(hid_linebuf)-2) = '\0'; /* Term */ + +#if MINIBUF == 1 + cc = inp_line(infil, linebuf, sizeof(hid_linebuf)-2); + if( cc >= 0 ) + eol_ptr = linebuf+cc-1; +#else + cc = read(infil, linebuf, sizeof(hid_linebuf)-2); + if( cc > 0 ) + { + eol_ptr = memchr(linebuf, '\n', cc); + if( eol_ptr == 0 ) + eol_ptr = hid_linebuf+sizeof(hid_linebuf)-2; + else + lseek(infil, (long)(eol_ptr+1-hid_linebuf)-cc, 1); + } +#endif } - linebuf = lineptr; - if (lineptr >= input.limit) - *(lineptr = input.limit = input.buf) = EOLCHAR; + + if( cc <= 0 ) + { + if( cc < 0 ) as_abort("error reading input"); + + clearsource(); + pproceof(); + listpre = FALSE; + if (macload) + { + symname = lineptr; + return; /* macro not allowed across eof */ + } + goto again; + } + +#if 0 + *eol_ptr = 0; + printf("LINE:%s.\n", lineptr); +#endif + *eol_ptr = EOLCHAR; } PUBLIC void skipline() { - register char *reglineptr; + if(macflag) + lineptr = strchr(hid_linebuf, EOLCHAR); + else + lineptr = eol_ptr; +} + +#if MINIBUF == 1 +PRIVATE char input_buf[1024]; /* input buffer */ +PRIVATE int in_start=0, in_end=0; +PRIVATE long ftpos = 0; +PRIVATE int lastfd = -1; + +PRIVATE int inp_line(fd, buf, size) +int fd; +char * buf; +int size; +{ + int offt = 0; + if( fd!=lastfd ) inp_seek(-1, 0L); + for(;;) + { + if(in_start >= in_end) + { + lastfd = -1; + ftpos = lseek(fd, 0L, 1); + in_start = 0; + in_end = read(fd, input_buf, sizeof(input_buf)); + if( in_end <=0 ) return in_end; + lastfd = fd; + } + if( (buf[offt++] = input_buf[in_start++]) == '\n' || offt >= size ) + break; + } + return offt; +} - reglineptr = lineptr - 1; - while (*reglineptr != EOLCHAR) - ++reglineptr; - lineptr = reglineptr; +PRIVATE long inp_tell(fd) +int fd; +{ + if( fd != lastfd ) + return lseek(fd, 0L, 1); + else + return ftpos + in_start; } + +PRIVATE void inp_seek(fd, posn) +int fd; +long posn; +{ + if( lastfd != -1 ) + lseek(lastfd, ftpos+in_start, 0); + lastfd = -1; + in_end = 0; + if( fd >= 0 ) + lseek(fd, posn, 0); +} + +#endif @@ -1,5 +1,6 @@ /* scan.c - lexical analyser for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" #include "globvar.h" @@ -11,7 +12,7 @@ PRIVATE int numbase; /* base for number */ PRIVATE char symofchar[256] = /* table to convert chars to their symbols */ { - WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE, + EOLSYM, WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE, EOLSYM, WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE, @@ -5,7 +5,7 @@ EXTERN struct sym_s *gsymptr; /* global symbol ptr */ EXTERN char lindirect; /* left symbol for indirect addressing */ EXTERN char *lineptr; /* current line position */ -EXTERN offset_t number; /* constant number */ +EXTERN offset_t number; /* constant number */ EXTERN int rindexp; /* error code for missing rindirect */ EXTERN char rindirect; /* right symbol for indirect addressing */ EXTERN char sym; /* current symbol */ diff --git a/as/syshead.h b/as/syshead.h new file mode 100644 index 0000000..d2a1655 --- /dev/null +++ b/as/syshead.h @@ -0,0 +1,50 @@ + +#ifndef STDC_HEADERS_MISSING +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#endif + +#ifndef POSIX_HEADERS_MISSING +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#endif + +#ifdef MSDOS +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#undef min +#undef POSIX_HEADERS_MISSING +#endif + +#ifdef STDC_HEADERS_MISSING +char *strcpy P((char *s1, const char *s2)); +char *strrchr P((const char *s, int c)); +int memcmp P((const void *s1, const void *s2, unsigned n)); +int strcmp P((const char *s1, const char *s2)); +int strncmp P((const char *s1, const char *s2, unsigned n)); +unsigned strlen P((const char *s)); +void *malloc P((unsigned size)); +void *memset P((void *s, int c, unsigned n)); +void exit P((int status)); +#endif + +#ifdef POSIX_HEADERS_MISSING +int close P((int fd)); +int creat P((const char *path, int mode)); +int open P((const char *path, int oflag, ...)); +int read P((int fd, void *buf, unsigned nbytes)); +int write P((int fd, const void *buf, unsigned nbytes)); +off_t lseek P((int fd, off_t offset, int whence)); +typedef long off_t; +#define O_RDONLY 0 + +#define BIGBUFFER 0 /* Can't use a big buffer ... sorry */ +#endif + +#ifndef O_BINARY +#define O_BINARY 0 +#endif @@ -1,19 +1,27 @@ /* table.c - keyword tables and symbol table lookup for assembler */ +#include "syshead.h" #include "const.h" #include "type.h" #include "globvar.h" #include "opcode.h" #include "scan.h" -#ifdef STDC_HEADERS_MISSING -int memcmp P((const void *s1, const void *s2, unsigned n)); -#else -#include <string.h> -#endif - #define hconv(ch) ((unsigned char) (ch) - 0x41) /* better form for hashing */ +#ifdef I80386 +# ifdef MNSIZE +EXTERN char bytesizeops[]; +# endif +#endif +EXTERN char ops[]; +EXTERN char page1ops[]; +EXTERN char page2ops[]; +EXTERN char regs[]; +#ifdef I80386 +EXTERN char typesizes[]; +#endif + #ifdef DEBUG unsigned nhash; unsigned nlookup; @@ -22,733 +30,6 @@ unsigned nx[30]; FORWARD void printchain P((void)); #endif -/* --- start of keywords --- */ - -/* registers */ -/* the register code (internal to assembler) is given in 1 byte */ -/* the "opcode" field is not used */ - -PUBLIC char regs[] = -{ -#ifdef I80386 - 2, 'B', 'P', BPREG, 0, - 2, 'B', 'X', BXREG, 0, - 2, 'D', 'I', DIREG, 0, - 2, 'S', 'I', SIREG, 0, - - 3, 'E', 'A', 'X', EAXREG, 0, - 3, 'E', 'B', 'P', EBPREG, 0, - 3, 'E', 'B', 'X', EBXREG, 0, - 3, 'E', 'C', 'X', ECXREG, 0, - 3, 'E', 'D', 'I', EDIREG, 0, - 3, 'E', 'D', 'X', EDXREG, 0, - 3, 'E', 'S', 'I', ESIREG, 0, - 3, 'E', 'S', 'P', ESPREG, 0, - - 2, 'A', 'X', AXREG, 0, - 2, 'C', 'X', CXREG, 0, - 2, 'D', 'X', DXREG, 0, - 2, 'S', 'P', SPREG, 0, - - 2, 'A', 'H', AHREG, 0, - 2, 'A', 'L', ALREG, 0, - 2, 'B', 'H', BHREG, 0, - 2, 'B', 'L', BLREG, 0, - 2, 'C', 'H', CHREG, 0, - 2, 'C', 'L', CLREG, 0, - 2, 'D', 'H', DHREG, 0, - 2, 'D', 'L', DLREG, 0, - - 2, 'C', 'S', CSREG, 0, - 2, 'D', 'S', DSREG, 0, - 2, 'E', 'S', ESREG, 0, - 2, 'F', 'S', FSREG, 0, - 2, 'G', 'S', GSREG, 0, - 2, 'S', 'S', SSREG, 0, - - 3, 'C', 'R', '0', CR0REG, 0, - 3, 'C', 'R', '2', CR2REG, 0, - 3, 'C', 'R', '3', CR3REG, 0, - 3, 'D', 'R', '0', DR0REG, 0, - 3, 'D', 'R', '1', DR1REG, 0, - 3, 'D', 'R', '2', DR2REG, 0, - 3, 'D', 'R', '3', DR3REG, 0, - 3, 'D', 'R', '6', DR6REG, 0, - 3, 'D', 'R', '7', DR7REG, 0, - 3, 'T', 'R', '3', TR3REG, 0, - 3, 'T', 'R', '4', TR4REG, 0, - 3, 'T', 'R', '5', TR5REG, 0, - 3, 'T', 'R', '6', TR6REG, 0, - 3, 'T', 'R', '7', TR7REG, 0, - - 2, 'S', 'T', ST0REG, 0, -#endif /* I80386 */ - -#ifdef MC6809 - 1, 'A', AREG, 0, - 1, 'B', BREG, 0, - 2, 'C', 'C', CCREG, 0, - 1, 'D', DREG, 0, - 2, 'D', 'P', DPREG, 0, - 2, 'P', 'C', PCREG, 0, - 3, 'P', 'C', 'R', PCREG, 0, - 1, 'S', SREG, 0, - 1, 'U', UREG, 0, - 1, 'X', XREG, 0, - 1, 'Y', YREG, 0, -#endif - 0 /* end of register list */ -}; - -#ifdef I80386 - -/* type sizes */ -/* the "opcode" field gives the type size */ - -PUBLIC char typesizes[] = -{ - 4, 'B', 'Y', 'T', 'E', BYTEOP, 1, - 5, 'D', 'W', 'O', 'R', 'D', DWORDOP, 4, - 5, 'F', 'W', 'O', 'R', 'D', FWORDOP, 6, - 3, 'F', 'A', 'R', FAROP, 0, - 3, 'P', 'T', 'R', PTROP, 0, - 5, 'P', 'W', 'O', 'R', 'D', PWORDOP, 6, - 5, 'Q', 'W', 'O', 'R', 'D', QWORDOP, 8, - 5, 'T', 'B', 'Y', 'T', 'E', TBYTEOP, 10, - 4, 'W', 'O', 'R', 'D', WORDOP, 2, - 0 /* end of typesize list */ -}; - -#endif - -/* ops */ -/* the routine number is given in 1 byte */ -/* the opcode is given in 1 byte (it is not used for pseudo-ops) */ - -PUBLIC char ops[] = -{ - /* pseudo-ops. The "opcode" field is unused and padded with a null byte */ - /* conditionals - must be first */ - 4, 'E', 'L', 'S', 'E', ELSEOP, 0, - 6, 'E', 'L', 'S', 'E', 'I', 'F', ELSEIFOP, 0, - 7, 'E', 'L', 'S', 'E', 'I', 'F', 'C', ELSEIFCOP, 0, - 5, 'E', 'N', 'D', 'I', 'F', ENDIFOP, 0, - 2, 'I', 'F', IFOP, 0, - 3, 'I', 'F', 'C', IFCOP, 0, - - /* unconditionals */ - 6, '.', 'A', 'L', 'I', 'G', 'N', ALIGNOP, 0, - 6, '.', 'A', 'S', 'C', 'I', 'I', FCCOP, 0, - 6, '.', 'A', 'S', 'C', 'I', 'Z', ASCIZOP, 0, - 5, '.', 'B', 'L', 'K', 'B', RMBOP, 0, - 5, '.', 'B', 'L', 'K', 'W', BLKWOP, 0, - 5, 'B', 'L', 'O', 'C', 'K', BLOCKOP, 0, - 4, '.', 'B', 'S', 'S', BSSOP, 0, - 5, '.', 'B', 'Y', 'T', 'E', FCBOP, 0, - 4, 'C', 'O', 'M', 'M', COMMOP, 0, - 5, '.', 'C', 'O', 'M', 'M', COMMOP1, 0, - 5, '.', 'D', 'A', 'T', 'A', DATAOP, 0, - 6, '.', 'D', 'A', 'T', 'A', '1', FCBOP, 0, - 6, '.', 'D', 'A', 'T', 'A', '2', FDBOP, 0, - 6, '.', 'D', 'A', 'T', 'A', '4', FQBOP, 0, - 2, 'D', 'B', FCBOP, 0, - 2, 'D', 'D', FQBOP, 0, - 7, '.', 'D', 'E', 'F', 'I', 'N', 'E', EXPORTOP, 0, - 2, 'D', 'W', FDBOP, 0, - 3, 'E', 'N', 'D', PROCEOFOP, 0, - 4, 'E', 'N', 'D', 'B', ENDBOP, 0, - 5, 'E', 'N', 'T', 'E', 'R', ENTEROP, 0, - 5, 'E', 'N', 'T', 'R', 'Y', ENTRYOP, 0, - 3, 'E', 'Q', 'U', EQUOP, 0, - 5, '.', 'E', 'V', 'E', 'N', EVENOP, 0, - 6, 'E', 'X', 'P', 'O', 'R', 'T', EXPORTOP, 0, - 6, 'E', 'X', 'T', 'E', 'R', 'N', IMPORTOP, 0, - 7, '.', 'E', 'X', 'T', 'E', 'R', 'N', IMPORTOP, 0, - 5, 'E', 'X', 'T', 'R', 'N', IMPORTOP, 0, - 4, 'F', 'A', 'I', 'L', FAILOP, 0, - 5, '.', 'F', 'A', 'I', 'L', FAILOP, 0, - 3, 'F', 'C', 'B', FCBOP, 0, - 3, 'F', 'C', 'C', FCCOP, 0, - 3, 'F', 'D', 'B', FDBOP, 0, - 3, 'G', 'E', 'T', GETOP, 0, - 6, '.', 'G', 'L', 'O', 'B', 'L', GLOBLOP, 0, - 5, 'I', 'D', 'E', 'N', 'T', IDENTOP, 0, - 6, 'I', 'M', 'P', 'O', 'R', 'T', IMPORTOP, 0, - 7, 'I', 'N', 'C', 'L', 'U', 'D', 'E', GETOP, 0, - 5, 'L', 'C', 'O', 'M', 'M', LCOMMOP, 0, - 6, '.', 'L', 'C', 'O', 'M', 'M', LCOMMOP1, 0, - 5, '.', 'L', 'I', 'S', 'T', LISTOP, 0, - 3, 'L', 'O', 'C', LOCOP, 0, - 5, '.', 'L', 'O', 'N', 'G', FQBOP, 0, - 8, '.', 'M', 'A', 'C', 'L', 'I', 'S', 'T', MACLISTOP, 0, - 5, 'M', 'A', 'C', 'R', 'O', MACROOP, 0, - 4, '.', 'M', 'A', 'P', MAPOP, 0, - 3, 'O', 'R', 'G', ORGOP, 0, - 4, '.', 'O', 'R', 'G', ORGOP, 0, - 6, 'P', 'U', 'B', 'L', 'I', 'C', EXPORTOP, 0, - 3, 'R', 'M', 'B', RMBOP, 0, - 4, '.', 'R', 'O', 'M', DATAOP, 0, - 5, '.', 'S', 'E', 'C', 'T', SECTOP, 0, - 3, 'S', 'E', 'T', SETOP, 0, - 5, 'S', 'E', 'T', 'D', 'P', SETDPOP, 0, - 6, '.', 'S', 'H', 'O', 'R', 'T', FDBOP, 0, - 6, '.', 'S', 'P', 'A', 'C', 'E', RMBOP, 0, - 5, '.', 'T', 'E', 'X', 'T', TEXTOP, 0, - 5, 'U', 'S', 'E', '1', '6', USE16OP, 0, - 5, 'U', 'S', 'E', '3', '2', USE32OP, 0, - 5, '.', 'W', 'A', 'R', 'N', WARNOP, 0, - 5, '.', 'W', 'O', 'R', 'D', FDBOP, 0, - 6, '.', 'Z', 'E', 'R', 'O', 'W', BLKWOP, 0, - - /* hardware ops. The opcode field is now used */ -#ifdef I80386 - 3, 'A', 'A', 'A', INHER, 0x37, - 3, 'A', 'A', 'D', INHER_A, 0xD5, - 3, 'A', 'A', 'M', INHER_A, 0xD4, - 3, 'A', 'A', 'S', INHER, 0x3F, - 3, 'A', 'D', 'C', GROUP1, 0x10, - 3, 'A', 'D', 'D', GROUP1, 0x00, - 3, 'A', 'N', 'D', GROUP1, 0x20, - 4, 'A', 'R', 'P', 'L', EwGw, 0x63, - 3, 'B', 'C', 'C', BCC, 0x73, - 3, 'B', 'C', 'S', BCC, 0x72, - 3, 'B', 'E', 'Q', BCC, 0x74, - 3, 'B', 'G', 'E', BCC, 0x7D, - 3, 'B', 'G', 'T', BCC, 0x7F, - 3, 'B', 'H', 'I', BCC, 0x77, - 4, 'B', 'H', 'I', 'S', BCC, 0x73, - 3, 'B', 'L', 'E', BCC, 0x7E, - 3, 'B', 'L', 'O', BCC, 0x72, - 4, 'B', 'L', 'O', 'S', BCC, 0x76, - 3, 'B', 'L', 'T', BCC, 0x7C, - 3, 'B', 'M', 'I', BCC, 0x78, - 3, 'B', 'N', 'E', BCC, 0x75, - 5, 'B', 'O', 'U', 'N', 'D', GvMa, 0x62, - 3, 'B', 'P', 'C', BCC, 0x7B, - 3, 'B', 'P', 'L', BCC, 0x79, - 3, 'B', 'P', 'S', BCC, 0x7A, - 2, 'B', 'R', CALL, JMP_OPCODE, - 3, 'B', 'V', 'C', BCC, 0x71, - 3, 'B', 'V', 'S', BCC, 0x70, - 4, 'C', 'A', 'L', 'L', CALL, JSR_OPCODE, - 5, 'C', 'A', 'L', 'L', 'F', CALLI, 0x9A, - 5, 'C', 'A', 'L', 'L', 'I', CALLI, 0x9A, - 3, 'C', 'B', 'W', INHER16, 0x98, - 3, 'C', 'L', 'C', INHER, 0xF8, - 3, 'C', 'L', 'D', INHER, 0xFC, - 3, 'C', 'L', 'I', INHER, 0xFA, - 3, 'C', 'M', 'C', INHER, 0xF5, - 3, 'C', 'M', 'P', GROUP1, CMP_OPCODE_BASE, - 4, 'C', 'M', 'P', 'S', INHER, CMPSW_OPCODE, - 5, 'C', 'M', 'P', 'S', 'B', INHER, CMPSB_OPCODE, - 5, 'C', 'M', 'P', 'S', 'D', INHER32, CMPSW_OPCODE, - 5, 'C', 'M', 'P', 'S', 'W', INHER16, CMPSW_OPCODE, - 4, 'C', 'M', 'P', 'W', INHER16, CMPSW_OPCODE, - 4, 'C', 'S', 'E', 'G', INHER, 0x2E, - 3, 'C', 'W', 'D', INHER16, 0x99, - 4, 'C', 'W', 'D', 'E', INHER32, 0x98, - 3, 'C', 'D', 'Q', INHER32, 0x99, - 3, 'D', 'A', 'A', INHER, 0x27, - 3, 'D', 'A', 'S', INHER, 0x2F, - 4, 'D', 'S', 'E', 'G', INHER, 0x3E, - 3, 'D', 'E', 'C', INCDEC, 0x08, - 3, 'D', 'I', 'V', DIVMUL, 0x30, - 5, 'E', 'N', 'T', 'E', 'R', ENTER, 0xC8, - 4, 'E', 'S', 'E', 'G', INHER, 0x26, - 4, 'F', 'S', 'E', 'G', INHER, 0x64, - 4, 'G', 'S', 'E', 'G', INHER, 0x65, - 3, 'H', 'L', 'T', INHER, 0xF4, - 4, 'I', 'D', 'I', 'V', DIVMUL, 0x38, - 4, 'I', 'M', 'U', 'L', IMUL, 0x28, - 2, 'I', 'N', IN, 0xEC, - 3, 'I', 'N', 'C', INCDEC, 0x00, - 3, 'I', 'N', 'S', INHER, 0x6D, - 4, 'I', 'N', 'S', 'B', INHER, 0x6C, - 4, 'I', 'N', 'S', 'D', INHER32, 0x6D, - 4, 'I', 'N', 'S', 'W', INHER16, 0x6D, - 3, 'I', 'N', 'T', INT, 0xCD, - 4, 'I', 'N', 'T', 'O', INHER, 0xCE, - 3, 'I', 'N', 'W', IN, 0xED, - 4, 'I', 'R', 'E', 'T', INHER16, 0xCF, - 5, 'I', 'R', 'E', 'T', 'D', INHER32, 0xCF, - 1, 'J', CALL, JMP_SHORT_OPCODE, - 2, 'J', 'A', JCC, 0x77, - 3, 'J', 'A', 'E', JCC, 0x73, - 2, 'J', 'B', JCC, 0x72, - 3, 'J', 'B', 'E', JCC, 0x76, - 2, 'J', 'C', JCC, 0x72, - 4, 'J', 'C', 'X', 'E', JCXZ, 0x2, - 4, 'J', 'C', 'X', 'Z', JCXZ, 0x2, - 5, 'J', 'E', 'C', 'X', 'E', JCXZ, 0x4, - 5, 'J', 'E', 'C', 'X', 'Z', JCXZ, 0x4, - 2, 'J', 'E', JCC, 0x74, - 2, 'J', 'G', JCC, 0x7F, - 3, 'J', 'G', 'E', JCC, 0x7D, - 2, 'J', 'L', JCC, 0x7C, - 3, 'J', 'L', 'E', JCC, 0x7E, - 3, 'J', 'M', 'P', CALL, JMP_SHORT_OPCODE, - 4, 'J', 'M', 'P', 'F', CALLI, 0xEA, - 4, 'J', 'M', 'P', 'I', CALLI, 0xEA, - 3, 'J', 'N', 'A', JCC, 0x76, - 4, 'J', 'N', 'A', 'E', JCC, 0x72, - 3, 'J', 'N', 'B', JCC, 0x73, - 4, 'J', 'N', 'B', 'E', JCC, 0x77, - 3, 'J', 'N', 'C', JCC, 0x73, - 3, 'J', 'N', 'E', JCC, 0x75, - 3, 'J', 'N', 'G', JCC, 0x7E, - 4, 'J', 'N', 'G', 'E', JCC, 0x7C, - 3, 'J', 'N', 'L', JCC, 0x7D, - 4, 'J', 'N', 'L', 'E', JCC, 0x7F, - 3, 'J', 'N', 'O', JCC, 0x71, - 3, 'J', 'N', 'P', JCC, 0x7B, - 3, 'J', 'N', 'S', JCC, 0x79, - 3, 'J', 'N', 'Z', JCC, 0x75, - 2, 'J', 'O', JCC, 0x70, - 2, 'J', 'P', JCC, 0x7A, - 3, 'J', 'P', 'E', JCC, 0x7A, - 3, 'J', 'P', 'O', JCC, 0x7B, - 2, 'J', 'S', JCC, 0x78, - 2, 'J', 'Z', JCC, 0x74, - 4, 'L', 'A', 'H', 'F', INHER, 0x9F, - 3, 'L', 'D', 'S', GvMp, 0xC5, - 3, 'L', 'E', 'A', LEA, 0x8D, - 5, 'L', 'E', 'A', 'V', 'E', INHER, 0xC9, - 3, 'L', 'E', 'S', GvMp, 0xC4, - 4, 'L', 'O', 'C', 'K', INHER, 0xF0, - 4, 'L', 'O', 'D', 'B', INHER, 0xAC, - 4, 'L', 'O', 'D', 'S', INHER, 0xAD, - 5, 'L', 'O', 'D', 'S', 'B', INHER, 0xAC, - 5, 'L', 'O', 'D', 'S', 'D', INHER32, 0xAD, - 5, 'L', 'O', 'D', 'S', 'W', INHER16, 0xAD, - 4, 'L', 'O', 'D', 'W', INHER16, 0xAD, - 4, 'L', 'O', 'O', 'P', JCC, 0xE2, - 5, 'L', 'O', 'O', 'P', 'E', JCC, 0xE1, - 6, 'L', 'O', 'O', 'P', 'N', 'E', JCC, 0xE0, - 6, 'L', 'O', 'O', 'P', 'N', 'Z', JCC, 0xE0, - 5, 'L', 'O', 'O', 'P', 'Z', JCC, 0xE1, - 3, 'M', 'O', 'V', MOV, 0x88, - 4, 'M', 'O', 'V', 'S', INHER, MOVSW_OPCODE, - 5, 'M', 'O', 'V', 'S', 'B', INHER, MOVSB_OPCODE, - 5, 'M', 'O', 'V', 'S', 'D', INHER32, MOVSW_OPCODE, - 5, 'M', 'O', 'V', 'S', 'W', INHER16, MOVSW_OPCODE, - 4, 'M', 'O', 'V', 'W', INHER16, MOVSW_OPCODE, - 3, 'M', 'U', 'L', DIVMUL, 0x20, - 3, 'N', 'E', 'G', NEGNOT, 0x18, - 3, 'N', 'O', 'P', INHER, 0x90, - 3, 'N', 'O', 'T', NEGNOT, 0x10, - 2, 'O', 'R', GROUP1, 0x08, - 3, 'O', 'U', 'T', OUT, 0xEE, - 4, 'O', 'U', 'T', 'S', INHER, 0x6F, - 5, 'O', 'U', 'T', 'S', 'B', INHER, 0x6E, - 5, 'O', 'U', 'T', 'S', 'D', INHER32, 0x6F, - 5, 'O', 'U', 'T', 'S', 'W', INHER16, 0x6F, - 4, 'O', 'U', 'T', 'W', OUT, 0xEF, - 3, 'P', 'O', 'P', PUSHPOP, POP_OPCODE, - 4, 'P', 'O', 'P', 'A', INHER16, 0x61, - 5, 'P', 'O', 'P', 'A', 'D', INHER32, 0x61, - 4, 'P', 'O', 'P', 'F', INHER16, 0x9D, - 5, 'P', 'O', 'P', 'F', 'D', INHER32, 0x9D, - 4, 'P', 'U', 'S', 'H', PUSHPOP, PUSH_OPCODE, - 5, 'P', 'U', 'S', 'H', 'A', INHER16, 0x60, - 6, 'P', 'U', 'S', 'H', 'A', 'D', INHER32, 0x60, - 5, 'P', 'U', 'S', 'H', 'F', INHER16, 0x9C, - 6, 'P', 'U', 'S', 'H', 'F', 'D', INHER32, 0x9C, - 3, 'R', 'C', 'L', GROUP2, 0x10, - 3, 'R', 'C', 'R', GROUP2, 0x18, - 3, 'R', 'O', 'L', GROUP2, 0x00, - 3, 'R', 'O', 'R', GROUP2, 0x08, - 3, 'R', 'E', 'P', INHER, 0xF3, - 4, 'R', 'E', 'P', 'E', INHER, 0xF3, - 5, 'R', 'E', 'P', 'N', 'E', INHER, 0xF2, - 5, 'R', 'E', 'P', 'N', 'Z', INHER, 0xF2, - 4, 'R', 'E', 'P', 'Z', INHER, 0xF3, - 3, 'R', 'E', 'T', RET, 0xC3, - 4, 'R', 'E', 'T', 'F', RET, 0xCB, - 4, 'R', 'E', 'T', 'I', RET, 0xCB, - 4, 'S', 'A', 'H', 'F', INHER, 0x9E, - 3, 'S', 'A', 'L', GROUP2, 0x20, - 3, 'S', 'A', 'R', GROUP2, 0x38, - 3, 'S', 'B', 'B', GROUP1, 0x18, - 4, 'S', 'C', 'A', 'B', INHER, 0xAE, - 4, 'S', 'C', 'A', 'S', INHER, 0xAF, - 5, 'S', 'C', 'A', 'S', 'B', INHER, 0xAE, - 5, 'S', 'C', 'A', 'S', 'D', INHER32, 0xAF, - 5, 'S', 'C', 'A', 'S', 'W', INHER16, 0xAF, - 4, 'S', 'C', 'A', 'W', INHER16, 0xAF, - 3, 'S', 'E', 'G', SEG, 0x06, - 3, 'S', 'H', 'L', GROUP2, 0x20, - 3, 'S', 'H', 'R', GROUP2, 0x28, - 4, 'S', 'S', 'E', 'G', INHER, 0x36, - 3, 'S', 'T', 'C', INHER, 0xF9, - 3, 'S', 'T', 'D', INHER, 0xFD, - 3, 'S', 'T', 'I', INHER, 0xFB, - 4, 'S', 'T', 'O', 'B', INHER, 0xAA, - 4, 'S', 'T', 'O', 'S', INHER, 0xAB, - 5, 'S', 'T', 'O', 'S', 'B', INHER, 0xAA, - 5, 'S', 'T', 'O', 'S', 'D', INHER32, 0xAB, - 5, 'S', 'T', 'O', 'S', 'W', INHER16, 0xAB, - 4, 'S', 'T', 'O', 'W', INHER16, 0xAB, - 3, 'S', 'U', 'B', GROUP1, 0x28, - 4, 'T', 'E', 'S', 'T', TEST, 0x84, - 4, 'W', 'A', 'I', 'T', INHER, WAIT_OPCODE, - 4, 'X', 'C', 'H', 'G', XCHG, 0x86, - 4, 'X', 'L', 'A', 'T', INHER, 0xD7, - 5, 'X', 'L', 'A', 'T', 'B', INHER, 0xD7, - 3, 'X', 'O', 'R', GROUP1, 0x30, - - /* floating point */ - 5, 'F', '2', 'X', 'M', '1', F_INHER, 0x70, - 4, 'F', 'A', 'B', 'S', F_INHER, 0x61, - 4, 'F', 'A', 'D', 'D', F_M4_M8_STST, 0x00, - 5, 'F', 'A', 'D', 'D', 'P', F_STST, 0x60, - 4, 'F', 'B', 'L', 'D', F_M10, 0x74, - 5, 'F', 'B', 'S', 'T', 'P', F_M10, 0x76, - 4, 'F', 'C', 'H', 'S', F_INHER, 0x60, - 5, 'F', 'C', 'L', 'E', 'X', F_W_INHER, 0xE2, - 4, 'F', 'C', 'O', 'M', F_M4_M8_OPTST, 0x02, - 5, 'F', 'C', 'O', 'M', 'P', F_M4_M8_OPTST, 0x03, - 6, 'F', 'C', 'O', 'M', 'P', 'P', F_INHER, 0x19, - 4, 'F', 'C', 'O', 'S', F_INHER, 0x7F, - 7, 'F', 'D', 'E', 'C', 'S', 'T', 'P', F_INHER, 0x76, - 5, 'F', 'D', 'I', 'S', 'I', F_W_INHER, 0xE1, - 4, 'F', 'D', 'I', 'V', F_M4_M8_STST, 0x06, - 5, 'F', 'D', 'I', 'V', 'P', F_STST, 0x67, - 5, 'F', 'D', 'I', 'V', 'R', F_M4_M8_STST, 0x07, - 6, 'F', 'D', 'I', 'V', 'R', 'P', F_STST, 0x66, - 4, 'F', 'E', 'N', 'I', F_W_INHER, 0xE0, - 5, 'F', 'F', 'R', 'E', 'E', F_ST, 0x50, - 5, 'F', 'I', 'A', 'D', 'D', F_M2_M4, 0x20, - 5, 'F', 'I', 'C', 'O', 'M', F_M2_M4, 0x22, - 6, 'F', 'I', 'C', 'O', 'M', 'P', F_M2_M4, 0x23, - 5, 'F', 'I', 'D', 'I', 'V', F_M2_M4, 0x26, - 6, 'F', 'I', 'D', 'I', 'V', 'R', F_M2_M4, 0x27, - 4, 'F', 'I', 'L', 'D', F_M2_M4_M8, 0x30, - 5, 'F', 'I', 'M', 'U', 'L', F_M2_M4, 0x21, - 7, 'F', 'I', 'N', 'C', 'S', 'T', 'P', F_INHER, 0x77, - 5, 'F', 'I', 'N', 'I', 'T', F_W_INHER, 0xE3, - 4, 'F', 'I', 'S', 'T', F_M2_M4, 0x32, - 5, 'F', 'I', 'S', 'T', 'P', F_M2_M4_M8, 0x33, - 5, 'F', 'I', 'S', 'U', 'B', F_M2_M4, 0x24, - 6, 'F', 'I', 'S', 'U', 'B', 'R', F_M2_M4, 0x25, - 3, 'F', 'L', 'D', F_M4_M8_M10_ST, 0x10, - 4, 'F', 'L', 'D', '1', F_INHER, 0x68, - 6, 'F', 'L', 'D', 'L', '2', 'E', F_INHER, 0x6A, - 6, 'F', 'L', 'D', 'L', '2', 'T', F_INHER, 0x69, - 5, 'F', 'L', 'D', 'C', 'W', F_M2, 0x15, - 6, 'F', 'L', 'D', 'E', 'N', 'V', F_M, 0x14, - 6, 'F', 'L', 'D', 'L', 'G', '2', F_INHER, 0x6C, - 6, 'F', 'L', 'D', 'L', 'N', '2', F_INHER, 0x6D, - 5, 'F', 'L', 'D', 'P', 'I', F_INHER, 0x6B, - 4, 'F', 'L', 'D', 'Z', F_INHER, 0x6E, - 4, 'F', 'M', 'U', 'L', F_M4_M8_STST, 0x01, - 5, 'F', 'M', 'U', 'L', 'P', F_STST, 0x61, - 6, 'F', 'N', 'C', 'L', 'E', 'X', F_INHER, 0xE2, - 6, 'F', 'N', 'D', 'I', 'S', 'I', F_INHER, 0xE1, - 5, 'F', 'N', 'E', 'N', 'I', F_INHER, 0xE0, - 6, 'F', 'N', 'I', 'N', 'I', 'T', F_INHER, 0xE3, - 4, 'F', 'N', 'O', 'P', F_INHER, 0x50, - 6, 'F', 'N', 'S', 'A', 'V', 'E', F_M, 0x56, - 6, 'F', 'N', 'S', 'T', 'C', 'W', F_M2, 0x17, - 7, 'F', 'N', 'S', 'T', 'E', 'N', 'V', F_M, 0x16, - 6, 'F', 'N', 'S', 'T', 'S', 'W', F_M2_AX, 0x57, - 6, 'F', 'P', 'A', 'T', 'A', 'N', F_INHER, 0x73, - 5, 'F', 'P', 'R', 'E', 'M', F_INHER, 0x78, - 6, 'F', 'P', 'R', 'E', 'M', '1', F_INHER, 0x75, - 5, 'F', 'P', 'T', 'A', 'N', F_INHER, 0x72, - 7, 'F', 'R', 'N', 'D', 'I', 'N', 'T', F_INHER, 0x7C, - 6, 'F', 'R', 'S', 'T', 'O', 'R', F_M, 0x54, - 5, 'F', 'S', 'A', 'V', 'E', F_W_M, 0x56, - 6, 'F', 'S', 'C', 'A', 'L', 'E', F_INHER, 0x7D, - 6, 'F', 'S', 'E', 'T', 'P', 'M', F_INHER, 0xE4, - 4, 'F', 'S', 'I', 'N', F_INHER, 0x7E, - 7, 'F', 'S', 'I', 'N', 'C', 'O', 'S', F_INHER, 0x7B, - 5, 'F', 'S', 'Q', 'R', 'T', F_INHER, 0x7A, - 3, 'F', 'S', 'T', F_M4_M8_ST, FST_ENCODED, - 5, 'F', 'S', 'T', 'C', 'W', F_W_M2, 0x17, - 6, 'F', 'S', 'T', 'E', 'N', 'V', F_W_M, 0x16, - 4, 'F', 'S', 'T', 'P', F_M4_M8_M10_ST, FSTP_ENCODED, - 5, 'F', 'S', 'T', 'S', 'W', F_W_M2_AX, 0x57, - 4, 'F', 'S', 'U', 'B', F_M4_M8_STST, 0x04, - 5, 'F', 'S', 'U', 'B', 'P', F_STST, 0x65, - 5, 'F', 'S', 'U', 'B', 'R', F_M4_M8_STST, 0x05, - 6, 'F', 'S', 'U', 'B', 'R', 'P', F_STST, 0x64, - 4, 'F', 'T', 'S', 'T', F_INHER, 0x64, - 5, 'F', 'U', 'C', 'O', 'M', F_OPTST, 0x54, - 6, 'F', 'U', 'C', 'O', 'M', 'P', F_OPTST, 0x55, - 7, 'F', 'U', 'C', 'O', 'M', 'P', 'P', F_INHER, 0xA9, - 5, 'F', 'W', 'A', 'I', 'T', INHER, WAIT_OPCODE, - 4, 'F', 'X', 'A', 'M', F_INHER, 0x65, - 4, 'F', 'X', 'C', 'H', F_OPTST, 0x11, - 7, 'F', 'X', 'T', 'R', 'A', 'C', 'T', F_INHER, 0x74, - 5, 'F', 'Y', 'L', '2', 'X', F_INHER, 0x71, - 7, 'F', 'Y', 'L', '2', 'X', 'P', '1', F_INHER, 0x79, -#endif /* I80386 */ - -#ifdef MC6809 - 3, 'A', 'B', 'X', INHER, 0x3A, - 4, 'A', 'D', 'C', 'A', ALL, 0x89, - 4, 'A', 'D', 'C', 'B', ALL, 0xC9, - 4, 'A', 'D', 'D', 'A', ALL, 0x8B, - 4, 'A', 'D', 'D', 'B', ALL, 0xCB, - 4, 'A', 'D', 'D', 'D', ALL, 0xC3, - 4, 'A', 'N', 'D', 'A', ALL, 0x84, - 4, 'A', 'N', 'D', 'B', ALL, 0xC4, - 5, 'A', 'N', 'D', 'C', 'C', IMMED, 0x1C, - 3, 'A', 'S', 'L', ALTER, 0x08, - 4, 'A', 'S', 'L', 'A', INHER, 0x48, - 4, 'A', 'S', 'L', 'B', INHER, 0x58, - 3, 'A', 'S', 'R', ALTER, 0x07, - 4, 'A', 'S', 'R', 'A', INHER, 0x47, - 4, 'A', 'S', 'R', 'B', INHER, 0x57, - 3, 'B', 'C', 'C', SHORT, 0x24, - 3, 'B', 'C', 'S', SHORT, 0x25, - 3, 'B', 'E', 'Q', SHORT, 0x27, - 3, 'B', 'G', 'E', SHORT, 0x2C, - 3, 'B', 'G', 'T', SHORT, 0x2E, - 3, 'B', 'H', 'I', SHORT, 0x22, - 3, 'B', 'H', 'S', SHORT, 0x24, - 4, 'B', 'I', 'T', 'A', ALL, 0X85, - 4, 'B', 'I', 'T', 'B', ALL, 0XC5, - 3, 'B', 'L', 'E', SHORT, 0x2F, - 3, 'B', 'L', 'O', SHORT, 0x25, - 3, 'B', 'L', 'S', SHORT, 0x23, - 3, 'B', 'L', 'T', SHORT, 0x2D, - 3, 'B', 'M', 'I', SHORT, 0x2B, - 3, 'B', 'N', 'E', SHORT, 0x26, - 3, 'B', 'P', 'L', SHORT, 0x2A, - 3, 'B', 'R', 'A', SHORT, 0x20, - 4, 'L', 'B', 'R', 'A', LONG, 0x16, - 3, 'B', 'R', 'N', SHORT, 0x21, - 3, 'B', 'S', 'R', SHORT, 0x8D, - 4, 'L', 'B', 'S', 'R', LONG, 0x17, - 3, 'B', 'V', 'C', SHORT, 0x28, - 3, 'B', 'V', 'S', SHORT, 0x29, - 3, 'C', 'L', 'R', ALTER, 0x0F, - 4, 'C', 'L', 'R', 'A', INHER, 0x4F, - 4, 'C', 'L', 'R', 'B', INHER, 0x5F, - 4, 'C', 'M', 'P', 'A', ALL, 0x81, - 4, 'C', 'M', 'P', 'B', ALL, 0xC1, - 4, 'C', 'M', 'P', 'X', ALL, 0x8C, - 3, 'C', 'O', 'M', ALTER, 0x03, - 4, 'C', 'O', 'M', 'A', INHER, 0x43, - 4, 'C', 'O', 'M', 'B', INHER, 0x53, - 4, 'C', 'W', 'A', 'I', IMMED, 0x3C, - 3, 'D', 'A', 'A', INHER, 0x19, - 3, 'D', 'E', 'C', ALTER, 0x0A, - 4, 'D', 'E', 'C', 'A', INHER, 0x4A, - 4, 'D', 'E', 'C', 'B', INHER, 0x5A, - 4, 'E', 'O', 'R', 'A', ALL, 0x88, - 4, 'E', 'O', 'R', 'B', ALL, 0xC8, - 3, 'E', 'X', 'G', SWAP, 0x1E, - 3, 'I', 'N', 'C', ALTER, 0x0C, - 4, 'I', 'N', 'C', 'A', INHER, 0x4C, - 4, 'I', 'N', 'C', 'B', INHER, 0x5C, - 3, 'J', 'M', 'P', ALTER, 0x0E, - 3, 'J', 'S', 'R', ALTER, 0x8D, - 3, 'L', 'D', 'A', ALL, 0x86, - 3, 'L', 'D', 'B', ALL, 0xC6, - 3, 'L', 'D', 'D', ALL, 0xCC, - 3, 'L', 'D', 'U', ALL, 0xCE, - 3, 'L', 'D', 'X', ALL, 0x8E, - 4, 'L', 'E', 'A', 'S', INDEXD, 0x32, - 4, 'L', 'E', 'A', 'U', INDEXD, 0x33, - 4, 'L', 'E', 'A', 'X', INDEXD, 0x30, - 4, 'L', 'E', 'A', 'Y', INDEXD, 0x31, - 3, 'L', 'S', 'L', ALTER, 0x08, - 4, 'L', 'S', 'L', 'A', INHER, 0x48, - 4, 'L', 'S', 'L', 'B', INHER, 0x58, - 3, 'L', 'S', 'R', ALTER, 0x04, - 4, 'L', 'S', 'R', 'A', INHER, 0x44, - 4, 'L', 'S', 'R', 'B', INHER, 0x54, - 3, 'M', 'U', 'L', INHER, 0x3D, - 3, 'N', 'E', 'G', ALTER, 0x00, - 4, 'N', 'E', 'G', 'A', INHER, 0x40, - 4, 'N', 'E', 'G', 'B', INHER, 0x50, - 3, 'N', 'O', 'P', INHER, 0x12, - 3, 'O', 'R', 'A', ALL, 0x8A, - 3, 'O', 'R', 'B', ALL, 0xCA, - 4, 'O', 'R', 'C', 'C', IMMED, 0x1A, - 4, 'P', 'S', 'H', 'S', SSTAK, 0x34, - 4, 'P', 'S', 'H', 'U', USTAK, 0x36, - 4, 'P', 'U', 'L', 'S', SSTAK, 0x35, - 4, 'P', 'U', 'L', 'U', USTAK, 0x37, - 3, 'R', 'O', 'L', ALTER, 0x09, - 4, 'R', 'O', 'L', 'A', INHER, 0x49, - 4, 'R', 'O', 'L', 'B', INHER, 0x59, - 3, 'R', 'O', 'R', ALTER, 0x06, - 4, 'R', 'O', 'R', 'A', INHER, 0x46, - 4, 'R', 'O', 'R', 'B', INHER, 0x56, - 3, 'R', 'T', 'I', INHER, 0x3B, - 3, 'R', 'T', 'S', INHER, 0x39, - 4, 'S', 'B', 'C', 'A', ALL, 0x82, - 4, 'S', 'B', 'C', 'B', ALL, 0xC2, - 3, 'S', 'E', 'X', INHER, 0x1D, - 3, 'S', 'T', 'A', ALTER, 0x87, - 3, 'S', 'T', 'B', ALTER, 0xC7, - 3, 'S', 'T', 'D', ALTER, 0xCD, - 3, 'S', 'T', 'U', ALTER, 0xCF, - 3, 'S', 'T', 'X', ALTER, 0x8F, - 4, 'S', 'U', 'B', 'A', ALL, 0x80, - 4, 'S', 'U', 'B', 'B', ALL, 0xC0, - 4, 'S', 'U', 'B', 'D', ALL, 0x83, - 3, 'S', 'W', 'I', INHER, 0x3F, - 4, 'S', 'Y', 'N', 'C', INHER, 0x13, - 3, 'T', 'F', 'R', SWAP, 0x1F, - 3, 'T', 'S', 'T', ALTER, 0x0D, - 4, 'T', 'S', 'T', 'A', INHER, 0x4D, - 4, 'T', 'S', 'T', 'B', INHER, 0x5D, -#endif /* MC6809 */ - 0 /* end of ops */ -}; - -PUBLIC char page1ops[] = -{ -#ifdef I80386 - 3, 'B', 'S', 'F', GvEv, 0xBC, - 3, 'B', 'S', 'R', GvEv, 0xBD, - 5, 'B', 'S', 'W', 'A', 'P', BSWAP, 0xC8, - 2, 'B', 'T', GROUP8, 0x20, - 3, 'B', 'T', 'C', GROUP8, 0x38, - 3, 'B', 'T', 'R', GROUP8, 0x30, - 3, 'B', 'T', 'S', GROUP8, 0x28, - 4, 'C', 'L', 'T', 'S', INHER, 0x06, - 7, 'C', 'M', 'P', 'X', 'C', 'H', 'G', ExGx, 0xA6, - 4, 'I', 'N', 'V', 'D', INHER, 0x08, - 6, 'I', 'N', 'V', 'L', 'P', 'G', GROUP7, 0x38, - 3, 'L', 'A', 'R', GvEv, 0x02, - 3, 'L', 'F', 'S', GvMp, 0xB4, - 4, 'L', 'G', 'D', 'T', GROUP7, 0x10, - 3, 'L', 'G', 'S', GvMp, 0xB5, - 4, 'L', 'I', 'D', 'T', GROUP7, 0x18, - 4, 'L', 'L', 'D', 'T', GROUP6, 0x10, - 4, 'L', 'M', 'S', 'W', GROUP7, 0x30, - 3, 'L', 'S', 'L', GvEv, 0x03, - 3, 'L', 'S', 'S', GvMp, 0xB2, - 3, 'L', 'T', 'R', GROUP6, 0x18, - 5, 'M', 'O', 'V', 'S', 'X', MOVX, 0xBE, - 5, 'M', 'O', 'V', 'Z', 'X', MOVX, 0xB6, - 4, 'S', 'E', 'T', 'A', SETCC, 0x97, - 5, 'S', 'E', 'T', 'A', 'E', SETCC, 0x93, - 4, 'S', 'E', 'T', 'B', SETCC, 0x92, - 5, 'S', 'E', 'T', 'B', 'E', SETCC, 0x96, - 4, 'S', 'E', 'T', 'C', SETCC, 0x92, - 4, 'S', 'E', 'T', 'E', SETCC, 0x94, - 4, 'S', 'E', 'T', 'G', SETCC, 0x9F, - 5, 'S', 'E', 'T', 'G', 'E', SETCC, 0x9D, - 4, 'S', 'E', 'T', 'L', SETCC, 0x9C, - 5, 'S', 'E', 'T', 'L', 'E', SETCC, 0x9E, - 5, 'S', 'E', 'T', 'N', 'A', SETCC, 0x96, - 6, 'S', 'E', 'T', 'N', 'A', 'E', SETCC, 0x92, - 5, 'S', 'E', 'T', 'N', 'B', SETCC, 0x93, - 6, 'S', 'E', 'T', 'N', 'B', 'E', SETCC, 0x97, - 5, 'S', 'E', 'T', 'N', 'C', SETCC, 0x93, - 5, 'S', 'E', 'T', 'N', 'E', SETCC, 0x95, - 5, 'S', 'E', 'T', 'N', 'G', SETCC, 0x9E, - 6, 'S', 'E', 'T', 'N', 'G', 'E', SETCC, 0x9C, - 5, 'S', 'E', 'T', 'N', 'L', SETCC, 0x9D, - 6, 'S', 'E', 'T', 'N', 'L', 'E', SETCC, 0x9F, - 5, 'S', 'E', 'T', 'N', 'O', SETCC, 0x91, - 5, 'S', 'E', 'T', 'N', 'P', SETCC, 0x9B, - 5, 'S', 'E', 'T', 'N', 'S', SETCC, 0x99, - 5, 'S', 'E', 'T', 'N', 'Z', SETCC, 0x95, - 4, 'S', 'E', 'T', 'O', SETCC, 0x90, - 4, 'S', 'E', 'T', 'P', SETCC, 0x9A, - 5, 'S', 'E', 'T', 'P', 'E', SETCC, 0x9A, - 5, 'S', 'E', 'T', 'P', 'O', SETCC, 0x9B, - 4, 'S', 'E', 'T', 'S', SETCC, 0x98, - 4, 'S', 'E', 'T', 'Z', SETCC, 0x94, - 4, 'S', 'G', 'D', 'T', GROUP7, 0x00, - 4, 'S', 'I', 'D', 'T', GROUP7, 0x08, - 4, 'S', 'H', 'L', 'D', SH_DOUBLE, 0xA4, - 4, 'S', 'H', 'R', 'D', SH_DOUBLE, 0xAC, - 4, 'S', 'L', 'D', 'T', GROUP6, 0x00, - 4, 'S', 'M', 'S', 'W', GROUP7, 0x20, - 3, 'S', 'T', 'R', GROUP6, 0x08, - 4, 'V', 'E', 'R', 'R', GROUP6, 0x20, - 4, 'V', 'E', 'R', 'W', GROUP6, 0x28, - 6, 'W', 'B', 'I', 'N', 'V', 'D', INHER, 0x09, - 4, 'X', 'A', 'D', 'D', ExGx, 0xC0, -#endif /* I80386 */ - -#ifdef MC6809 - 4, 'L', 'B', 'C', 'C', LONG, 0x24, - 4, 'L', 'B', 'C', 'S', LONG, 0x25, - 4, 'L', 'B', 'E', 'Q', LONG, 0x27, - 4, 'L', 'B', 'G', 'E', LONG, 0x2C, - 4, 'L', 'B', 'G', 'T', LONG, 0x2E, - 4, 'L', 'B', 'H', 'I', LONG, 0x22, - 4, 'L', 'B', 'H', 'S', LONG, 0x24, - 4, 'L', 'B', 'L', 'E', LONG, 0x2F, - 4, 'L', 'B', 'L', 'O', LONG, 0x25, - 4, 'L', 'B', 'L', 'S', LONG, 0x23, - 4, 'L', 'B', 'L', 'T', LONG, 0x2D, - 4, 'L', 'B', 'M', 'I', LONG, 0x2B, - 4, 'L', 'B', 'N', 'E', LONG, 0x26, - 4, 'L', 'B', 'P', 'L', LONG, 0x2A, - 4, 'L', 'B', 'R', 'N', LONG, 0x21, - 4, 'L', 'B', 'V', 'C', LONG, 0x28, - 4, 'L', 'B', 'V', 'S', LONG, 0x29, - 4, 'C', 'M', 'P', 'D', ALL, 0x83, - 4, 'C', 'M', 'P', 'Y', ALL, 0x8C, - 3, 'L', 'D', 'S', ALL, 0xCE, - 3, 'L', 'D', 'Y', ALL, 0x8E, - 3, 'S', 'T', 'S', ALTER, 0xCF, - 3, 'S', 'T', 'Y', ALTER, 0x8F, - 4, 'S', 'W', 'I', '2', INHER, 0x3F, -#endif /* MC6809 */ - 0 /* end of page 1 ops */ -}; - -PUBLIC char page2ops[] = -{ -#ifdef MC6809 - 4, 'C', 'M', 'P', 'S', ALL, 0x8C, - 4, 'C', 'M', 'P', 'U', ALL, 0x83, - 4, 'S', 'W', 'I', '3', INHER, 0x3F, -#endif - 0 /* end of page 2 ops */ -}; - -#ifdef I80386 -# ifdef MNSIZE -PUBLIC char bytesizeops[] = -{ - 4, 'A', 'D', 'C', 'B', GROUP1, 0x10, - 4, 'A', 'D', 'D', 'B', GROUP1, 0x00, - 4, 'A', 'N', 'D', 'B', GROUP1, 0x20, - 4, 'C', 'M', 'P', 'B', GROUP1, CMP_OPCODE_BASE, - 4, 'D', 'E', 'C', 'b', INCDEC, 0x08, - 4, 'D', 'I', 'V', 'B', DIVMUL, 0x30, - 5, 'I', 'D', 'I', 'V', 'B', DIVMUL, 0x38, - 5, 'I', 'M', 'U', 'L', 'B', IMUL, 0x28, - 3, 'I', 'N', 'B', IN, 0xEC, - 4, 'I', 'N', 'C', 'B', INCDEC, 0x00, - 4, 'M', 'O', 'V', 'B', MOV, 0x88, - 4, 'M', 'U', 'L', 'B', DIVMUL, 0x20, - 4, 'N', 'E', 'G', 'B', NEGNOT, 0x18, - 4, 'N', 'O', 'T', 'B', NEGNOT, 0x10, - 3, 'O', 'R', 'B', GROUP1, 0x08, - 4, 'O', 'U', 'T', 'B', OUT, 0xEE, - 4, 'R', 'C', 'L', 'B', GROUP2, 0x10, - 4, 'R', 'C', 'R', 'B', GROUP2, 0x18, - 4, 'R', 'O', 'L', 'B', GROUP2, 0x00, - 4, 'R', 'O', 'R', 'B', GROUP2, 0x08, - 4, 'S', 'A', 'L', 'B', GROUP2, 0x20, - 4, 'S', 'A', 'R', 'B', GROUP2, 0x38, - 4, 'S', 'H', 'L', 'B', GROUP2, 0x20, - 4, 'S', 'H', 'R', 'B', GROUP2, 0x28, - 4, 'S', 'B', 'B', 'B', GROUP1, 0x18, - 4, 'S', 'U', 'B', 'B', GROUP1, 0x28, - 5, 'T', 'E', 'S', 'T', 'B', TEST, 0x84, - 5, 'X', 'C', 'H', 'G', 'B', XCHG, 0x86, - 4, 'X', 'O', 'R', 'B', GROUP1, 0x30, - 0 /* end of byte size ops */ -}; -# endif /* MNSIZE */ -#endif /* I80386 */ - -/* --- end of keywords --- */ - FORWARD void install P((register char *keyptr, int data)); PUBLIC void inst_keywords() @@ -1,5 +1,10 @@ /* type.h - types for assembler */ +typedef unsigned short u2_t; +typedef unsigned u2_pt; +typedef unsigned long u4_t; +typedef unsigned long u4_pt; + /* redefine foo_t's because their use has become non-portable */ #define bool_t bool_T diff --git a/as/typeconv.c b/as/typeconv.c new file mode 100644 index 0000000..82dafdd --- /dev/null +++ b/as/typeconv.c @@ -0,0 +1,536 @@ +/* typeconv.c - convert between char arrays and unsigneds */ + +/* Copyright (C) 1994 Bruce Evans */ + +/* + c2u2(): 2 byte array to 2 byte unsigned + c4u4(): 4 byte array to 4 byte unsigned + cnu2(): n byte array to 2 byte unsigned + cnu4(): n byte array to 4 byte unsigned + u2c2(): 2 byte unsigned to 2 byte array + u2cn(): 2 byte unsigned to n byte array + u4c4(): 4 byte unsigned to 4 byte array + u4cn(): 4 byte unsigned to n byte array + typeconv_init: (re)initialise for given byte order. + Default is no swapping, but the initialisation should be done + anyway to provide some validity checks (returns FALSE if error). + + Not provided: + c2u4(), c4u2(), u2c4(), u4c2(). + Each of these is best done by truncating or extending a return value + or argument to the appropiate fixed-count function. + c4u2() has too many cases to do in-line conveniently, and the others + are hardly more efficient when done in-line. + + 4 byte orderings for both char arrays and unsigneds are supported: + 0123 - little-endian + 3210 - big-endian + 2301 - little-endian with long words big-endian (pdp11) + 1032 - big-endian with long words little_endian (who knows?) + + The unsigned's byte order is that of the machine on which these + routines are running. + It is determined at run time initialisation since the compiler/ + preprocessor is too dumb to tell us at compile time. +*/ + +#include "const.h" +#include "type.h" +#include "globvar.h" + +FORWARD u2_pt c2u2_00 P((char *buf)); +FORWARD u4_pt c4u4_00 P((char *buf)); +FORWARD u2_pt c2u2_ss P((char *buf)); +FORWARD u4_pt c4u4_ss P((char *buf)); +FORWARD u4_pt c4u4_s0 P((char *buf)); +FORWARD u4_pt c4u4_0s P((char *buf)); +FORWARD void u2c2_00 P((char *buf, u2_pt offset)); +FORWARD void u4c4_00 P((char *buf, u4_t offset)); +FORWARD void u2c2_ss P((char *buf, u2_pt offset)); +FORWARD void u4c4_ss P((char *buf, u4_t offset)); +FORWARD void u4c4_s0 P((char *buf, u4_t offset)); +FORWARD void u4c4_0s P((char *buf, u4_t offset)); + +PRIVATE u2_pt (*pc2u2) P((char *buf)) = c2u2_00; +PRIVATE u4_pt (*pc4u4) P((char *buf)) = c4u4_00; +PRIVATE void (*pu2c2) P((char *buf, u2_pt offset)) = u2c2_00; +PRIVATE void (*pu4c4) P((char *buf, u4_t offset)) = u4c4_00; + +/* === char arrays to unsigneds === */ + +/* no bytes swapped, longwinded to avoid alignment problems */ + +PRIVATE u2_pt c2u2_00(buf) +register char *buf; +{ + u2_t offset; + + ((char *) &offset)[0] = buf[0]; + ((char *) &offset)[1] = buf[1]; + return offset; +} + +PRIVATE u4_pt c4u4_00(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[0]; + ((char *) &offset)[1] = buf[1]; + ((char *) &offset)[2] = buf[2]; + ((char *) &offset)[3] = buf[3]; + return offset; +} + +/* straight swapping for little-endian to big-endian and vice versa */ + +PRIVATE u2_pt c2u2_ss(buf) +register char *buf; +{ + u2_t offset; + + ((char *) &offset)[0] = buf[1]; + ((char *) &offset)[1] = buf[0]; + return offset; +} + +PRIVATE u4_pt c4u4_ss(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[3]; + ((char *) &offset)[1] = buf[2]; + ((char *) &offset)[2] = buf[1]; + ((char *) &offset)[3] = buf[0]; + return offset; +} + +/* wierd swapping for different-endian u2's, same-endian u4's */ + +PRIVATE u4_pt c4u4_s0(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[1]; + ((char *) &offset)[1] = buf[0]; + ((char *) &offset)[2] = buf[3]; + ((char *) &offset)[3] = buf[2]; + return offset; +} + +/* very wierd swapping for same-endian u2's, different-endian u4's */ + +PRIVATE u4_pt c4u4_0s(buf) +register char *buf; +{ + u4_t offset; + + ((char *) &offset)[0] = buf[2]; + ((char *) &offset)[1] = buf[3]; + ((char *) &offset)[2] = buf[0]; + ((char *) &offset)[3] = buf[1]; + return offset; +} + +/* === entry points === */ + +PUBLIC u2_pt c2u2(buf) +char *buf; +{ + return (*pc2u2) (buf); +} + +PUBLIC u4_t c4u4(buf) +char *buf; +{ + return (*pc4u4) (buf); +} + +PUBLIC u2_pt cnu2(buf, count) +char *buf; +unsigned count; +{ + switch (count) + { + case 1: + return buf[0] & 0xFF; + case 2: + return (*pc2u2) (buf); + case 4: + return (u2_pt) (*pc4u4) (buf); + default: + return 0; + } +} + +PUBLIC u4_t cnu4(buf, count) +char *buf; +unsigned count; +{ + switch (count) + { + case 1: + return buf[0] & 0xFF; + case 2: + return (*pc2u2) (buf); + case 4: + return (*pc4u4) (buf); + default: + return 0; + } +} + +/* === unsigneds to char arrays === */ + +/* no bytes swapped, longwinded to avoid alignment problems */ + +PRIVATE void u2c2_00(buf, offset) +register char *buf; +u2_pt offset; +{ + + buf[0] = ((char *) &offset)[0]; + buf[1] = ((char *) &offset)[1]; +} + +PRIVATE void u4c4_00(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[0]; + buf[1] = ((char *) &offset)[1]; + buf[2] = ((char *) &offset)[2]; + buf[3] = ((char *) &offset)[3]; +} + +/* straight swapping for little-endian to big-endian and vice versa */ + +PRIVATE void u2c2_ss(buf, offset) +register char *buf; +u2_pt offset; +{ + u2_t offset2; + + offset2 = offset; + buf[0] = ((char *) &offset2)[1]; + buf[1] = ((char *) &offset2)[0]; +} + +PRIVATE void u4c4_ss(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[3]; + buf[1] = ((char *) &offset)[2]; + buf[2] = ((char *) &offset)[1]; + buf[3] = ((char *) &offset)[0]; +} + +/* wierd swapping for different-endian u2's, same-endian u4's */ + +PRIVATE void u4c4_s0(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[1]; + buf[1] = ((char *) &offset)[0]; + buf[2] = ((char *) &offset)[3]; + buf[3] = ((char *) &offset)[2]; +} + +/* very wierd swapping for same-endian u2's, different-endian u4's */ + +PRIVATE void u4c4_0s(buf, offset) +register char *buf; +u4_t offset; +{ + buf[0] = ((char *) &offset)[2]; + buf[1] = ((char *) &offset)[3]; + buf[2] = ((char *) &offset)[0]; + buf[3] = ((char *) &offset)[1]; +} + +/* === entry points === */ + +PUBLIC void u2c2(buf, offset) +register char *buf; +u2_pt offset; +{ + (*pu2c2) (buf, offset); +} + +PUBLIC void u4c4(buf, offset) +register char *buf; +u4_t offset; +{ + (*pu4c4) (buf, offset); +} + +PUBLIC void u2cn(buf, offset, count) +register char *buf; +u2_pt offset; +unsigned count; +{ + switch (count) + { + case 1: + buf[0] = (char) offset; + return; + case 2: + (*pu2c2) (buf, offset); + return; + case 4: + (*pu4c4) (buf, (u4_t) offset); + return; + } +} + +PUBLIC void u4cn(buf, offset, count) +register char *buf; +u4_t offset; +unsigned count; +{ + switch (count) + { + case 1: + buf[0] = (char) offset; + return; + case 2: + (*pu2c2) (buf, (u2_pt) (u2_t) offset); + return; + case 4: + (*pu4c4) (buf, offset); + return; + } +} + +/* initialise type conversion, return FALSE if it cannot be handled */ + +PUBLIC bool_pt typeconv_init(big_endian, long_big_endian) +bool_pt big_endian; +bool_pt long_big_endian; +{ + u2_pt conv2; + u4_pt conv4; + char *conv2ptr; + char *conv4ptr; + + if (sizeof(u2_t) != 2 || sizeof(u4_t) != 4) + /* dumb preprocessor's don't accept sizeof in #if expressions */ + return FALSE; + + if (big_endian) + { + conv2ptr = (conv4ptr = "\1\2\3\4") + 2; + if (!long_big_endian) + conv4ptr = "\3\4\1\2"; + } + else + { + conv2ptr = conv4ptr = "\4\3\2\1"; + if (long_big_endian) + conv4ptr = "\2\1\4\3"; + } + conv2 = c2u2_00(conv2ptr); + conv4 = c4u4_00(conv4ptr); + if (conv2 == 0x0304) + { + pc2u2 = c2u2_00; + pc4u4 = c4u4_00; + pu2c2 = u2c2_00; + pu4c4 = u4c4_00; + if (conv4 == 0x03040102L) + { + pc4u4 = c4u4_0s; + pu4c4 = u4c4_0s; + } + else if (conv4 != 0x01020304L) + return FALSE; + } + else if (conv2 == 0x0403) + { + pc2u2 = c2u2_ss; + pc4u4 = c4u4_ss; + pu2c2 = u2c2_ss; + pu4c4 = u4c4_ss; + if (conv4 == 0x02010403L) + { + pc4u4 = c4u4_s0; + pu4c4 = u4c4_s0; + } + else if (conv4 != 0x04030201L) + return FALSE; + } + else + return FALSE; + return TRUE; +} + +#ifdef DEBUG_TYPECONV + +main() +{ + char *source; + char target[4]; + u2_t u2; + u2_t u2a; + u4_t u4; + u4_t u4a; + + printf("%u\n", typeconv_init(FALSE, FALSE)); + printf("%u\n", typeconv_init(FALSE, TRUE)); + printf("%u\n", typeconv_init(TRUE, FALSE)); + printf("%u\n", typeconv_init(TRUE, TRUE)); + + typeconv_init(FALSE, FALSE); + source = "\4\3\2\1"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source, 2); + u2cn(target, u2, 2); + if (strncmp(source, target, 2)) + printf("oops9\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source, 2); + u4cn(target, u4a, 2); + if (strncmp(source, target, 2)) + printf("oops10\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\4\3\0\0", 4)) + printf("oops11\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops12\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); + + typeconv_init(FALSE, TRUE); + source = "\2\1\4\3"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source + 2, 2); + u2cn(target, u2, 2); + if (strncmp(source + 2, target, 2)) + printf("oops13\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source + 2, 2); + u4cn(target, u4a, 2); + if (strncmp(source + 2, target, 2)) + printf("oops14\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\0\0\4\3", 4)) + printf("oops15\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops16\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); + + typeconv_init(TRUE, FALSE); + source = "\3\4\1\2"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source, 2); + u2cn(target, u2, 2); + if (strncmp(source, target, 2)) + printf("oops5\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source, 2); + u4cn(target, u4a, 2); + if (strncmp(source, target, 2)) + printf("oops6\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\3\4\0\0", 4)) + printf("oops7\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops8\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); + + typeconv_init(TRUE, TRUE); + source = "\1\2\3\4"; + + target[0] = 0; + target[1] = 0; + u2 = cnu2(source + 2, 2); + u2cn(target, u2, 2); + if (strncmp(source + 2, target, 2)) + printf("oops1\n"); + + target[0] = 0; + target[1] = 0; + u4a = cnu4(source + 2, 2); + u4cn(target, u4a, 2); + if (strncmp(source + 2, target, 2)) + printf("oops2\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u2a = cnu2(source, 4); + u2cn(target, u2a, 4); + if (strncmp(target, "\0\0\3\4", 4)) + printf("oops3\n"); + + target[0] = 0; + target[1] = 0; + target[2] = 0; + target[3] = 0; + u4 = cnu4(source, 4); + u4cn(target, u4, 4); + if (strncmp(source, target, 4)) + printf("oops4\n"); + + printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); +} + +#endif /* DEBUG_TYPECONV */ diff --git a/bcc/Makefile b/bcc/Makefile index eb09e52..c97048b 100644 --- a/bcc/Makefile +++ b/bcc/Makefile @@ -2,7 +2,7 @@ # bcc Makefile # $Id$ # -BCCDEFS=-DLOCALPREFIX="\"/usr\"" -DDEFARCH=0 +BCCDEFS=-DLOCALPREFIX="\"/usr/bcc\"" -DDEFARCH=0 ifneq ($(TOPDIR),) include $(TOPDIR)/Make.defs @@ -10,7 +10,7 @@ BCCDEFS=-DLOCALPREFIX="\"$(BCCHOME)\"" -DDEFARCH=0 else CC=bcc CFLAGS=-Mf -LDFLAGS=-s -M +LDFLAGS=-s -Mf BINDIR=/usr/bin LIBDIR=/usr/lib/bcc endif @@ -20,7 +20,7 @@ OBJS = bcc-cc1.o codefrag.o debug.o declare.o express.o exptree.o floatop.o \ loadexp.o longop.o output.o preproc.o preserve.o scan.o softop.o \ state.o table.o type.o assign.o -all: bcc bcc-cc1 +all: bcc-cc1 bcc install: all install -d $(LIBDIR) diff --git a/bcc/bcc.doc b/bcc/bcc.doc index 1c5e930..acf4ab0 100644 --- a/bcc/bcc.doc +++ b/bcc/bcc.doc @@ -126,14 +126,14 @@ name basename of the source name -0 start with 16-bit code segment -3 start with 32-bit code segment -a enable partial compatibility with asld --b produce binary file, filename may follow (obsolete) -g only put global symbols in object file -j force all jumps to be long -l produce list file, filename may follow -m print macro expansions in listing -n name of module follows (goes in object instead of source name) -o produce object file, filename follows --s produce symbol file, filename follows (obsolete) +-b produce binary file, filename may follow +-s produce symbol file, filename follows -u take undefined symbols as imported-with-unspecified segment -w don't print warnings @@ -142,6 +142,11 @@ cc1 output and Minix's make does the wrong thing with .s files left around. However, all assembler code not written by compilers should assemble with them turned off. +The -b flag now produces a 'raw' binary file with no header, if there's no +-s flag the file starts at location 0. The -s generates an ASCII symbol +table, if a binary file doesn't start at location zero the first two items +are the start and end addresses of the binary file. + ld options ---------- diff --git a/bcc/codefrag.c b/bcc/codefrag.c index e42b05b..5d3aa82 100644 --- a/bcc/codefrag.c +++ b/bcc/codefrag.c @@ -141,6 +141,7 @@ PUBLIC void comment() } PUBLIC void ctoi() { +#ifdef I80386 if (i386_32) { outmovzx(); @@ -148,6 +149,7 @@ PUBLIC void ctoi() outncregname(BREG); } else +#endif { outxor(); outhiaccum(); @@ -345,12 +347,14 @@ PUBLIC void outword() } PUBLIC void sctoi() { +#ifdef I80386 if (i386_32) { outmovsx(); outncregname(BREG); } else +#endif outnop1str("cbw"); } PUBLIC void stoi() @@ -592,7 +596,7 @@ PRIVATE seg_t segment; /* current seg, depends on init to CSEG = 0 */ PUBLIC void adc0() { -#ifdef I8088 +#ifdef I80386 if (i386_32) { adjcarry(); @@ -616,8 +620,12 @@ offset_t offset; store_pt reg; { #ifdef I8088 +#ifdef I80386 if ((i386_32 && (uoffset_t) offset + 1 <= 2) /* do -1 to 1 by dec/inc */ || (!i386_32 && (uoffset_t) offset + 2 <= 4)) /* do -2 to 2 */ +#else + if ((uoffset_t) offset + 2 <= 4) /* do -2 to 2 */ +#endif { if (reg == ALREG) reg = AXREG; /* shorter and faster */ @@ -673,7 +681,7 @@ store_pt reg; if ((store_t) reg != AXREG) #endif bumplc(); -#ifdef I8088 +#ifdef I80386 if (i386_32) bumplc2(); #endif @@ -702,7 +710,7 @@ label_t label; #ifdef MC6809 outcregname(LOCAL); #endif -#ifdef I8088 +#ifdef I80386 if (i386_32) bumplc2(); #endif @@ -726,8 +734,10 @@ offset_t offset; outncimmadr((offset_t) (topbits >> (INT16BITSTO - CHBITSTO))); #else outandac(); +#ifdef I80386 if (i386_32) bumplc2(); +#endif outncimmadr(offset); return; #endif @@ -767,9 +777,11 @@ PUBLIC label_t casejump() outj1switch(); outlabel(jtablelab = getlabel()); outj2switch(); +#ifdef I80386 if (i386_32) bumplc2(); #endif +#endif #ifdef MC6809 if (posindependent) { @@ -833,7 +845,7 @@ uoffset_t value; uoffset_t longlow; longlow = value & (uoffset_t) intmaskto; -#ifdef I8088 +#ifdef I80386 if (i386_32) defdword(); else @@ -1157,7 +1169,7 @@ store_pt reg; if (reg != BREG) { bumplc(); -#ifdef I8088 +#ifdef I80386 if (i386_32) bumplc2(); #endif @@ -1463,7 +1475,7 @@ PUBLIC void outimmed() PUBLIC void outjumpstring() { outop3str(jumpstring); -#ifdef I8088 +#ifdef I80386 if (i386_32) bumplc2(); #endif @@ -1571,7 +1583,7 @@ store_pt targreg; PUBLIC void sbc0() { -#ifdef I8088 +#ifdef I80386 if (i386_32) { adjcarry(); @@ -1624,7 +1636,7 @@ PUBLIC void slconst(shift, reg) value_t shift; store_pt reg; { -#ifdef I8088 +#ifdef I80386 if (i386_32) { if ((shift = (uvalue_t) shift % INT32BITSTO) != 0) @@ -1675,7 +1687,7 @@ PUBLIC void srconst(shift, uflag) value_t shift; bool_pt uflag; { -#ifdef I8088 +#ifdef I80386 if (i386_32) { if ((shift = (uvalue_t) shift % INT32BITSTO) != 0) @@ -1767,9 +1779,11 @@ PRIVATE void opregadr() outccname(opregstr); outindright(); bumplc2(); +#ifdef I80386 if (i386_32) bumplc2(); #endif +#endif #ifdef MC6809 outregname(OPREG); outtab(); diff --git a/bcc/const.h b/bcc/const.h index fda6914..f41fe8b 100644 --- a/bcc/const.h +++ b/bcc/const.h @@ -10,10 +10,23 @@ #define SELFTYPECHECK /* check calculated type = runtime type */ #ifdef I8088 -# define DYNAMIC_LONG_ORDER 1 /* long word order spec. at compile time */ # define FRAMEPOINTER /* index locals off frame ptr, not stack ptr */ # define HOLDSTRINGS /* hold strings for dumping at end * since assembler has only 1 data seg */ +# define DYNAMIC_LONG_ORDER 1 /* long word order spec. at compile time */ + +#ifdef __AS386_16__ + +/* Humm, not this is nasty :-) */ +#define float no_hope +#define double no_hope +#define atof atol +#define NOFLOAT +typedef long no_hope; + +#else +# define I80386 /* Little BCC doesn't need 386 */ +#endif #endif #ifdef MC6809 diff --git a/bcc/exptree.c b/bcc/exptree.c index c4da1c4..6b24eff 100644 --- a/bcc/exptree.c +++ b/bcc/exptree.c @@ -13,7 +13,11 @@ #include "sizes.h" #include "type.h" +#ifdef __AS386_16__ +#define ETREESIZE 300 +#else #define ETREESIZE 1200 +#endif #define errtype itype #define redtype ctype #define uredtype uctype @@ -96,7 +100,7 @@ register struct nodestruct *nodeptr; nodeptr->right = castnode(nodeptr->nodetype, right); } } -#ifdef I8088 +#ifdef I80386 else if (i386_32 && bothscalar & SHORT) { nodeptr->nodetype = itype; @@ -133,7 +137,11 @@ struct nodestruct *nodeptr; PRIVATE void etreefull() { +#if ETREESIZE == 1200 limiterror("expression too complex (1201 nodes)"); +#else + limiterror("expression too complex (ETREESIZE)"); +#endif } PUBLIC void etreeinit() @@ -1043,7 +1051,7 @@ struct nodestruct *nodeptr; nodeptr->right = castnode(rscalar & UNSIGNED ? ultype : targtype, right); } -#ifdef I8088 +#ifdef I80386 else if (i386_32 && lscalar & INT) { if (rscalar & SHORT) diff --git a/bcc/function.c b/bcc/function.c index 1d48a19..7beaa14 100644 --- a/bcc/function.c +++ b/bcc/function.c @@ -234,7 +234,7 @@ struct symstruct *target; PRIVATE void out_callstring() { outop3str(callstring); -#ifdef I8088 +#ifdef I80386 if (i386_32) bumplc2(); #endif @@ -305,7 +305,7 @@ PUBLIC void reslocals() pushlist(doubleargregs); break; case 4: -# ifdef I8088 +# ifdef I80386 if (!i386_32) # endif { diff --git a/bcc/gencode.c b/bcc/gencode.c index fa098ea..2f7ce5f 100644 --- a/bcc/gencode.c +++ b/bcc/gencode.c @@ -378,7 +378,7 @@ register uvalue_t number; PUBLIC void codeinit() { -#ifdef I8088 +#ifdef I80386 if (i386_32) { /* Need DATREG2 for doubles although handling of extra data regs is diff --git a/bcc/gencode.h b/bcc/gencode.h index 370817a..a6b99ec 100644 --- a/bcc/gencode.h +++ b/bcc/gencode.h @@ -26,7 +26,7 @@ EXTERN offset_t framep; /* hardware relative frame ptr */ EXTERN uoffset_t func1saveregsize; /* choice of next two values */ EXTERN uoffset_t funcdsaveregsize; /* funcsaveregsize adjusted for doubles */ EXTERN uoffset_t funcsaveregsize; /* tot size of framelist/calleemask regs */ -#ifdef I8088 +#ifdef I80386 EXTERN bool_t i386_32; /* nonzero to generate 386 32 bit code */ /* depends on zero init */ #endif diff --git a/bcc/genloads.c b/bcc/genloads.c index 2056cb7..9c77032 100644 --- a/bcc/genloads.c +++ b/bcc/genloads.c @@ -124,7 +124,7 @@ PUBLIC store_pt getindexreg() if (!(reguse & INDREG2)) return INDREG2; #if NOTFINISHED -#ifdef I8088 +#ifdef I80386 if (i386_32) { if (!(reguse & DATREG1)) @@ -579,7 +579,7 @@ store_pt targreg; { if ((store_t) targreg & ALLDATREGS && source->type->scalar & CHAR) targreg = BREG; -#ifdef I8088 +#ifdef I80386 if (i386_32 && source->type->scalar & SHORT && source->indcount <= 1) { @@ -642,7 +642,7 @@ struct symstruct *adr; outshex(adr->offset.offi); } bumplc2(); -#ifdef I8088 +#ifdef I80386 if (i386_32) bumplc2(); #endif @@ -691,7 +691,11 @@ struct symstruct *adr; #ifdef I8088 case DATREG1: case DATREG2: +#ifdef I80386 if (indflag && !i386_32) +#else + if (indflag) +#endif { outnl(); badaddress(); @@ -784,8 +788,10 @@ struct symstruct *adr; case GLOBAL: #ifdef I8088 bumplc(); +#ifdef I80386 if (i386_32) bumplc2(); +#endif if (!indflag) outimmed(); else @@ -1014,8 +1020,11 @@ struct symstruct *source; #ifdef I8088 else if ((source->indcount == 1 && (sscalar & (SHORT | INT | LONG | FLOAT) || - source->type->constructor & POINTER)) || - (source->storage == CONSTANT && i386_32)) + source->type->constructor & POINTER)) +#ifdef I80386 + || (source->storage == CONSTANT && i386_32) +#endif + ) { size = source->type->typesize; if (size == 1) @@ -1033,6 +1042,7 @@ struct symstruct *source; outpshs(); bumplc(); outtab(); +#ifdef I80386 if (i386_32) { if (source->storage == CONSTANT) @@ -1048,6 +1058,7 @@ struct symstruct *source; else outdword(); } +#endif outadr(source); sp -= size; } @@ -1200,7 +1211,7 @@ struct symstruct *target; unbumplc(); outnnadr(target); outcomma(); -#ifdef I8088 +#ifdef I80386 if (i386_32 && target->type->scalar & SHORT) { outshortregname(sourcereg); diff --git a/bcc/glogcode.c b/bcc/glogcode.c index e2d086b..2f39080 100644 --- a/bcc/glogcode.c +++ b/bcc/glogcode.c @@ -64,7 +64,7 @@ ccode_t *pcondtrue; cmplocal(source, target, pcondtrue); #if 0 -#ifdef I8088 +#ifdef I80386 if (i386_32) { if (*pcondtrue == LO) @@ -475,12 +475,14 @@ ccode_t *pcondtrue; if (target->offset.offi != 0 && cc_signed(*pcondtrue)) load(target, targreg); +#ifdef I80386 /* Extension was not done in exptree for the == 0 case, to allow * optimization here - which we don't do for shorts. (foo--) is * newfoo == -1 here and used to be missed. */ if (i386_32 && target->type->scalar & SHORT) extend(target); +#endif if (target->offset.offi == 0) { diff --git a/bcc/hardop.c b/bcc/hardop.c index 098d22b..51f9616 100644 --- a/bcc/hardop.c +++ b/bcc/hardop.c @@ -352,7 +352,7 @@ struct symstruct *target; } else outregname(BREG); -# ifdef I8088 +# ifdef I80386 if (i386_32 && !(sscalar & CHAR)) bumplc2(); # endif diff --git a/bcc/idcc b/bcc/idcc new file mode 100755 index 0000000..a04afc8 --- /dev/null +++ b/bcc/idcc @@ -0,0 +1,311 @@ +#!/bin/ash +# +# This is a shell version of the bcc compiler driver. It's a little slower +# than a C version but overall seems to be a lot cleaner, perhaps a C version +# based on this might be a good idea ... +# +# The compiler works on a 'modal' basis certain flags given to it put the +# compiler into specific modes, it can only be in one mode for a run. +# +# The mode defines the basic passes and specific options that are available +# +# To define a mode see the functions 'run_0' and 'run_3' for examples. The +# variable assignments just above the definitions enable the functions. +# +# This script is specifically designed so the there is as little interaction +# between the modes as is possible. +# +# It's run using ash because this appears to be _much_ faster than bash, it's +# also reasonable with ksh. +# (On other interpreters I think perl would be too big, but awk might work...) +# + +TMPFIL="/tmp/cc$$" +trap "rm -f $TMPFIL.* ; exit 1" 1 2 3 15 +TMPCNT=0 + +FILES= +OPTS= +RESEXTN= +OPTIM=no +VERBOSE=no +MULTISRC=no + +LDOPTS= +DESTDEF=no +LDDEST=a.out +DEFMODE=0 + +ccmode= +LIBPATH="/lib:/usr/lib:/usr/bin" + +main() { + scanargs "$@" + + PATH="$LIBPATH:$PATH" + [ "$EXEC_PREFIX" != "" ] && PATH="$EXEC_PREFIX:$PATH" + + rv=0 + LDFILES= + [ "$MULTISRC" = yes -o "$RESEXTN" = "" ] && DESTDEF=no + + for FILE in $FILES + do + case "$FILE" in + *.c ) PASS=cpp ; BASE="`basename $FILE .c`" ;; + *.s ) PASS=as ; BASE="`basename $FILE .s`" ;; + * ) PASS=lnk ;; + esac + + NAME="`basename $FILE`" + DEST="`dirname $FILE`/" + [ "$DEST" = "./" ] && DEST= + DEST="$DEST$BASE.$RESEXTN" + [ "$DESTDEF" = yes ] && DEST="$LDDEST" + + STEMP=0 INTEMP=0 + [ "$PASS" = "cpp" ] && { compile $FILE || rv=$? ; } + [ "$PASS" = "as" ] && { assem $FILE || rv=$? ; } + if [ "$PASS" = "lnk" ] + then + LDFILES="$LDFILES $FILE" + else + # If there's a fail can't link - still assembling to temps tho. + [ "$RESEXTN" = "" ] && RESEXTN=O + fi + [ "$STEMP" = 1 ] && rm -f "$SFILE" + [ "$INTEMP" = 1 ] && RMFILES="$RMFILES $FILE" + done + + [ "$RESEXTN" != "" ] && exit $rv + + [ "$VERBOSE" = yes ] && + echo "$LD $SYSLIB $LDOPTS $LDFLAGS -o $LDDEST $CRT0 $LDFILES $LIBS" + + $LD $SYSLIB $LDOPTS $LDFLAGS -o $LDDEST $CRT0 $LDFILES $LIBS + rv=$? + [ "$RMFILES" != "" ] && rm -f $RMFILES + exit "$rv" +} + +scanargs() { + WILDOPT=no + + while [ "$#" -gt 0 ] + do + case "$1" in + -[DU]* ) CPPDEFS="$CPPDEFS $1" ;; + -B?* ) PATH="`echo '.$1:$PATH' | sed 's/...//'`" ;; + -I?* ) CPPFLAGS="$CPPFLAGS $1" ;; + -L?* ) LDOPTS="$LDOPTS $1" ;; + -o ) LDDEST="$2"; DESTDEF=yes ; shift ;; + -b ) . /usr/lib/idcc/opts_$2 || exit 1; shift ;; + -E ) RESEXTN=i ;; + -S ) RESEXTN=s ;; + -c ) RESEXTN=o ;; + -O ) OPTIM=yes ;; + -v ) VERBOSE=yes ;; + -l?* ) FILES="$FILES $1" ; MULTISRC=yes ;; + -* ) OPTS="$OPTS `echo .$1 | sed 's/..//'`" ;; + * ) [ "$FILES" != "" ] && MULTISRC=yes ; FILES="$FILES $1" ;; + esac + shift + done + + while [ "$OPTS" != "" -o "$DEFMODE" != "" ] + do + # So they can try again ... with DEFMODE if needed + MOPTS="$OPTS" + OPTS= + + for opt in $MOPTS + do + # Option can be defined only for specific mode so if we haven't seen + # the mode yet save the opt. If we have check for conflicts too. + [ "$ccmode" = "" -a "$DEFMODE" != "" ] && { + eval "[ \"\$opt_$opt\" = yes ]" || { OPTS="$OPTS $opt" ; opt= ; } + } + [ "$opt" != "" ] && { + [ "$ccmode" = "" ] || { + eval "[ \"\$mode_$opt\" = yes ]" && { + echo Option "-$opt incompatible with -$ccmode" 1>&2 + exit 2 + } + } + + eval "[ \"\$opt_$opt\" = yes ]" || { + { eval "[ \"$WILDOPT\" = yes ]" && wild_opt "-$opt" ; } || { + echo Option '-'$opt unknown for this mode 1>&2 + exit 3 + } + } + + eval "[ \"\$opt_$opt\" = yes ]" && run_$opt + eval "[ \"\$mode_$opt\" = yes ]" && ccmode="$opt" + } + done + [ "$ccmode" = "" -a "$DEFMODE" != "" ] && OPTS="$DEFMODE $OPTS" + DEFMODE= + done +} + +compile() { + [ -r "$FILE" ] || { echo "Cannot open $FILE" 1>&2 ; return 1 ; } + + [ "$RESEXTN" = "i" ] && { + cpp_only $FILE + return + } + + # Loop for the pass list + # The CCX variables _are_ expanded again. + + ret=1 + for pass in $PASSLIST + do + for extn in '' pre post inf res opt + do eval "CCX$extn=\"\$CC$pass$extn\"" + done + + [ "$CCX" = "" ] && continue; + [ "$OPTIM" = "" -a "$CCXopt" = yes ] && continue; + + shuffel "$RESEXTN" $CCXres + [ "$VERBOSE" = yes ] && + eval "echo \"$CCX $CCXpre $SFILE $CCXinf $FILE $CCXpost\"" + eval "$CCX $CCXpre $SFILE $CCXinf $FILE $CCXpost" || return 1 + ret=0 + done + [ "$ret" = 1 ] && { echo 'CC configuration error' 1>&2 ; return $ret ; } + + [ "$RESEXTN" != "s" ] && PASS=as + return 0 +} + +assem() { + [ -r "$FILE" ] || { echo "Cannot open $FILE" 1>&2 ; return 1 ; } + + shuffel "$RESEXTN" o + + n= + [ "$ASNAME" != "" ] && n="$ASNAME$NAME" + + [ "$VERBOSE" = yes ] && echo "$AS $ASFLAGS $n $SFILE -o $FILE" + $AS $ASFLAGS $n $SFILE -o $FILE || return + + [ "$RESEXTN" != "o" ] && PASS=lnk + return 0 +} + +if [ "2" = "$[1+1]" ] ; then inc_tmpcnt() { TMPCNT="$[$TMPCNT+1]" ; } +else inc_tmpcnt() { TMPCNT="`expr $TMPCNT + 1`" ; } +fi + +shuffel() { + [ "$STEMP" = 1 ] && rm -f "$SFILE" + + SFILE="$FILE" + STEMP="$INTEMP" + + if [ "$1" = "$2" ] + then + FILE="$DEST" + INTEMP=0 + else + inc_tmpcnt + FILE="$TMPFIL.$TMPCNT.$2" + INTEMP=1 + fi +} + +mode_0=yes opt_0=yes +run_0() +{ + SYSINC="-I/usr/bcc/include" + SYSLIB="-L/usr/bcc/lib/bcc/i86/" + LIBPATH="/usr/bcc/lib/bcc" + CRT0="-C0" + LIBS="-lc" + CGEN= + DEFS= + + CPP="cpp" + + PASSLIST=2 + CC2="bcc-cc1" CC2pre='$SYSINC $DEFS $CPPFLAGS' + CC2inf='-o' CC2post='-0 $CGEN $CPPDEFS' CC2res=s + AS="as86" ASFLAGS='-u -w -0' ASNAME='-n ' + LD="ld86" LDFLAGS='-i -0' + + opt_ansi=yes + run_ansi() + { + PASSLIST="0 1 2" + CC0="bcc-cc1" CC0pre='$SYSINC $DEFS $CPPFLAGS' CC0inf='-o' + CC0post='-0 -E -D__STDC__=0 $CPPDEFS' CC0res=i + CC1="unproto" CC1pre='' CC1inf='' CC1post='' CC1res=k + CC2="bcc-cc1" CC2pre='$CGEN' CC2inf='-o' CC2post='-0' CC2res=s + } + opt_I=yes; run_I() { SYSINC= ; } + opt_L=yes; run_L() { SYSLIB= ; } + opt_s=yes; run_s() { LDFLAGS="$LDFLAGS -s" ; } + opt_Mf=yes; run_Mf() { LIBS=-lc_f ; CGEN='-f -c' ;} + opt_Md=yes; run_Md() { LIBS=-ldos ; DEFS='-D__MSDOS__' LDFLAGS='-i -0 -d' ;} + + WILDOPT=yes + wild_opt() + { + case "$1" in + -O* ) OPTIM=yes ; OPTFLG="$OPTFLG $1" ;; + * ) return 1 ;; + # For normal CC operation unknowns go to the linker. ie: + # * ) LDFLAGS="$LDFLAGS $1" ; return 0 ;; + esac + return 0 + } +} + +mode_3=yes opt_3=yes +run_3() +{ + SYSINC="-I/usr/bcc/include" + SYSLIB="-L/usr/bcc/lib/bcc/i386/" + LIBPATH="/usr/bcc/lib/bcc" + CRT0="-C0" + LIBS="-lc" + CGEN= + DEFS= + + CPP="cpp" + + PASSLIST=2 + CC2="bcc-cc3" CC2pre='$SYSINC $DEFS $CPPFLAGS' + CC2inf='-o' CC2post='-3 $CGEN $CPPDEFS' CC2res=s + AS="as86" ASFLAGS='-u -w -3' ASNAME='-n ' + LD="ld86" LDFLAGS='-i -3' + + opt_ansi=yes + run_ansi() + { + PASSLIST="0 1 2" + CC0="bcc-cc3" CC0pre='$SYSINC $DEFS $CPPFLAGS' CC0inf='-o' + CC0post='-3 -E -D__STDC__=0 $CPPDEFS' CC0res=i + CC1="unproto" CC1pre='' CC1inf='' CC1post='' CC1res=k + CC2="bcc-cc1" CC2pre='$CGEN' CC2inf='-o' CC2post='-3' CC2res=s + } + opt_I=yes; run_I() { SYSINC= ; } + opt_L=yes; run_L() { SYSLIB= ; } + opt_s=yes; run_s() { LDFLAGS="$LDFLAGS -s" ; } + + WILDOPT=yes + wild_opt() + { + case "$1" in + -O* ) OPTIM=yes ; OPTFLG="$OPTFLG $1" ;; + * ) return 1 ;; + esac + return 0 + } +} + +main "$@" diff --git a/bcc/input.c b/bcc/input.c index 3d77bbf..c6fbb32 100644 --- a/bcc/input.c +++ b/bcc/input.c @@ -466,7 +466,9 @@ char *argv[]; #endif fd = 0; /* standard input */ memset(flag, 0, sizeof flag); +#ifdef I80386 flag['3'] = sizeof (int) >= 4; +#endif fname = "stdin"; (incptr = &incfirst)->incnext = &inclast; initout(); @@ -486,6 +488,8 @@ char *argv[]; { #ifdef I8088 case '0': /* generate 16-bit code */ +#endif +#ifdef I80386 case '3': /* generate 32-bit code */ #endif case 'c': /* caller saves */ @@ -539,12 +543,14 @@ ts_s_includelist += sizeof *incnew; } } #ifdef I8088 +#ifdef I80386 if (flag['3']) { i386_32 = TRUE; definestring("__AS386_32__"); } else +#endif definestring("__AS386_16__"); #endif #ifdef MC6809 @@ -585,6 +591,9 @@ ts_s_includelist += sizeof *incnew; definestring("__POS_INDEPENDENT__"); } #endif +#ifdef NOFLOAT + definestring("__HAS_NO_FLOATS__"); +#endif ctext = flag['t']; watchlc = flag['w']; setoutbufs(); diff --git a/bcc/label.c b/bcc/label.c index 5b07af9..394a47c 100644 --- a/bcc/label.c +++ b/bcc/label.c @@ -316,9 +316,11 @@ label_t label; outbyte(' '); outtab(); bumplc2(); +#ifdef I80386 if (i386_32) bumplc(); #endif +#endif #ifdef MC6809 outcond(cond); bumplc(); diff --git a/bcc/ncc.c b/bcc/ncc.c deleted file mode 100644 index d48e522..0000000 --- a/bcc/ncc.c +++ /dev/null @@ -1,215 +0,0 @@ - -#include <stdio.h> - -/* Normal passes ... - * p: C preprocessor .c -> .0 - * 1: cc1 .1 -> .2 - * 2: opt .2 -> .3 - * 3: cg .3 -> .s - * a: as .s -> .o - * l: ld .o -> .out - * - * c: Is alias for one or more of 0,1,2 - * d: This command. (Semi-colon seperators) - */ - -#define MAXPASSES 16 -#define MAXOPTIONS 32 - -struct pass { - char * command; - char pass_id; - char source; - char result; - char * args; -} passes[MAXPASSES]; - -struct option { - char * optname; - char * subst; -} options[MAXOPTS]; - -/* The default argument list ... */ -extern int standard_argc; -extern char ** standard_argv; - -#ifdef __MSDOS__ -int standard_argc = 0; /* Nothing ... use the files */ -char ** standard_argv = 0; -#endif - -struct { char * opt, *spec; } builtin_models[] = { - { "-0", "i8086" } - { "-3", "i386" } - { "-9", "mc6809" } - {0,0} -}; - -/* What sort of compile ? */ -char model[20] = "-"; -int model_found = 0; -int args_active = 1; - -/* Linker output file */ -char * output_file = "a.out"; - -char ** file_list = 0; -int file_count = 0; -int pass_count = 0; -int opts_count = 0; - -/* A temp buffer */ -char little_buf[128]; - -main(argc, argv) -int argc; -char ** argv; -{ - int ar; - /* First, is there a model ? */ - /* PROBLEM: This doesn't find -b specifiers that are embedded in user opts */ - for(ar=1; ar<argc; ar++) - if(argv[ar][0] == '-') switch(argv[ar][1]) - { - case 'o': ar++; break; - case 'b': if(argv[ar][2]) break; - ar++; - if( argv[ar] == 0 ) fatal("-b needs specifier"); - strncpy(model, argv[ar], sizeof(model)-1); - break; - default: /* Scan builtin_models */ - } - - /* Space for filenames */ - file_list = calloc(argc, sizeof(char*)); - if( file_list == 0 ) fatal("Out of memory"); - - /* Perhaps: make builtin_models[0].spec the default ? */ - - for(ar=0; ar<standard_argc; ) - ar += decode_arg(standard_argv[ar], standard_argv[ar+1]); - - /* The model isn't in the standard args ... */ - if( !model_found ) - { - strcat(little_buf, exec_paths[0]); - strcat(little_buf, "/spec"); - include_file(little_buf); - } - if( !model_found && strcmp(model, "-") != 0 ) - { - strcat(little_buf, exec_paths[0]); - strcat(little_buf, "/spec."); - strcat(little_buf, model); - include_file(little_buf); - } - if( !model_found ) fatal("Unable to find compiler specification"); - - /* Now we can do the command line for real */ - for(ar=1; ar<argc; ) - ar += decode_arg(argv[ar], argv[ar+1]); - - /* Compile all the files to objects; save the names back in file_table */ - for(ar=0; ar<file_count; ar++) - do_compile(file_table[ar]); - - /* If everything was OK then find the pass with a nul result type */ - if( exit_status == 0 ) - do_link_command(); - - return exit_status; -} - -decode_arg(arg1, arg2) -char * arg1; -char * arg2; -{ - if(arg1[0] == '-' && arg1[2] == '\0') switch(arg1[1]) - { - case 'v': verbose++; return 1; - case 'o': if( arg2 == 0 ) fatal("-o needs filename"); - output_file = arg2; - return 2; - case 'b': if( arg2 == 0 ) fatal("-b needs specifier"); - args_active = 1; - if( strcmp(arg2, "-") == 0) - return 2; - else if( strcmp(arg2, model) == 0) - ; - else if( strcmp(model, "-") == 0) - strncpy(model, arg2, sizeof(model)-1); - else - { - args_active=0; - return 2; - } - model_found = 1; - return 2; - - default: /* Lookup item in conversion table */ - } - else if( args_active == 0 ) - return 1; - else if(arg1[0] == '-' ) switch(arg1[1]) - { - case '@': include_file(arg1+2); return 1; - case 'B': add_path(exec_path, arg1+2); return 1; - case 'W': command_W(arg1+2); return 1; - case 'T': command_T(arg1+2); return 1; - /* -T0,bcc-cc1,-0,-i,$1,$2,-o,$3 ie add standard args */ - - default: /* Lookup item in conversion table */ - } - else - { - file_names[file_count++] = arg1; - return 1; - } - - /* Do conversion ... */ - /* - * 1) Locate arg in options - * 2) for each semicolon seperated item - * 3) pass it to decode_arg - * 4) remember to give it 2 args for '-b' - * - * Note: char '*' in the options table matches the rest of the arg. - */ - return 1; -} - -include_file(fname) -char * fname; -{ - FILE * fd; - char line_buffer[512]; - char * p; - - RIGHT HERE - - fd = fopen(fname, "r"); - if( fd == 0 ) fatal("Cannot open command line file"); - - while( fgets(line_buffer, sizeof(line_buffer), fd) ) - { - if( line_buffer[0] == '#' ) continue; - - } - fclose(fd); -} - -command_T(arg1) -char * arg1; -{ - /* Is it an option specifier ? */ - if(arg1[0] == '-') - { - argend = strchr(arg1, ';'); - - - } - else /* Must be a pass specifier or modifier */ - { - - } -} @@ -724,8 +724,16 @@ PUBLIC void stringorcharconst() if (ch == terminator) { *charptr++ = terminator; - gch1(); - break; + + /* This adds ansi string concatenation BUT only on one line */ + do { gch1(); } while(SYMOFCHAR(ch) == WHITESPACE); + if( ch == terminator ) /* Hang on .. that's another string ... */ + { + charptr--; /* Stick it together */ + gch1(); + } + else + break; } } } diff --git a/bcc/state.c b/bcc/state.c index 36140c2..1d0dd04 100644 --- a/bcc/state.c +++ b/bcc/state.c @@ -342,7 +342,7 @@ PRIVATE void docont() #ifdef MC6809 outcregname(LOCAL); #endif -#ifdef I8088 +#ifdef I80386 if (i386_32) bumplc2(); #endif @@ -669,9 +669,11 @@ offset_t offset; outswstacklab(); #ifdef I8088 bumplc(); +#ifdef I80386 if (i386_32) bumplc2(); #endif +#endif } PUBLIC void outswstacklab() diff --git a/bcc/table.c b/bcc/table.c index e2580da..7f4a1ac 100644 --- a/bcc/table.c +++ b/bcc/table.c @@ -25,10 +25,18 @@ #define GOLDEN 157 /* GOLDEN/HASHTABSIZE approx golden ratio */ #define HASHTABSIZE 256 #define MARKER ((unsigned) 0x18C396A5L) /* lint everywhere it is used */ +#ifdef __AS386_16__ +#define MAXEXPR 125 +#else #define MAXEXPR 500 +#endif #define MAXLOCAL 100 #define NKEYWORDS 35 +#ifdef NOFLOAT +#define NSCALTYPES 10 +#else #define NSCALTYPES 12 +#endif #define STACKSPACE 256 /* punt for normal recursions - switch extra */ struct keywordstruct @@ -134,8 +142,10 @@ PRIVATE struct typedatastruct scaltypes[NSCALTYPES] = { "int", FALSE, UNSIGNED | INT, 2, &uitype, }, { "long", TRUE, LONG | DLONG, 4, <ype, }, { "long", FALSE, UNSIGNED | LONG | DLONG, 4, &ultype, }, +#ifndef NOFLOAT { "float", TRUE, FLOAT, 4, &fltype, }, { "double", TRUE, DOUBLE, 8, &dtype, }, +#endif }; FORWARD struct symstruct *addkeyword P((char *name, sym_pt code)); @@ -419,7 +429,11 @@ struct symstruct *symptr; newsymptr = exprptr++; if (exprptr >= &exprsyms[MAXEXPR]) +#if MAXEXPR == 500 limiterror("expression too complex (501 symbols)"); +#else + limiterror("expression too complex (MAXEXPR)"); +#endif *newsymptr = *symptr; newsymptr->level = EXPRLEVEL; newsymptr->name.namep = symptr->name.namea; @@ -179,7 +179,7 @@ struct typestruct *type; PUBLIC void typeinit() { -#ifdef I8088 +#ifdef I80386 if (i386_32) { uitype->typesize = diff --git a/elksemu/Makefile b/elksemu/Makefile index 92aa516..2044160 100644 --- a/elksemu/Makefile +++ b/elksemu/Makefile @@ -2,7 +2,7 @@ # Makefile for elksemu. # -CFLAGS=-O2 -fno-strength-reduce -Wall +CFLAGS=-O2 -fno-strength-reduce -Wall -idirafter . $(DEFS) # If you need an a.out exe. NB The program _does_ now work as ELF # CFLAGS=-O2 -fno-strength-reduce -b i486-linuxaout -N -s -static @@ -32,12 +32,16 @@ module: binfmt_elks.o # HOW to compile the module... -# This matches my compile; yours may be different. +# This matches my compile (2.0.0); yours may be different. +MODCFLAGS=-D__KERNEL__ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \ + -fno-strength-reduce -pipe -m486 -DCPU=486 -DMODULE -DMODVERSIONS \ + -include /usr/include/linux/modversions.h + binfmt_elks.o: binfmt_elks.c - gcc -O -c -fomit-frame-pointer -DCPU=386 -D__KERNEL__ -DMODULE -DMODVERSIONS -include /usr/include/linux/modversions.h binfmt_elks.c + gcc -c $(MODCFLAGS) binfmt_elks.c # This is another option -# gcc -O -c -fomit-frame-pointer -DCPU=386 -D__KERNEL__ -DMODULE binfmt_elks.c +#MODCFLAGS=-O -fomit-frame-pointer -DCPU=386 -D__KERNEL__ -DMODULE # Or this ... -# gcc -O -c -fomit-frame-pointer -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS binfmt_elks.c +#MODCFLAGS=-O -fomit-frame-pointer -D__KERNEL__ -DMODULE -DCONFIG_MODVERSIONS diff --git a/elksemu/V-files.tar b/elksemu/V-files.tar Binary files differindex 3e1227c..93e529d 100644 --- a/elksemu/V-files.tar +++ b/elksemu/V-files.tar diff --git a/elksemu/binfmt_elks.c b/elksemu/binfmt_elks.c index 09e5a29..9c1ecd4 100644 --- a/elksemu/binfmt_elks.c +++ b/elksemu/binfmt_elks.c @@ -104,7 +104,6 @@ int init_elksaout_binfmt(void) { #ifdef MODULE #if LINUX_VERSION_CODE < 0x010300 -#include <linux/version.h> char kernel_version[] = UTS_RELEASE; #endif int init_module(void) diff --git a/elksemu/elks.c b/elksemu/elks.c index 10d9d78..652b559 100644 --- a/elksemu/elks.c +++ b/elksemu/elks.c @@ -208,10 +208,13 @@ void main(int argc, char *argv[], char *envp[]) } /* This uses the _real_ user ID If the file is exec only that's */ /* ok cause the suid root will override. */ + /* BTW, be careful here, security problems are possible because of + * races if you change this. */ if( access(argv[1], X_OK) < 0 - || stat(argv[1], &st) < 0 - || (fd=open(argv[1], O_RDONLY)) < 0) + || (fd=open(argv[1], O_RDONLY)) < 0 + || fstat(fd, &st) < 0 + ) { perror(argv[1]); exit(1); diff --git a/elksemu/elks_sys.c b/elksemu/elks_sys.c index 586ee9b..c16dc53 100644 --- a/elksemu/elks_sys.c +++ b/elksemu/elks_sys.c @@ -352,10 +352,12 @@ static int elks_times(int bx,int cx,int dx,int di,int si) struct tms t; long clock_ticks=times(&t); long *tp=ELKS_PTR(long, bx); + long *clkt=ELKS_PTR(long, cx); *tp++=t.tms_utime; *tp++=t.tms_stime; *tp++=t.tms_cutime; *tp=t.tms_cstime; + *clkt = clock_ticks; return 0; /* Should be clock_ticks */ } @@ -676,6 +678,9 @@ static int elks_termios(int bx,int cx,int dx,int di,int si) case 0x0A: rv = ioctl(bx, TCXONC, dx); break; case 0x0B: rv = ioctl(bx, TCFLSH, dx); break; + case 0x11: rv = ioctl(bx, TIOCOUTQ, ELKS_PTR(void, dx)); break; + case 0x1B: rv = ioctl(bx, TIOCINQ, ELKS_PTR(void, dx)); break; + default: rv = -1; errno = EINVAL; break; } return rv; diff --git a/elksemu/linux/vm86.h b/elksemu/linux/vm86.h new file mode 100644 index 0000000..c099980 --- /dev/null +++ b/elksemu/linux/vm86.h @@ -0,0 +1,8 @@ +/* + * Since 1.3.99 vm86.h has moved from it's original position, this file + * redirects sys/vm86.h to the correct location if it hasn't been updated + * yet. + * + * Use "-idirafter . " on the command line. + */ +#include <asm/vm86.h> diff --git a/ld/Makefile b/ld/Makefile index d93579a..784763a 100644 --- a/ld/Makefile +++ b/ld/Makefile @@ -1,6 +1,8 @@ ifneq ($(TOPDIR),) include $(TOPDIR)/Make.defs + +# CFLAGS=$(CCFLAGS) -DBSD_A_OUT else CC=bcc LDFLAGS=-s diff --git a/ld/a_out.h b/ld/a_out.h deleted file mode 120000 index 9238685..0000000 --- a/ld/a_out.h +++ /dev/null @@ -1 +0,0 @@ -a.out.h
\ No newline at end of file @@ -5,6 +5,16 @@ #ifndef S_ALIGNMENT # define align(x) #else -# define align(x) ((x) = ((int) (x) + (S_ALIGNMENT-1)) & ~(S_ALIGNMENT-1)) - /* assumes sizeof(int) == sizeof(char *) */ +# define align(x) ((x)=(void*) \ + ((char *)(x) + ((S_ALIGNMENT-(int)(x)) & (S_ALIGNMENT-1)))) #endif + + + + + + +/* * assumes sizeof(int) == sizeof(char *) * +# define align(x) ((x) = (void *)(((int) (x) + (S_ALIGNMENT-1)) & ~(S_ALIGNMENT-1))) +*/ + diff --git a/ld/config.h b/ld/config.h index 201c153..1629ba3 100644 --- a/ld/config.h +++ b/ld/config.h @@ -17,10 +17,12 @@ #undef HOST_8BIT /* enable some 8-bit optimizations */ -/* #define S_ALIGNMENT 4 */ /* source memory alignment, power of 2 */ +#ifndef __BCC__ +#define S_ALIGNMENT 4 /* source memory alignment, power of 2 */ /* don't use for 8 bit processors */ /* don't use even for 80386 - overhead for */ /* alignment cancels improved access */ +#endif /* these must be defined to suit the source libraries */ @@ -2,41 +2,11 @@ /* Copyright (C) 1994 Bruce Evans */ +#include "syshead.h" #include "const.h" -#include "obj.h" /* needed for LONG_OFFSETS and offset_t */ +#include "obj.h" /* needed for LONG_OFFSETS and bin_off_t */ #include "type.h" #include "globvar.h" -#include <fcntl.h> - -#ifdef STDC_HEADERS_MISSING -void exit P((int status)); -void *malloc P((unsigned size)); -#else -#include <stdlib.h> -#endif - -#ifdef POSIX_HEADERS_MISSING -#define SEEK_SET 0 -#define STDOUT_FILENO 0 -#include <sys/types.h> -#include <sys/stat.h> -#define mode_t unsigned short -#define off_t long -int chmod P((const char *path, int mode)); -int close P((int fd)); -int creat P((const char *path, int mode)); -int fstat P((int fd, struct stat *statbuf)); -off_t lseek P((int fd, off_t offset, int whence)); -int open P((const char *path, int oflag, ...)); -int read P((int fd, void *buf, unsigned nbytes)); -mode_t umask P((int oldmask)); -int write P((int fd, const void *buf, unsigned nbytes)); -#else -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#endif #define DRELBUFSIZE 3072 #define ERR (-1) @@ -44,9 +14,6 @@ int write P((int fd, const void *buf, unsigned nbytes)); #define INBUFSIZE 1024 #define OUTBUFSIZE 2048 #define TRELBUFSIZE 1024 -#ifndef O_BINARY -#define O_BINARY 0 -#endif #ifdef BSD_A_OUT PRIVATE char *drelbuf; /* extra output buffer for data relocations */ @@ -81,7 +48,7 @@ FORWARD void flushout P((void)); #ifdef BSD_A_OUT FORWARD void flushtrel P((void)); #endif -FORWARD void outhexdigs P((offset_t num)); +FORWARD void outhexdigs P((bin_off_t num)); FORWARD void outputerror P((char *message)); FORWARD void put04x P((unsigned num)); FORWARD void putstrn P((char *message)); @@ -228,7 +195,7 @@ char *filename; } PRIVATE void outhexdigs(num) -register offset_t num; +register bin_off_t num; { if (num >= 0x10) { @@ -250,7 +217,7 @@ register unsigned num; #ifdef LONG_OFFSETS PUBLIC void put08lx(num) -register offset_t num; +register bin_off_t num; { put04x(num / 0x10000); put04x(num % 0x10000); @@ -259,7 +226,7 @@ register offset_t num; #else /* not LONG_OFFSETS */ PUBLIC void put08x(num) -register offset_t num; +register bin_off_t num; { putstr("0000"); put04x(num); @@ -562,12 +529,12 @@ char *name; PUBLIC void size_error(seg, count, size) int seg; -offset_t count; -offset_t size; +bin_off_t count; +bin_off_t size; { refer(); putstr("seg "); - outhexdigs((offset_t) seg); + outhexdigs((bin_off_t) seg); putstr(" has wrong size "); outhexdigs(count); putstr(", supposed to be "); @@ -2,28 +2,12 @@ /* Copyright (C) 1994 Bruce Evans */ +#include "syshead.h" #include "const.h" #include "byteord.h" #include "type.h" #include "globvar.h" -#ifdef STDC_HEADERS_MISSING -extern int errno; -char *strcat P((char *dest, const char *src)); -unsigned long strtoul P((const char *s, char **endptr, int base)); -#else -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#endif - -#ifdef POSIX_HEADERS_MISSING -#define R_OK 0 -int access P((const char *path, int amode)); -#else -#include <unistd.h> -#endif - #define MAX_LIBS (NR_STDLIBS + 5) #ifdef MC6809 #define NR_STDLIBS 1 @@ -31,9 +31,9 @@ #endif #ifdef MC6809 /* temp don't support alignment at all */ -# define roundup( num, boundary, type ) (num) +# define ld_roundup( num, boundary, type ) (num) #else -# define roundup( num, boundary, type ) \ +# define ld_roundup( num, boundary, type ) \ (((num) + ((boundary) - 1)) & (type) ~((boundary) - 1)) #endif diff --git a/ld/readobj.c b/ld/readobj.c index bb6a6b5..eb5e0e3 100644 --- a/ld/readobj.c +++ b/ld/readobj.c @@ -2,6 +2,7 @@ /* Copyright (C) 1994 Bruce Evans */ +#include "syshead.h" #include "ar.h" /* maybe local copy of <ar.h> for cross-link */ #include "const.h" #include "byteord.h" @@ -9,15 +10,6 @@ #include "type.h" #include "globvar.h" -#ifdef STDC_HEADERS_MISSING -int strncmp P((const char *s1, const char *s2, unsigned n)); -char *strncpy P((char *dest, const char *src, unsigned n)); -unsigned long strtoul P((const char *s, char **endptr, int base)); -#else -#include <stdlib.h> -#include <string.h> -#endif - /* Linking takes 2 passes. The 1st pass reads through all files specified in the command line, and all libraries. All public symbols are extracted @@ -42,7 +34,7 @@ FORWARD long readarheader P((char **parchentry)); FORWARD unsigned readfileheader P((void)); FORWARD void readmodule P((char *filename, char *archentry)); FORWARD void reedmodheader P((void)); -FORWARD bool_pt redsym P((struct symstruct *symptr, offset_t value)); +FORWARD bool_pt redsym P((struct symstruct *symptr, bin_off_t value)); FORWARD unsigned checksum P((char *string, unsigned length)); FORWARD unsigned segbits P((unsigned seg, char *sizedesc)); @@ -93,7 +85,7 @@ bool_pt trace; readmodule(stralloc(filename), archentry); modlast->textoffset += filepos; } - seekin(filepos += roundup(filelength, 2, long)); + seekin(filepos += ld_roundup(filelength, 2, long)); } break; } @@ -147,7 +139,7 @@ char *archentry; { struct symdstruct /* to save parts of symbol before name known */ { - offset_t dvalue; + bin_off_t dvalue; flags_t dflags; }; struct symdstruct *endsymdptr; @@ -289,7 +281,7 @@ PRIVATE void reedmodheader() PRIVATE bool_pt redsym(symptr, value) register struct symstruct *symptr; -offset_t value; +bin_off_t value; { register struct redlist *rlptr; char class; @@ -340,13 +332,13 @@ unsigned length; return sum; } -PUBLIC offset_t readconvsize(countindex) +PUBLIC bin_off_t readconvsize(countindex) unsigned countindex; { return readsize(convertsize[countindex]); } -PUBLIC offset_t readsize(count) +PUBLIC bin_off_t readsize(count) unsigned count; { char buf[MAX_OFFSET_SIZE]; diff --git a/ld/syshead.h b/ld/syshead.h new file mode 100644 index 0000000..33f1123 --- /dev/null +++ b/ld/syshead.h @@ -0,0 +1,121 @@ + +#ifndef STDC_HEADERS_MISSING +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#endif + +#ifndef POSIX_HEADERS_MISSING +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#endif + +#ifdef MSDOS +#undef POSIX_HEADERS_MISSING + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#define A_OUT_INCL "a_out.h" +#undef min +#define R_OK 0 +#define mode_t unsigned short +#define SEEK_SET 0 +#define STDOUT_FILENO 0 +#endif + +#ifndef A_OUT_INCL +#define A_OUT_INCL "a.out.h" +#endif + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +/******************************************************************************/ + +/* EEEEyuk!! */ + +#ifdef __STDC__ +#define P(x) x +#else +#define P(x) () +#endif + +#ifdef STDC_HEADERS_MISSING +extern int errno; +char *strcat P((char *dest, const char *src)); +unsigned long strtoul P((const char *s, char **endptr, int base)); +void exit P((int status)); +void *malloc P((unsigned size)); +int strncmp P((const char *s1, const char *s2, unsigned n)); +char *strncpy P((char *dest, const char *src, unsigned n)); +char * strcpy P((char* dest, char* src)); +void *memset P((void *s, int c, unsigned n)); +#endif + +#ifdef POSIX_HEADERS_MISSING +#include <sys/types.h> +#include <sys/stat.h> + +#define R_OK 0 +int access P((const char *path, int amode)); +#define SEEK_SET 0 +#define STDOUT_FILENO 0 + +#define mode_t unsigned short +#define off_t long + +int chmod P((const char *path, int mode)); +int close P((int fd)); +int creat P((const char *path, int mode)); +int fstat P((int fd, struct stat *statbuf)); +off_t lseek P((int fd, off_t offset, int whence)); +int open P((const char *path, int oflag, ...)); +int read P((int fd, void *buf, unsigned nbytes)); +mode_t umask P((int oldmask)); +int write P((int fd, const void *buf, unsigned nbytes)); +#endif + +#ifndef A_OUT_INCL +# ifdef BSD_A_OUT +# ifdef STANDARD_GNU_A_OUT +# define A_OUT_INCL <a.out.h> +# 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 +# endif /* BSD_A_OUT */ +#endif + +# ifdef BSD_A_OUT +# ifdef STANDARD_GNU_A_OUT +# define RELOC_INFO_SIZE 8 /* unportable bitfields - bcc doesn't pack */ +# else +# define RELOC_INFO_SIZE (sizeof (struct relocation_info)) +# endif +# define C_EXT N_EXT +# define C_STAT 0 +# define n_was_name n_un.n_name +# define n_was_numaux n_other +# define n_was_other n_numaux +# define n_was_sclass n_type +# define n_was_strx n_un.n_strx +# define n_was_type n_desc +# else /* not BSD_A_OUT */ +# define n_was_name n_name +# define n_was_numaux n_numaux +# define n_was_other n_other +# define n_was_sclass n_sclass +# define n_was_strx n_value +# define n_was_type n_type +# endif /* BSD_A_OUT */ + @@ -2,20 +2,13 @@ /* Copyright (C) 1994 Bruce Evans */ +#include "syshead.h" #include "const.h" #include "align.h" #include "obj.h" #include "type.h" #include "globvar.h" -#ifdef STDC_HEADERS_MISSING -void *malloc P((unsigned size)); -char * strcpy P((char* dest, char* src)); -#else -#include <stdlib.h> -#include <string.h> -#endif - #define GOLDEN 157 /* GOLDEN/HASHTABSIZE approx golden ratio */ #define HASHTABSIZE 256 @@ -22,9 +22,9 @@ typedef int fastin_pt; typedef unsigned flags_t; /* unsigned makes shifts logical */ #ifdef LONG_OFFSETS -typedef unsigned long offset_t; +typedef unsigned long bin_off_t; #else -typedef unsigned offset_t; +typedef unsigned bin_off_t; #endif struct entrylist /* list of entry symbols */ @@ -55,13 +55,13 @@ struct redlist /* list of redefined (exported) symbols */ struct redlist *rlnext; /* next on list */ struct symstruct *rlsymptr; /* to symbol with same name, flags */ struct modstruct *rlmodptr; /* module for this redefinition */ - offset_t rlvalue; /* value for this redefinition */ + bin_off_t rlvalue; /* value for this redefinition */ }; struct symstruct /* symbol table entry format */ { struct modstruct *modptr; /* module where symbol is defined */ - offset_t value; /* value of symbol */ + bin_off_t value; /* value of symbol */ flags_t flags; /* see below (unsigned makes shifts logical) */ struct symstruct *next; /* next symbol with same hash value */ char name[1]; /* name is any string beginning here */ @@ -71,11 +71,13 @@ struct symstruct /* symbol table entry format */ /* prototypes */ +#ifndef P #ifdef __STDC__ #define P(x) x #else #define P(x) () #endif +#endif /* dump.c */ void dumpmods P((void)); @@ -92,8 +94,8 @@ void openin P((char *filename)); void openout P((char *filename)); void putstr P((char *message)); #ifdef OBJ_H -void put08x P((offset_t num)); -void put08lx P((offset_t num)); +void put08x P((bin_off_t num)); +void put08lx P((bin_off_t num)); #endif void putbstr P((unsigned width, char *str)); void putbyte P((int ch)); @@ -116,7 +118,7 @@ void redefined P((char *name, char *message, char *archentry, char *deffilename, char *defarchentry)); void reserved P((char *name)); #ifdef OBJ_H -void size_error P((int seg, offset_t count, offset_t size)); +void size_error P((int seg, bin_off_t count, bin_off_t size)); #endif void undefined P((char *name)); void usage P((void)); @@ -130,8 +132,8 @@ void objinit P((void)); void readsyms P((char *filename, bool_pt trace)); #ifdef OBJ_H void entrysym P((struct symstruct *symptr)); -offset_t readconvsize P((unsigned countindex)); -offset_t readsize P((unsigned count)); +bin_off_t readconvsize P((unsigned countindex)); +bin_off_t readsize P((unsigned count)); unsigned segsizecount P((unsigned seg, struct modstruct *modptr)); #endif diff --git a/ld/writebin.c b/ld/writebin.c index 3e7602d..fd3a3b9 100644 --- a/ld/writebin.c +++ b/ld/writebin.c @@ -7,52 +7,14 @@ static long bdataoffset; /* Copyright (C) 1994 Bruce Evans */ -#ifdef A_OUT_H -# include A_OUT_H -#else -# ifdef BSD_A_OUT -# ifdef STANDARD_GNU_A_OUT -# include <a.out.h> -# define RELOC_INFO_SIZE 8 /* unportable bitfields - bcc doesn't pack */ -# else -# include "bsd-a.out.h" -# define RELOC_INFO_SIZE (sizeof (struct relocation_info)) -# endif -# define C_EXT N_EXT -# define C_STAT 0 -# define n_was_name n_un.n_name -# define n_was_numaux n_other -# define n_was_other n_numaux -# define n_was_sclass n_type -# define n_was_strx n_un.n_strx -# define n_was_type n_desc -# else /* not BSD_A_OUT */ -# ifdef MSDOS -# include "a_out.h" -# else -# include "a.out.h" /* maybe local copy of <a.out.h> for X-link */ -# endif -# define n_was_name n_name -# define n_was_numaux n_numaux -# define n_was_other n_other -# define n_was_sclass n_sclass -# define n_was_strx n_value -# define n_was_type n_type -# endif /* BSD_A_OUT */ -#endif - +#include "syshead.h" +#include A_OUT_INCL #include "const.h" #include "obj.h" #include "type.h" #undef EXTERN #include "globvar.h" -#ifdef STDC_HEADERS_MISSING -void *memset P((void *s, int c, unsigned n)); -#else -#include <string.h> -#endif - #ifdef EDOS # define FILEHEADERLENGTH 0 #endif @@ -95,13 +57,13 @@ void *memset P((void *s, int c, unsigned n)); #define memsizeof(struc, mem) sizeof(((struc *) 0)->mem) PRIVATE bool_t bits32; /* nonzero for 32-bit executable */ -PRIVATE offset_t combase[NSEG]; /* bases of common parts of segments */ -PRIVATE offset_t comsz[NSEG]; /* sizes of common parts of segments */ +PRIVATE bin_off_t combase[NSEG];/* bases of common parts of segments */ +PRIVATE bin_off_t comsz[NSEG]; /* sizes of common parts of segments */ PRIVATE fastin_t curseg; /* current segment, 0 to $F */ -PRIVATE offset_t edataoffset; /* end of data */ -PRIVATE offset_t endoffset; /* end of bss */ -PRIVATE offset_t etextoffset; /* end of text */ -PRIVATE offset_t etextpadoff; /* end of padded text */ +PRIVATE bin_off_t edataoffset; /* end of data */ +PRIVATE bin_off_t endoffset; /* end of bss */ +PRIVATE bin_off_t etextoffset; /* end of text */ +PRIVATE bin_off_t etextpadoff; /* end of padded text */ #ifdef BSD_A_OUT PRIVATE unsigned ndreloc; /* number of data relocations */ #endif @@ -111,17 +73,17 @@ PRIVATE unsigned ntreloc; /* number of text relocations */ PRIVATE bool_t reloc_output; /* nonzero to leave reloc info in output */ #endif PRIVATE unsigned relocsize; /* current relocation size 1, 2 or 4 */ -PRIVATE offset_t segadj[NSEG]; /* adjusts (file offset - seg offset) */ +PRIVATE bin_off_t segadj[NSEG]; /* adjusts (file offset - seg offset) */ /* depends on zero init */ -PRIVATE offset_t segbase[NSEG]; /* bases of data parts of segments */ +PRIVATE bin_off_t segbase[NSEG];/* bases of data parts of segments */ PRIVATE char segboundary[9] = "__seg0DH"; /* name of seg boundary __seg0DL to __segfCH */ -PRIVATE offset_t segpos[NSEG]; /* segment positions for current module */ -PRIVATE offset_t segsz[NSEG]; /* sizes of data parts of segments */ +PRIVATE bin_off_t segpos[NSEG]; /* segment positions for current module */ +PRIVATE bin_off_t segsz[NSEG]; /* sizes of data parts of segments */ /* depends on zero init */ PRIVATE bool_t sepid; /* nonzero for separate I & D */ PRIVATE bool_t stripflag; /* nonzero to strip symbols */ -PRIVATE offset_t spos; /* position in current seg */ +PRIVATE bin_off_t spos; /* position in current seg */ PRIVATE bool_t uzp; /* nonzero for unmapped zero page */ #ifdef EDOS @@ -131,7 +93,7 @@ FORWARD char *idconvert P((struct entrylist *elptr, char *commandname)); FORWARD void linkmod P((struct modstruct *modptr)); FORWARD void linkrefs P((struct modstruct *modptr)); FORWARD void padmod P((struct modstruct *modptr)); -FORWARD void setsym P((char *name, offset_t value)); +FORWARD void setsym P((char *name, bin_off_t value)); FORWARD void symres P((char *name)); FORWARD void setseg P((fastin_pt newseg)); FORWARD void skip P((unsigned countsize)); @@ -140,7 +102,7 @@ FORWARD void writeheader P((char *commandname)); #else FORWARD void writeheader P((void)); #endif -FORWARD void writenulls P((offset_t count)); +FORWARD void writenulls P((bin_off_t count)); extern int doscomfile; @@ -219,7 +181,7 @@ bool_pt arguzp; struct modstruct *modptr; fastin_t seg; unsigned sizecount; - offset_t tempoffset; + bin_off_t tempoffset; sepid = argsepid; bits32 = argbits32; @@ -305,7 +267,7 @@ bool_pt arguzp; #endif #endif { - tempoffset = roundup(symptr->value, 4, offset_t); + tempoffset = ld_roundup(symptr->value, 4, bin_off_t); /* temp kludge quad alignment for 386 */ symptr->value = comsz[seg = symptr->flags & SEGM_MASK]; comsz[seg] += tempoffset; @@ -322,8 +284,8 @@ bool_pt arguzp; /* adjust sizes to even to get quad boundaries */ /* this should be specifiable dynamically */ - segsz[seg] = roundup(segsz[seg], 4, offset_t); - comsz[seg] = roundup(comsz[seg], 4, offset_t); + segsz[seg] = ld_roundup(segsz[seg], 4, bin_off_t); + comsz[seg] = ld_roundup(comsz[seg], 4, bin_off_t); #endif cptr += sizecount; } @@ -342,7 +304,7 @@ bool_pt arguzp; etextpadoff = etextoffset = combase[0] + comsz[0]; if (sepid) { - etextpadoff = roundup(etextoffset, 0x10, offset_t); + etextpadoff = ld_roundup(etextoffset, 0x10, bin_off_t); segadj[1] += etextpadoff - bdataoffset; } else if (bdataoffset == 0) @@ -360,9 +322,9 @@ bool_pt arguzp; if (tempoffset > 0x100) fatalerror("direct page segment too large"); if ((((segbase[seg] + tempoffset) ^ segbase[seg]) - & ~(offset_t) 0xFF) != 0) + & ~(bin_off_t) 0xFF) != 0) segpos[seg] = segbase[seg] = (segbase[seg] + 0xFF) - & ~(offset_t) 0xFF; + & ~(bin_off_t) 0xFF; } combase[seg] = segbase[seg] + segsz[seg]; segadj[seg] = segadj[seg - 1]; @@ -420,7 +382,14 @@ bool_pt arguzp; setsym("__etext", etextoffset); setsym("__edata", edataoffset); setsym("__end", endoffset = combase[NSEG - 1] + comsz[NSEG - 1]); - setsym("__segoff", (offset_t)(segadj[1]-segadj[0])/0x10); + setsym("__segoff", (bin_off_t)(segadj[1]-segadj[0])/0x10); + if( !bits32 ) + { + if( etextoffset > 65535L ) + fatalerror("text segment too large for 16bit"); + if( endoffset > 65535L ) + fatalerror("data segment too large for 16bit"); + } openout(outfilename); #ifdef BSD_A_OUT @@ -472,7 +441,7 @@ bool_pt arguzp; { #ifdef BSD_A_OUT offtocn((char *) &extsym.n_was_strx, - (offset_t) stringoff, 4); + (bin_off_t) stringoff, 4); #else strncpy((char *) extsym.n_was_name, symptr->name, sizeof extsym.n_was_name); @@ -511,7 +480,7 @@ bool_pt arguzp; } } #ifdef BSD_A_OUT - offtocn((char *) &extsym.n_was_strx, (offset_t) stringoff, 4); + offtocn((char *) &extsym.n_was_strx, (bin_off_t) stringoff, 4); writeout((char *) &extsym.n_was_strx, 4); for (modptr = modfirst; modptr != NUL_PTR; modptr = modptr->modnext) if (modptr->loadflag) @@ -615,7 +584,7 @@ struct modstruct *modptr; char buf[ABS_TEXT_MAX]; int command; unsigned char modify; - offset_t offset; + bin_off_t offset; int symbolnum; struct symstruct **symparray; struct symstruct *symptr; @@ -787,9 +756,9 @@ struct modstruct *modptr; PRIVATE void padmod(modptr) struct modstruct *modptr; { - offset_t count; + bin_off_t count; fastin_t seg; - offset_t size; + bin_off_t size; unsigned sizecount; char *sizeptr; @@ -803,7 +772,7 @@ struct modstruct *modptr; /* pad to quad boundary */ /* not padding in-between common areas which sometimes get into file */ - if ((size = roundup(segpos[seg], 4, offset_t) - segpos[seg]) != 0) + if ((size = ld_roundup(segpos[seg], 4, bin_off_t) - segpos[seg]) != 0) { setseg(seg); writenulls(size); @@ -815,7 +784,7 @@ struct modstruct *modptr; PRIVATE void setsym(name, value) char *name; -offset_t value; +bin_off_t value; { struct symstruct *symptr; @@ -861,7 +830,7 @@ fastin_pt newseg; PRIVATE void skip(countsize) unsigned countsize; { - writenulls((offset_t) readsize(countsize)); + writenulls((bin_off_t) readsize(countsize)); } #ifdef EDOS @@ -870,7 +839,7 @@ PRIVATE void writeheader(commandname) char *commandname; { char buf[MAX_OFFSET_SIZE]; - offset_t offset; + bin_off_t offset; unsigned headlength; char *name; struct entrylist *elptr; @@ -977,7 +946,7 @@ PRIVATE void writeheader() offtocn((char *) &header.a_entry, page_size(), sizeof header.a_entry); #ifndef STANDARD_GNU_A_OUT - offtocn((char *) &header.a_total, (offset_t) + offtocn((char *) &header.a_total, (bin_off_t) (endoffset < 0x00010000L ? 0x00010000L : endoffset + 0x0008000L), sizeof header.a_total); #endif @@ -989,9 +958,12 @@ PRIVATE void writeheader() #endif /* MINIX */ PRIVATE void writenulls(count) -offset_t count; +bin_off_t count; { + long lcount = count; + if( lcount < 0 ) + fatalerror("org command requires reverse seek"); spos += count; - while (count--) + while (count-- > 0) writechar(0); } diff --git a/libbsd/libbsd.a b/libbsd/libbsd.a Binary files differindex c592908..36a9f62 100644 --- a/libbsd/libbsd.a +++ b/libbsd/libbsd.a @@ -8,16 +8,16 @@ Useful bits for /etc/magic: # text if readable, executable if runnable binary, data if unreadable. # 0 string \01\03\020\04 Linux-8086 impure executable ->16 long !0 not stripped +>28 long !0 not stripped 0 string \01\03\040\04 Linux-8086 executable ->16 long !0 not stripped +>28 long !0 not stripped # 0 string \243\206\001\0 Linux-8086 object file # There is _no_ difference between 16 and 32 bit .o files # 0 string \01\03\020\20 Minix-386 impure executable ->16 long !0 not stripped +>28 long !0 not stripped 0 string \01\03\040\20 Minix-386 executable ->16 long !0 not stripped +>28 long !0 not stripped # #------------------------------------------------------------------------------ diff --git a/libc/Make.defs b/libc/Make.defs index 1cf9b30..6744899 100644 --- a/libc/Make.defs +++ b/libc/Make.defs @@ -18,7 +18,7 @@ endif VERMAJOR=0 VERMINOR=0 -VERPATCH=6 +VERPATCH=7 VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH) LIBDEFS=-D__LIBC__ diff --git a/libc/Makefile b/libc/Makefile index 0076f8b..a88ffb2 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -9,7 +9,7 @@ SRC=crt0.c OBJ=crt0.o TARGETS=$(OBJ) $(LIBC) -TXT=Makefile Make.defs README TODO KERNEL COPYING Contributors MAGIC \ +TXT=Makefile Make.defs README KERNEL COPYING Contributors MAGIC \ New_subdir Pre_main Config_sh all: .config.lst $(TARGETS) diff --git a/libc/New_subdir b/libc/New_subdir index 92f523d..a28a5ec 100755 --- a/libc/New_subdir +++ b/libc/New_subdir @@ -36,7 +36,7 @@ OBJ=$1.o all: \$(OBJ) libc.a: \$(OBJ) - ar r ../$(LIBC) \$(OBJ) + ar r ../\$(LIBC) \$(OBJ) @touch libc.a clean: diff --git a/libc/TODO b/libc/TODO deleted file mode 100644 index f6baaa0..0000000 --- a/libc/TODO +++ /dev/null @@ -1,48 +0,0 @@ -Here's a short list of bits that are required. If you want to do one of -these it's probably best to post to the list <linux-8086@vger.rutgers.edu>. - -Add more to this todo list! - - -TODO for libc-8086: -Item Notes ---------------------------------------------------------------------------- -Header Files - This will take some time, also some files should - be kernel. -Floating Point - Bruce is on this (Yes that one) Initially it'll - assume an FPU is available. "int" version soon - after. -dirent &co - Directory listing - Partial. -hsearch &co - -tsearch &co - -locale processing - multi national, unicode (string stuff has a couple - of stubs) -rpc - -time calcs - mktime gmtime localtime etc, Nat -timezone - Probably V simplistic, List of UTC's - offsets & STDvDST -i386 support - For both GCC and BCC-386. - -shadow password - Do we need ? Do we want :-) [No! Ick! ;) -Nat] -curses - What does ncurses need ? (150kb!!) -crypt - TEA version, first cut. -signal stuff - Got a basic 'signal' appears to work correctly. -getenv/setenv - Done -bsearch - Grabbed (Public Domain) -lsearch - Grabbed (Public Domain) -random numbers - Got ZX81 version (better than some) (And 2nd now) -Build environment - Good first cut is now available. - -Other projects: -Project Notes ---------------------------------------------------------------------------- -Optimiser for BCC - A lot of work, but lucrative. - (assembler level one started, by?) -Tiny vi editor - Use 'ae' ? -Shells: Bourne, Csh, -menu, silly - ash now compiles, Rob. -Tiny Perl - :-) :-) You first ;) -User commands - Everything in /bin /usr/bin - will existing PD/GPL - compile in 16 bit ? Or do smaller ones exist, - need to be written ? - diff --git a/libc/bcc/ldiv.c b/libc/bcc/ldiv.c new file mode 100644 index 0000000..6bfef0a --- /dev/null +++ b/libc/bcc/ldiv.c @@ -0,0 +1,27 @@ +#asm +.text +export _ldiv +_ldiv: + push bp + mov bp,sp + push di + push si + mov ax,[bp+6] + mov bx,[bp+8] + mov cx,[bp+10] + mov di,[bp+12] + call ldivmod + mov si,[bp+4] + mov [si],cx + mov [si+2],di + mov [si+4],ax + mov [si+6],bx + mov ax,si + pop si + pop di + pop bp + ret +.data +.bss +#endasm + diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index f67984a..7831424 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -25,6 +25,22 @@ extern void srand __P ((unsigned int seed)); extern long strtol __P ((const char * nptr, char ** endptr, int base)); extern unsigned long strtoul __P ((const char * nptr, char ** endptr, int base)); +#ifndef __HAS_NO_FLOATS__ extern double strtod __P ((const char * nptr, char ** endptr)); +#endif + +/* Returned by `div'. */ +typedef struct + { + int quot; /* Quotient. */ + int rem; /* Remainder. */ + } div_t; + +/* Returned by `ldiv'. */ +typedef struct + { + long int quot; /* Quotient. */ + long int rem; /* Remainder. */ + } ldiv_t; #endif /* __STDLIB_H */ diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h index 366b0c6..0afc883 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -18,7 +18,10 @@ typedef long double __long_double_t; #define __STRING(x) "x" #define __ptr_t char * + +#ifndef __HAS_NO_FLOATS__ typedef double __long_double_t; +#endif #endif diff --git a/libc/include/sys/times.h b/libc/include/sys/times.h new file mode 100644 index 0000000..b6defa8 --- /dev/null +++ b/libc/include/sys/times.h @@ -0,0 +1,21 @@ +#ifndef _SYS_TIMES_H +#define _SYS_TIMES_H + +#include <features.h> +#include <sys/types.h> +#include <time.h> + +struct tms { + clock_t tms_utime; + clock_t tms_stime; + clock_t tms_cutime; + clock_t tms_cstime; +}; + +__BEGIN_DECLS + +extern clock_t times __P ((struct tms * __tp)); + +__END_DECLS + +#endif diff --git a/libc/include/time.h b/libc/include/time.h index b9eb87c..30ae4bc 100644 --- a/libc/include/time.h +++ b/libc/include/time.h @@ -30,6 +30,11 @@ struct tm { int tm_isdst; }; +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + #define __isleap(year) \ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) @@ -43,8 +48,10 @@ extern int stime __P ((time_t* __tptr)); extern clock_t clock __P ((void)); extern time_t time __P ((time_t * __tp)); +#ifndef __HAS_NO_FLOATS__ extern __CONSTVALUE double difftime __P ((time_t __time2, time_t __time1)) __CONSTVALUE2; +#endif extern time_t mktime __P ((struct tm * __tp)); extern char * asctime __P ((__const struct tm * __tp)); diff --git a/libc/kinclude/linuxmt/types.h b/libc/kinclude/linuxmt/types.h index 785d250..1450d25 100644 --- a/libc/kinclude/linuxmt/types.h +++ b/libc/kinclude/linuxmt/types.h @@ -28,5 +28,7 @@ typedef __u16 ino_t; typedef __u32 tcflag_t; typedef __u8 cc_t; +typedef int ptrdiff_t; + #endif diff --git a/libc/libc.a b/libc/libc.a Binary files differindex 5f92616..be7499f 100644 --- a/libc/libc.a +++ b/libc/libc.a diff --git a/libc/misc/Makefile b/libc/misc/Makefile index 87ad1e5..01092bb 100644 --- a/libc/misc/Makefile +++ b/libc/misc/Makefile @@ -11,11 +11,18 @@ MOBJ=abs.o raise.o bcopy.o bzero.o bcmp.o index.o rindex.o remove.o creat.o ESRC=atexit.c EOBJ=on_exit.o atexit.o __do_exit.o -OBJ=$(MOBJ) $(EOBJ) \ - atoi.o atol.o ltoa.o ltostr.o \ - ctype.o qsort.o bsearch.o rand.o lsearch.o getopt.o \ - getenv.o putenv.o itoa.o cputype.o \ - strtol.o popen.o system.o crypt.o +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 + + +ifeq ($(PLATFORM),i86-DOS) +OBJ=$(MOBJ) $(EOBJ) $(GOBJ) +else +OBJ=$(MOBJ) $(EOBJ) $(GOBJ) $(UOBJ) +endif # No ELKS strtod() until BCC does 16 bit FP... ifeq ($(PLATFORM),i386-Linux) diff --git a/libc/string/string.c b/libc/string/string.c index fad6690..50b7145 100644 --- a/libc/string/string.c +++ b/libc/string/string.c @@ -120,6 +120,7 @@ const char * s; push es push ds ; Im not sure if this is needed, so just in case. pop es + cld #endif #if __FIRST_ARG_IN_AX__ @@ -367,6 +368,7 @@ size_t l; push es push ds ; Im not sure if this is needed, so just in case. pop es + cld #endif #if __FIRST_ARG_IN_AX__ diff --git a/libc/syscall/Makefile b/libc/syscall/Makefile index 21991ee..fd2f1bc 100644 --- a/libc/syscall/Makefile +++ b/libc/syscall/Makefile @@ -9,7 +9,7 @@ LSRC=syslibc.c LOBJ=__cstartup.o time.o lseek.o getpid.o getppid.o \ getuid.o geteuid.o getgid.o getegid.o \ dup2.o dup.o abort.o wait.o waitpid.o sleep.o \ - killpg.o setpgrp.o getpgrp.o + killpg.o setpgrp.o getpgrp.o times.o usleep.o ESRC=execve.c EOBJ=execve.o execl.o execv.o execle.o diff --git a/libc/syscall/syscall.dat b/libc/syscall/syscall.dat index df61a4f..de5ed9b 100644 --- a/libc/syscall/syscall.dat +++ b/libc/syscall/syscall.dat @@ -67,7 +67,7 @@ RENAME 38 2 MKDIR 39 2 RMDIR 40 1 PIPE 42 1 -TIMES 43 1 +TIMES 43 2 * 2nd arg is pointer for long ret val. SETGID 46 1 GETGID 47 1 * This gets both gid and egid SIGNAL 48 2 * Have put the despatch table in user space. @@ -78,7 +78,7 @@ UMASK 60 1 CHROOT 61 1 USTAT 62 2 GETPGRP 65 0 - use getpgid(0) -SETSID 66 X +SETSID 66 0 SIGACTION 67 X SGETMASK 68 X SSETMASK 69 X diff --git a/libc/syscall/syslibc.c b/libc/syscall/syslibc.c index 1dcb013..e6d58eb 100644 --- a/libc/syscall/syslibc.c +++ b/libc/syscall/syslibc.c @@ -6,6 +6,7 @@ #include <sys/types.h> #include <errno.h> #include <time.h> +#include <sys/times.h> /* MSDOS has it's own versions */ #ifndef __MSDOS__ @@ -117,6 +118,18 @@ time_t *where; } #endif +/********************** Function times ************************************/ + +#ifdef L_times +clock_t times(buf) +struct tms* buf; +{ + long rv; + __times(buf, &rv); + return rv; +} +#endif + /********************** Function lseek ************************************/ #ifdef L_lseek @@ -359,6 +372,22 @@ unsigned int seconds; return seconds - (time((void*)0) - start); } #endif + +#endif + +/********************** Function usleep ************************************/ + +#ifdef L_usleep +#include <sys/time.h> +void +usleep(useconds) +unsigned long useconds; +{ + struct timeval timeout; + timeout.tv_sec = useconds%1000000L; + timeout.tv_usec = useconds/1000000L; + select(1, NULL, NULL, NULL, &timeout); +} #endif /********************** THE END ********************************************/ diff --git a/libc/time/Config b/libc/time/Config new file mode 100644 index 0000000..053ab81 --- /dev/null +++ b/libc/time/Config @@ -0,0 +1 @@ +time: Unix time manipulation functions. diff --git a/libc/time/Makefile b/libc/time/Makefile new file mode 100644 index 0000000..d04e5f4 --- /dev/null +++ b/libc/time/Makefile @@ -0,0 +1,17 @@ +# 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. + +TOP=.. +include $(TOP)/Make.defs + +OBJ=localtime.o gmtime.o asctime.o ctime.o asc_conv.o tm_conv.o + +all: $(OBJ) + +libc.a: $(OBJ) + ar r ../$(LIBC) $(OBJ) + @touch libc.a + +clean: + rm -f *.o libc.a diff --git a/libc/time/README b/libc/time/README new file mode 100644 index 0000000..0d50401 --- /dev/null +++ b/libc/time/README @@ -0,0 +1,7 @@ +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. + +There's currently nothing special about time. + +-Robert diff --git a/libc/time/asc_conv.c b/libc/time/asc_conv.c new file mode 100644 index 0000000..0ba48f1 --- /dev/null +++ b/libc/time/asc_conv.c @@ -0,0 +1,46 @@ + +#include <time.h> +#include <string.h> +/* + * Internal ascii conversion routine, avoid use of printf, it's a bit big! + */ + +static hit(buf, val) +char * buf; +int val; +{ + *buf = '0' + val%10; +} + +void +__asctime(buffer, ptm) +char * buffer; +struct tm * ptm; +{ +static days[] = "SunMonTueWedThuFriSat"; +static mons[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; + int year; + + /* 012345678901234567890123456 */ + strcpy(buffer, "Err Err .. ..:..:.. ....\n"); + if( ptm->tm_wday >= 0 && ptm->tm_wday <= 6 ) + memcpy(buffer, days+3*ptm->tm_wday, 3); + + if( ptm->tm_mon >= 1 && ptm->tm_mon <= 12 ) + memcpy(buffer+4, mons+3*ptm->tm_mon-3, 3); + + hit(buffer+ 8, ptm->tm_mday/10); + hit(buffer+ 9, ptm->tm_mday ); + hit(buffer+11, ptm->tm_hour/10); + hit(buffer+12, ptm->tm_hour ); + hit(buffer+14, ptm->tm_min/10); + hit(buffer+15, ptm->tm_min ); + hit(buffer+17, ptm->tm_sec/10); + hit(buffer+18, ptm->tm_sec ); + + year = ptm->tm_year + 1900; + hit(buffer+20, year/1000); + hit(buffer+21, year/100); + hit(buffer+22, year/10); + hit(buffer+23, year); +} diff --git a/libc/time/asctime.c b/libc/time/asctime.c new file mode 100644 index 0000000..b66cd37 --- /dev/null +++ b/libc/time/asctime.c @@ -0,0 +1,15 @@ + +#include <time.h> + +extern void __asctime(); + +char * +asctime(timeptr) +struct tm * timeptr; +{ +static char timebuf[26]; + + if( timeptr == 0 ) return 0; + __asctime(timebuf, timeptr); + return timebuf; +} diff --git a/libc/time/ctime.c b/libc/time/ctime.c new file mode 100644 index 0000000..bc7283d --- /dev/null +++ b/libc/time/ctime.c @@ -0,0 +1,26 @@ + +#include <time.h> + +extern void __tm_conv(); +extern void __asc_conv(); + +char * +ctime(timep) +time_t * timep; +{ +static char cbuf[26]; + struct tm tmb; + struct timezone tz; + time_t offt; + + gettimeofday((void*)0, &tz); + + offt = -tz.tz_minuteswest*60L; + + /* tmb.tm_isdst = ? */ + __tm_conv(&tmb, &timep, offt); + + __asc_conv(cbuf, &tmb); + + return cbuf; +} diff --git a/libc/time/gmtime.c b/libc/time/gmtime.c new file mode 100644 index 0000000..29907d0 --- /dev/null +++ b/libc/time/gmtime.c @@ -0,0 +1,15 @@ + +#include <time.h> + +extern void __tm_conv(); + +struct tm * +gmtime(timep) +time_t * timep; +{ + static struct tm tmb; + + __tm_conv(&tmb, &timep, 0L); + + return &tmb; +} diff --git a/libc/time/localtime.c b/libc/time/localtime.c new file mode 100644 index 0000000..b0b729c --- /dev/null +++ b/libc/time/localtime.c @@ -0,0 +1,22 @@ + +#include <time.h> + +extern void __tm_conv(); + +struct tm * +localtime(timep) +time_t * timep; +{ + static struct tm tmb; + struct timezone tz; + time_t offt; + + gettimeofday((void*)0, &tz); + + offt = -tz.tz_minuteswest*60L; + + /* tmb.tm_isdst = ? */ + __tm_conv(&tmb, &timep, offt); + + return &tmb; +} diff --git a/libc/time/tm_conv.c b/libc/time/tm_conv.c new file mode 100644 index 0000000..96f4735 --- /dev/null +++ b/libc/time/tm_conv.c @@ -0,0 +1,64 @@ + +#include <time.h> + +/* This is a translation from ALGOL in Collected Algorithms of CACM. */ +/* Copied from Algorithm 199, Author: Robert G. Tantzen */ + +void +__tm_conv(tmbuf, timep, offset) +struct tm *tmbuf; +time_t *timep; +time_t offset; +{ +static int moffset[] = + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; + + long s; + long j, d, m, y; + + offset += *timep; + + tmbuf->tm_isdst = 0; /* Someone else can set this */ + + j = offset / 86400L + 719469; + s = offset % 86400L; + + if( s < 0 ) { s += 86400L; j--; } + + tmbuf->tm_sec = s % 60; + tmbuf->tm_min = (s / 60) % 60; + tmbuf->tm_hour = s / 3600; + + tmbuf->tm_wday = (j+2) % 7; + + /* + * Julian date converter. Takes a julian date (the number of days since + * some distant epoch or other), and fills tmbuf. + */ + + y = (4L * j - 1L) / 146097L; + j = 4L * j - 1L - 146097L * y; + d = j / 4L; + j = (4L * d + 3L) / 1461L; + d = 4L * d + 3L - 1461L * j; + d = (d + 4L) / 4L; + m = (5L * d - 3L) / 153L; + d = 5L * d - 3 - 153L * m; + d = (d + 5L) / 5L; + y = 100L * y + j; + if (m < 10) + m += 2; + else + { + m -= 10; + ++y; + } + + tmbuf->tm_year = y - 1900; + tmbuf->tm_mon = m; + tmbuf->tm_mday = d; + + tmbuf->tm_yday = d + moffset[m]; + if (m > 1 && ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))) + tmbuf->tm_yday++; +} diff --git a/make_bcc.bat b/make_bcc.bat index 837879c..cf5985d 100644 --- a/make_bcc.bat +++ b/make_bcc.bat @@ -1,11 +1,22 @@ -@echo off
-
+@
+@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 -W3
+@
+set CFLAGS=-Ml -nologo
cl %CFLAGS% -c assign.c
cl %CFLAGS% -c bcc-cc1.c
cl %CFLAGS% -c codefrag.c
@@ -31,22 +42,28 @@ cl %CFLAGS% -c softop.c cl %CFLAGS% -c state.c
cl %CFLAGS% -c table.c
cl %CFLAGS% -c type.c
-
-del bcc_lib.lib
-lib bcc_lib.lib -+assign.obj -+declare.obj -+gencode.obj -+label.obj ;
-lib bcc_lib.lib -+preserve.obj -+type.obj -+express.obj -+genloads.obj ;
-lib bcc_lib.lib -+loadexp.obj -+scan.obj -+exptree.obj -+glogcode.obj ;
-lib bcc_lib.lib -+longop.obj -+softop.obj -+codefrag.obj -+floatop.obj ;
-lib bcc_lib.lib -+hardop.obj -+output.obj -+state.obj -+debug.obj ;
-lib bcc_lib.lib -+function.obj -+input.obj -+preproc.obj -+table.obj ;
-
-cl %CFLAGS% -o bcc-cc1.exe bcc-cc1.obj bcc_lib.lib
+@
+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 ..
-
-:no_bcc
+@
+@goto endbcc
+@
+:mkld
+@
cd ld
set CFLAGS=-O -Ml -DPOSIX_HEADERS_MISSING -nologo
-
+@
+copy aout*.h a_out.h
cl -c %CFLAGS% writebin.c
cl -c %CFLAGS% dumps.c
cl -c %CFLAGS% io.c
@@ -54,13 +71,17 @@ cl -c %CFLAGS% ld.c cl -c %CFLAGS% readobj.c
cl -c %CFLAGS% table.c
cl -c %CFLAGS% typeconv.c
+del a_out.h
cl -O -nologo -o ld.exe dumps io ld readobj table typeconv writebin
cd ..
-
+@
+@goto endld
+@
+:mkas
+@
cd as
set CFLAGS=-O -Ml -DPOSIX_HEADERS_MISSING -nologo
-del as.lib
-lib as.lib -+..\ld\typeconv.obj;
+cl -c %CFLAGS% readsrc.c
cl -c %CFLAGS% as.c
cl -c %CFLAGS% assemble.c
cl -c %CFLAGS% error.c
@@ -69,30 +90,35 @@ 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% readsrc.c
cl -c %CFLAGS% scan.c
cl -c %CFLAGS% table.c
-lib as.lib -+assemble.obj;
-lib as.lib -+error.obj;
-lib as.lib -+express.obj;
-lib as.lib -+genbin.obj;
-lib as.lib -+genlist.obj;
-lib as.lib -+genobj.obj;
-lib as.lib -+gensym.obj;
-lib as.lib -+macro.obj;
-lib as.lib -+mops.obj;
-lib as.lib -+pops.obj;
-lib as.lib -+readsrc.obj;
-lib as.lib -+scan.obj;
-lib as.lib -+table.obj;
-cl %CFLAGS% -o as.exe as.obj as.lib
+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=
|