diff options
author | Robert de Bath <rdebath@poboxes.com> | 1996-09-03 22:06:58 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:31:01 +0200 |
commit | 0936b9aeab611665645a4e6bafaded7ca76dd189 (patch) | |
tree | fe6384035e96adc260f621d27909be67ad2e724a /as | |
parent | e85ee07172eccafd9441362e774f7b184810d008 (diff) | |
download | dev86-0936b9aeab611665645a4e6bafaded7ca76dd189.tar.gz |
Import Dev86-0.0.7.tar.gzv0.0.7
Diffstat (limited to 'as')
-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 |
28 files changed, 2051 insertions, 974 deletions
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 */ |