Separate out PDP11 stuff into a separate directory and header file
authorNick Downing <nick@ndcode.org>
Fri, 14 Jun 2019 11:24:40 +0000 (21:24 +1000)
committerNick Downing <nick@ndcode.org>
Fri, 14 Jun 2019 11:24:40 +0000 (21:24 +1000)
12 files changed:
Makefile
defines.h
pdp11/branch.c [moved from branch.c with 100% similarity]
pdp11/cpu.c [moved from cpu.c with 100% similarity]
pdp11/debug.c [moved from debug.c with 100% similarity]
pdp11/double.c [moved from double.c with 100% similarity]
pdp11/ea.c [moved from ea.c with 100% similarity]
pdp11/fp.c [moved from fp.c with 100% similarity]
pdp11/itab.c [moved from itab.c with 100% similarity]
pdp11/ke11a.c [moved from ke11a.c with 100% similarity]
pdp11/pdp11.h [new file with mode: 0644]
pdp11/single.c [moved from single.c with 100% similarity]

index 3443f41..fad8b9d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ APOUT_OPTIONS?= -DEMU211 -DEMUv1 -DNATIVES -DDEBUG
 #LDFLAGS?=
 
 # Assemble CFLAGS
-CFLAGS?= -O2 -DINLINE=inline -finline-functions -fomit-frame-pointer
+CFLAGS?= -O2 -I. -DINLINE=inline -finline-functions -fomit-frame-pointer
 CFLAGS+=-Winline -Wunused-result # silence warnings
 CFLAGS+= $(APOUT_OPTIONS)
 
@@ -35,15 +35,21 @@ MANDIR=$(PREFIX)/man/man1
 BINDIR=$(PREFIX)/bin
 
 VERSION= apout2.3beta1
-SRCS=  cpu.c aout.c aout.h branch.c double.c ea.c itab.c main.c ke11a.c \
-       single.c fp.c v7trap.c bsdtrap.c defines.h v7trap.h debug.c \
+SRCS=  aout.c aout.h main.c \
+       v7trap.c bsdtrap.c defines.h v7trap.h \
        bsdtrap.h bsd_ioctl.c bsd_signal.c magic.c v1trap.c v1trap.h
-OBJS=  aout.o branch.o bsd_ioctl.o bsd_signal.o bsdtrap.o cpu.o debug.o \
-       double.o ea.o fp.o itab.o ke11a.o magic.o main.o single.o v1trap.o \
+PDP11_SRCS= pdp11/cpu.c pdp11/branch.c pdp11/double.c pdp11/ea.c pdp11/itab.c \
+       pdp11/ke11a.c pdp11/single.c pdp11/fp.c pdp11/debug.c
+OBJS=  aout.o bsd_ioctl.o bsd_signal.o bsdtrap.o \
+       magic.o main.o v1trap.o \
        v7trap.o
+PDP11_OBJS= pdp11/branch.o pdp11/cpu.o pdp11/debug.o \
+       pdp11/double.o pdp11/ea.o pdp11/fp.o pdp11/itab.o pdp11/ke11a.o \
+       pdp11/single.o
 
-apout: $(OBJS)
-       $(CC) $(LDFLAGS) $(OBJS) -o apout $(LIBS)
+
+apout: $(OBJS) $(PDP11_OBJS)
+       $(CC) $(LDFLAGS) $(OBJS) $(PDP11_OBJS) -o apout $(LIBS)
 
 install: apout apout.1
        cp apout $(BINDIR)
@@ -52,7 +58,7 @@ install: apout apout.1
        chmod 644 $(MANDIR)/apout.1
 
 clean:
-       rm -rf apout *core $(OBJS) *.dbg $(VERSION) $(VERSION).tar.gz apout.0
+       rm -rf apout *core $(OBJS) $(PDP11_OBJS) *.dbg $(VERSION) $(VERSION).tar.gz apout.0
 
 apout.0: apout.1
        nroff -man apout.1 > apout.0
@@ -69,20 +75,20 @@ disttar: clean apout.0
        tar vzcf $(VERSION).tar.gz $(VERSION)
 
 # Dependencies for object files
-aout.o: aout.c defines.h aout.h Makefile
-branch.o: branch.c defines.h Makefile
-bsd_ioctl.o: bsd_ioctl.c defines.h Makefile
-bsd_signal.o: bsd_signal.c defines.h bsdtrap.h Makefile
-bsdtrap.o: bsdtrap.c bsdtrap.h defines.h Makefile
-cpu.o: cpu.c defines.h Makefile
-debug.o: debug.c defines.h Makefile
-double.o: double.c defines.h Makefile
-ea.o: ea.c defines.h Makefile
-fp.o: fp.c defines.h Makefile
-itab.o: itab.c defines.h Makefile
-ke11a.o: ke11a.c defines.h Makefile
-magic.o: magic.c defines.h Makefile
-main.o: main.c defines.h Makefile
-single.o: single.c defines.h Makefile
-v1trap.o: v1trap.c v1trap.h defines.h Makefile
-v7trap.o: v7trap.c v7trap.h defines.h Makefile
+aout.o: aout.c defines.h pdp11/pdp11.h aout.h Makefile
+pdp11/branch.o: pdp11/branch.c defines.h pdp11/pdp11.h Makefile
+bsd_ioctl.o: bsd_ioctl.c defines.h pdp11/pdp11.h Makefile
+bsd_signal.o: bsd_signal.c defines.h pdp11/pdp11.h bsdtrap.h Makefile
+bsdtrap.o: bsdtrap.c bsdtrap.h defines.h pdp11/pdp11.h Makefile
+pdp11/cpu.o: pdp11/cpu.c defines.h pdp11/pdp11.h Makefile
+pdp11/debug.o: pdp11/debug.c defines.h pdp11/pdp11.h Makefile
+pdp11/double.o: pdp11/double.c defines.h pdp11/pdp11.h Makefile
+pdp11/ea.o: pdp11/ea.c defines.h pdp11/pdp11.h Makefile
+pdp11/fp.o: pdp11/fp.c defines.h pdp11/pdp11.h Makefile
+pdp11/itab.o: pdp11/itab.c defines.h pdp11/pdp11.h Makefile
+pdp11/ke11a.o: pdp11/ke11a.c defines.h pdp11/pdp11.h Makefile
+magic.o: magic.c defines.h pdp11/pdp11.h Makefile
+main.o: main.c defines.h pdp11/pdp11.h Makefile
+pdp11/single.o: pdp11/single.c defines.h pdp11/pdp11.h Makefile
+v1trap.o: v1trap.c v1trap.h defines.h pdp11/pdp11.h Makefile
+v7trap.o: v7trap.c v7trap.h defines.h pdp11/pdp11.h Makefile
index 25951e1..eafb618 100644 (file)
--- a/defines.h
+++ b/defines.h
@@ -125,52 +125,8 @@ typedef unsigned long u_int32_t;
 #define P(s) ()
 #endif
 
-typedef void (*_itab) P((void));
-extern _itab itab[];           /* Instruction Table for Fast Decode. */
-
-typedef float FLOAT;           /* For now, we use floats to do FP */
-
-/* PDP processor defines. */
-
-#define SP     6               /* stack pointer */
-#define PC     7               /* program counter */
-#define CC_NBIT 010            /* Positions of the flags in the */
-#define CC_ZBIT 04             /* processor status word */
-#define CC_VBIT 02
-#define CC_CBIT 01
-
-#define PDP_MEM_SIZE   65536   /* Size of inst-space and data-space */
 #define MAX_ARGS       200     /* Max cmd-line args per process */
 
-
-/* Global variables. */
-
-extern u_int16_t regs[8];      /* general registers */
-extern u_int16_t ir;           /* current instruction register */
-extern int CC_N;               /* The processor status word is represented */
-extern int CC_Z;               /* by these four values. On some */
-extern int CC_V;               /* architectures, you may get a performance */
-extern int CC_C;               /* increase by changing the size of the vars */
-
-extern FLOAT fregs[8];         /* FP registers */
-extern int FPC;                        /* FP Status flags */
-extern int FPZ;
-extern int FPN;
-extern int FPV;
-extern int FPMODE;             /* 0 = float, 1 = doubles */
-extern int INTMODE;            /* 0 = integers, 1 = longs */
-
-extern u_int16_t ea_addr;      /* stored address for dest modifying insts */
-extern u_int8_t *ispace, *dspace;
-extern u_int16_t dwrite_base;  /* Lowest addr where dspace writes can occur */
-
-extern u_int16_t dstword;      /* These globals are used in the effective */
-extern u_int16_t srcword;      /* address calculations, mainly to save */
-extern u_int16_t tmpword;      /* parameter passing overheads in */
-extern u_int8_t dstbyte;       /* function calls */
-extern u_int8_t srcbyte;
-extern u_int8_t tmpbyte;
-
 /* The following array holds the FILE pointers
  * that correspond to open file descriptors.
  * Only fds which are not ttys have
@@ -217,233 +173,6 @@ struct our_siglist {
 extern struct our_siglist *Sighead;    /* Head of the list */
 extern struct our_siglist *Sigtail;    /* Tail of the list */
 
-/* Inline defines. */
-
-#define CLR_CC_V()     CC_V=0
-#define CLR_CC_C()     CC_C=0
-#define CLR_CC_Z()     CC_Z=0
-#define CLR_CC_N()     CC_N=0
-#define CLR_CC_ALL()   CC_V=CC_C=CC_Z=CC_N=0
-
-#define SET_CC_V()     CC_V=1
-#define SET_CC_C()     CC_C=1
-#define SET_CC_Z()     CC_Z=1
-#define SET_CC_N()     CC_N=1
-
-#define SRC_MODE       (( ir & 07000 ) >> 9 )
-#define SRC_REG                (( ir & 0700 ) >> 6 )
-#define DST_MODE       (( ir & 070 ) >> 3 )
-#define DST_REG                ( ir & 07 )
-
-#define LSBIT  1               /* least significant bit */
-
-#define MPI    0077777         /* most positive integer */
-#define MNI    0100000         /* most negative integer */
-#define NEG_1  0177777         /* negative one */
-#define SIGN   0100000         /* sign bit */
-#define CARRY  0200000         /* set if carry out */
-
-#define MPI_B  0177            /* most positive integer (byte) */
-#define MNI_B  0200            /* most negative integer (byte) */
-#define NEG_1_B 0377           /* negative one (byte) */
-#define SIGN_B 0200            /* sign bit (byte) */
-#define CARRY_B 0400           /* set if carry out (byte) */
-
-#define LOW16( data )  (u_int16_t)(( data ) & 0177777 )        /* mask the lower 16 bits */
-#define LOW8( data )   (u_int8_t)(( data ) & 0377 )    /* mask the lower 8 bits */
-
-#define CHG_CC_N( d )  if ((d) & SIGN ) \
-                                       SET_CC_N(); \
-                               else \
-                                       CLR_CC_N()
-
-#define CHGB_CC_N( d ) if ((d) & SIGN_B ) \
-                               SET_CC_N(); \
-                       else \
-                               CLR_CC_N()
-
-#define CHG_CC_Z( d )  if ( d ) \
-                                       CLR_CC_Z(); \
-                               else \
-                                       SET_CC_Z()
-
-#define CHGB_CC_Z( d ) if ( LOW8( d )) \
-                               CLR_CC_Z(); \
-                       else \
-                               SET_CC_Z()
-
-#define CHG_CC_C( d )  if ((d) & CARRY ) \
-                                       SET_CC_C(); \
-                               else \
-                                       CLR_CC_C()
-
-#define CHG_CC_IC( d ) if ((d) & CARRY ) \
-                                       CLR_CC_C(); \
-                               else \
-                                       SET_CC_C()
-
-#define CHGB_CC_IC( d ) if ((d) & CARRY_B ) \
-                               CLR_CC_C(); \
-                       else \
-                               SET_CC_C()
-
-#define CHG_CC_V( d1, d2, d3 ) \
-                               if ((( d1 & SIGN ) == ( d2 & SIGN )) \
-                               && (( d1 & SIGN ) != ( d3 & SIGN ))) \
-                                       SET_CC_V(); \
-                               else \
-                                       CLR_CC_V()
-
-#define CHG_CC_VC( d1, d2, d3 ) \
-                               if ((( d1 & SIGN ) != ( d2 & SIGN )) \
-                               && (( d2 & SIGN ) == ( d3 & SIGN ))) \
-                                       SET_CC_V(); \
-                               else \
-                                       CLR_CC_V()
-
-#define CHG_CC_VS( d1, d2, d3 ) \
-                               if ((( d1 & SIGN ) != ( d2 & SIGN )) \
-                               && (( d1 & SIGN ) == ( d3 & SIGN ))) \
-                                       SET_CC_V(); \
-                               else \
-                                       CLR_CC_V()
-
-#define CHGB_CC_V( d1, d2, d3 ) \
-                               if ((( d1 & SIGN_B ) == ( d2 & SIGN_B )) \
-                               && (( d1 & SIGN_B ) != ( d3 & SIGN_B ))) \
-                                       SET_CC_V(); \
-                               else \
-                                       CLR_CC_V()
-
-#define CHGB_CC_VC(d1,d2,d3)   \
-                               if ((( d1 & SIGN_B ) != ( d2 & SIGN_B )) \
-                               && (( d2 & SIGN_B ) == ( d3 & SIGN_B ))) \
-                                       SET_CC_V(); \
-                               else \
-                                       CLR_CC_V()
-
-#define CHG_CC_V_XOR_C_N()     \
-                               if ((( CC_C ) && \
-                                  ( CC_N )) \
-                               || ((!( CC_C )) && \
-                                  ( ! ( CC_N )))) \
-                                       CLR_CC_V(); \
-                               else \
-                                       SET_CC_V()
-
-
-/* Macros to read and write loctions in
- * main memory.
- */
-
-extern u_int16_t *adptr;
-
-#define copylong(to,from) \
-       buf = (char *) &(to); buf2 = (char *) &(from); \
-       buf[0]=buf2[2]; buf[1]=buf2[3]; buf[2]=buf2[0]; buf[3]=buf2[1]
-
-#ifndef EMUV1
-/* lli_word() - Load a word from the given ispace logical address. */
-#define lli_word(addr, word) \
-       { adptr= (u_int16_t *)&(ispace[addr]); word= *adptr; }
-
-/* ll_word() - Load a word from the given logical address. */
-#define ll_word(addr, word) \
-       { adptr= (u_int16_t *)&(dspace[addr]); word= *adptr; }
-
-/* sl_word() - Store a word at the given logical address. */
-#ifdef WRITEBASE
-#define sl_word(addr, word) \
-       { if ((u_int16_t)addr < dwrite_base) seg_fault(); \
-         adptr= (u_int16_t *)&(dspace[addr]); *adptr= word; }
-#else
-#define sl_word(addr, word) \
-       { adptr= (u_int16_t *)&(dspace[addr]); *adptr= word; }
-#endif
-
-/* lli_byte() - Load a byte from the given logical ispace address. */
-#define lli_byte(addr, byte) \
-    byte = ispace[addr];
-
-/* ll_byte() - Load a byte from the given logical address. */
-#define ll_byte(addr, byte) \
-    byte = dspace[addr];
-
-/* sl_byte() - Store a byte at the given logical address. */
-#ifdef WRITEBASE
-#define sl_byte(addr, byte) \
-       { if (addr < dwrite_base) seg_fault(); \
-         dspace[addr]= byte; }
-#else
-#define sl_byte(addr, byte) \
-       { dspace[addr]= byte; }
-#endif
-#else
-/* These versions of the macros are required */
-/* because the KE11-A module is mapped into */
-/* a process' memory space in 1st Edition */
-#define KE11LO 0177300
-#define KE11HI 0177317
-
-/* lli_word() - Load a word from the given ispace logical address. */
-#define lli_word(addr, word) \
-       { if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
-               word= kell_word(addr);                                  \
-         } else { adptr= (u_int16_t *)&(ispace[addr]); word= *adptr; } \
-       }
-
-/* ll_word() - Load a word from the given logical address. */
-#define ll_word(addr, word) \
-       { if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
-               word= kell_word(addr);                                  \
-         } else { adptr= (u_int16_t *)&(dspace[addr]); word= *adptr; } \
-       }
-
-/* sl_word() - Store a word at the given logical address. */
-#ifdef WRITEBASE
-#define sl_word(addr, word) \
-       { if ((u_int16_t)addr < dwrite_base) seg_fault(); \
-         if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
-               kesl_word(addr, word);                                  \
-         } else { adptr= (u_int16_t *)&(dspace[addr]); *adptr= word; } \
-       }
-#else
-#define sl_word(addr, word) \
-       { if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
-               kesl_word(addr, word);                                  \
-         } else { adptr= (u_int16_t *)&(dspace[addr]); *adptr= word; } \
-       }
-#endif
-
-/* lli_byte() - Load a byte from the given logical ispace address. */
-#define lli_byte(addr, byte) \
-    byte = ispace[addr];
-
-/* ll_byte() - Load a byte from the given logical address. */
-#define ll_byte(addr, byte) \
-       { if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
-               byte= kell_byte(addr);                                  \
-         } else byte = dspace[addr];                                   \
-       }
-
-/* sl_byte() - Store a byte at the given logical address. */
-#ifdef WRITEBASE
-#define sl_byte(addr, byte) \
-       { if (addr < dwrite_base) seg_fault(); \
-         if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
-               kesl_byte(addr, byte);                                  \
-         } else dspace[addr]= byte;                                    \
-       }
-#else
-#define sl_byte(addr, byte) \
-       { if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
-               kesl_byte(addr, byte);                                  \
-         } else dspace[addr]= byte;                                    \
-       }
-#endif
-#endif
-
-
 
 
 /* Function prototypes */
@@ -455,118 +184,6 @@ int load_a_out P((const char *file, const char *origpath, int want_env))
 void do_bsd_overlay P((void));
 #endif
 
-/* branch.c */
-void br P((void));
-void blos P((void));
-void bge P((void));
-void blt P((void));
-void ble P((void));
-void bgt P((void));
-void jmp P((void));
-void jsr P((void));
-void rts P((void));
-void bne P((void));
-void beq P((void));
-void bpl P((void));
-void bmi P((void));
-void bhi P((void));
-void bvc P((void));
-void bvs P((void));
-void bcc P((void));
-void bcs P((void));
-void scc P((void));
-void ccc P((void));
-void sob P((void));
-void mfps P((void));
-void mtps P((void));
-void mfpi P((void));
-void mtpi P((void));
-void ash P((void));
-void mul P((void));
-void divide P((void));
-void ashc P((void));
-void xor P((void));
-
-/* double.c */
-void mov P((void));
-void movsreg P((void));
-void movsreg1 P((void));
-void movsreg1pc P((void));
-void cmp P((void));
-void add P((void));
-void sub P((void));
-void bit P((void));
-void bic P((void));
-void bis P((void));
-void movb P((void));
-void cmpb P((void));
-void bitb P((void));
-void bicb P((void));
-void bisb P((void));
-
-/* cpu.c */
-void run P((void));
-void sim_init P((void));
-void bus_error P((int));
-void seg_fault P((void));
-void waiti P((void));
-void halt P((void));
-void iot P((void));
-void emt P((void));
-void bpt P((void));
-void fis P((void));
-void illegal P((void));
-void not_impl P((void));
-void mark P((void));
-void mfpd P((void));
-void mtpd P((void));
-void trap P((void));
-void bad_FP_reg P((void));
-void sigcatcher P((int sig));
-
-/* ea.c */
-void load_ea P((void));
-void pop P((void));
-void push P((void));
-void loadb_dst P((void));
-void loadb_src P((void));
-void storeb_dst P((void));
-void storeb_dst_2 P((void));
-void loadp_dst P((void));
-void storep_dst P((void));
-void load_src P((void));
-void store_dst P((void));
-void load_dst P((void));
-void store_dst_2 P((void));
-
-/* fp.c */
-void fpset P((void));
-void ldf P((void));
-void stf P((void));
-void clrf P((void));
-void addf P((void));
-void subf P((void));
-void negf P((void));
-void absf P((void));
-void mulf P((void));
-void moddf P((void));
-void divf P((void));
-void cmpf P((void));
-void tstf P((void));
-void ldfps P((void));
-void stfps P((void));
-void lcdif P((void));
-void stcfi P((void));
-void stexp P((void));
-void stcdf P((void));
-void ldcdf P((void));
-void stst P((void));
-void ldexpp P((void));
-
-/* itab.c */
-void dositab0 P((void));
-void dositab1 P((void));
-
 /* main.c */
 int main P((int argc, char **argv));
 void usage P((void));
@@ -576,34 +193,6 @@ void set_apout_root P((char *dirname));
 /* magic.c */
 int special_magic P((u_int16_t * cptr));
 
-/* single.c */
-void adc P((void));
-void asl P((void));
-void asr P((void));
-void clr P((void));
-void com P((void));
-void dec P((void));
-void inc P((void));
-void neg P((void));
-void rol P((void));
-void ror P((void));
-void sbc P((void));
-void swabi P((void));
-void sxt P((void));
-void tst P((void));
-void tstb P((void));
-void aslb P((void));
-void asrb P((void));
-void clrb P((void));
-void comb P((void));
-void decb P((void));
-void incb P((void));
-void negb P((void));
-void rolb P((void));
-void rorb P((void));
-void adcb P((void));
-void sbcb P((void));
-
 /* v6trap.c */
 void v6trap P((void));
 
@@ -625,13 +214,6 @@ void set_bsdsig_dfl P((void));
 int do_sigaction P((int sig, int a, int oa));
 #endif
 
-/* ke11a.c */
-#ifdef EMUV1
-int16_t kell_word P((u_int16_t addr));
-void kesl_word P((u_int16_t addr, u_int16_t word));
-int8_t kell_byte P((u_int16_t addr));
-void kesl_byte P((u_int16_t addr, u_int8_t byte));
-void set_SR P((void));
-#endif
-
 #undef P
+
+#include "pdp11/pdp11.h"
similarity index 100%
rename from branch.c
rename to pdp11/branch.c
similarity index 100%
rename from cpu.c
rename to pdp11/cpu.c
similarity index 100%
rename from debug.c
rename to pdp11/debug.c
similarity index 100%
rename from double.c
rename to pdp11/double.c
diff --git a/ea.c b/pdp11/ea.c
similarity index 100%
rename from ea.c
rename to pdp11/ea.c
diff --git a/fp.c b/pdp11/fp.c
similarity index 100%
rename from fp.c
rename to pdp11/fp.c
similarity index 100%
rename from itab.c
rename to pdp11/itab.c
similarity index 100%
rename from ke11a.c
rename to pdp11/ke11a.c
diff --git a/pdp11/pdp11.h b/pdp11/pdp11.h
new file mode 100644 (file)
index 0000000..575570a
--- /dev/null
@@ -0,0 +1,437 @@
+#ifndef _PDP11_H
+#define _PDP11_H
+
+/* Set up prototype macro for
+ * both K&R and ANSI C platforms
+ */
+#ifdef __STDC__
+#define P(s) s
+#else
+#define P(s) ()
+#endif
+
+typedef void (*_itab) P((void));
+extern _itab itab[];           /* Instruction Table for Fast Decode. */
+
+typedef float FLOAT;           /* For now, we use floats to do FP */
+
+/* PDP processor defines. */
+
+#define SP     6               /* stack pointer */
+#define PC     7               /* program counter */
+#define CC_NBIT 010            /* Positions of the flags in the */
+#define CC_ZBIT 04             /* processor status word */
+#define CC_VBIT 02
+#define CC_CBIT 01
+
+#define PDP_MEM_SIZE   65536   /* Size of inst-space and data-space */
+
+
+/* Global variables. */
+
+extern u_int16_t regs[8];      /* general registers */
+extern u_int16_t ir;           /* current instruction register */
+extern int CC_N;               /* The processor status word is represented */
+extern int CC_Z;               /* by these four values. On some */
+extern int CC_V;               /* architectures, you may get a performance */
+extern int CC_C;               /* increase by changing the size of the vars */
+
+extern FLOAT fregs[8];         /* FP registers */
+extern int FPC;                        /* FP Status flags */
+extern int FPZ;
+extern int FPN;
+extern int FPV;
+extern int FPMODE;             /* 0 = float, 1 = doubles */
+extern int INTMODE;            /* 0 = integers, 1 = longs */
+
+extern u_int16_t ea_addr;      /* stored address for dest modifying insts */
+extern u_int8_t *ispace, *dspace;
+extern u_int16_t dwrite_base;  /* Lowest addr where dspace writes can occur */
+
+extern u_int16_t dstword;      /* These globals are used in the effective */
+extern u_int16_t srcword;      /* address calculations, mainly to save */
+extern u_int16_t tmpword;      /* parameter passing overheads in */
+extern u_int8_t dstbyte;       /* function calls */
+extern u_int8_t srcbyte;
+extern u_int8_t tmpbyte;
+
+
+/* Inline defines. */
+
+#define CLR_CC_V()     CC_V=0
+#define CLR_CC_C()     CC_C=0
+#define CLR_CC_Z()     CC_Z=0
+#define CLR_CC_N()     CC_N=0
+#define CLR_CC_ALL()   CC_V=CC_C=CC_Z=CC_N=0
+
+#define SET_CC_V()     CC_V=1
+#define SET_CC_C()     CC_C=1
+#define SET_CC_Z()     CC_Z=1
+#define SET_CC_N()     CC_N=1
+
+#define SRC_MODE       (( ir & 07000 ) >> 9 )
+#define SRC_REG                (( ir & 0700 ) >> 6 )
+#define DST_MODE       (( ir & 070 ) >> 3 )
+#define DST_REG                ( ir & 07 )
+
+#define LSBIT  1               /* least significant bit */
+
+#define MPI    0077777         /* most positive integer */
+#define MNI    0100000         /* most negative integer */
+#define NEG_1  0177777         /* negative one */
+#define SIGN   0100000         /* sign bit */
+#define CARRY  0200000         /* set if carry out */
+
+#define MPI_B  0177            /* most positive integer (byte) */
+#define MNI_B  0200            /* most negative integer (byte) */
+#define NEG_1_B 0377           /* negative one (byte) */
+#define SIGN_B 0200            /* sign bit (byte) */
+#define CARRY_B 0400           /* set if carry out (byte) */
+
+#define LOW16( data )  (u_int16_t)(( data ) & 0177777 )        /* mask the lower 16 bits */
+#define LOW8( data )   (u_int8_t)(( data ) & 0377 )    /* mask the lower 8 bits */
+
+#define CHG_CC_N( d )  if ((d) & SIGN ) \
+                                       SET_CC_N(); \
+                               else \
+                                       CLR_CC_N()
+
+#define CHGB_CC_N( d ) if ((d) & SIGN_B ) \
+                               SET_CC_N(); \
+                       else \
+                               CLR_CC_N()
+
+#define CHG_CC_Z( d )  if ( d ) \
+                                       CLR_CC_Z(); \
+                               else \
+                                       SET_CC_Z()
+
+#define CHGB_CC_Z( d ) if ( LOW8( d )) \
+                               CLR_CC_Z(); \
+                       else \
+                               SET_CC_Z()
+
+#define CHG_CC_C( d )  if ((d) & CARRY ) \
+                                       SET_CC_C(); \
+                               else \
+                                       CLR_CC_C()
+
+#define CHG_CC_IC( d ) if ((d) & CARRY ) \
+                                       CLR_CC_C(); \
+                               else \
+                                       SET_CC_C()
+
+#define CHGB_CC_IC( d ) if ((d) & CARRY_B ) \
+                               CLR_CC_C(); \
+                       else \
+                               SET_CC_C()
+
+#define CHG_CC_V( d1, d2, d3 ) \
+                               if ((( d1 & SIGN ) == ( d2 & SIGN )) \
+                               && (( d1 & SIGN ) != ( d3 & SIGN ))) \
+                                       SET_CC_V(); \
+                               else \
+                                       CLR_CC_V()
+
+#define CHG_CC_VC( d1, d2, d3 ) \
+                               if ((( d1 & SIGN ) != ( d2 & SIGN )) \
+                               && (( d2 & SIGN ) == ( d3 & SIGN ))) \
+                                       SET_CC_V(); \
+                               else \
+                                       CLR_CC_V()
+
+#define CHG_CC_VS( d1, d2, d3 ) \
+                               if ((( d1 & SIGN ) != ( d2 & SIGN )) \
+                               && (( d1 & SIGN ) == ( d3 & SIGN ))) \
+                                       SET_CC_V(); \
+                               else \
+                                       CLR_CC_V()
+
+#define CHGB_CC_V( d1, d2, d3 ) \
+                               if ((( d1 & SIGN_B ) == ( d2 & SIGN_B )) \
+                               && (( d1 & SIGN_B ) != ( d3 & SIGN_B ))) \
+                                       SET_CC_V(); \
+                               else \
+                                       CLR_CC_V()
+
+#define CHGB_CC_VC(d1,d2,d3)   \
+                               if ((( d1 & SIGN_B ) != ( d2 & SIGN_B )) \
+                               && (( d2 & SIGN_B ) == ( d3 & SIGN_B ))) \
+                                       SET_CC_V(); \
+                               else \
+                                       CLR_CC_V()
+
+#define CHG_CC_V_XOR_C_N()     \
+                               if ((( CC_C ) && \
+                                  ( CC_N )) \
+                               || ((!( CC_C )) && \
+                                  ( ! ( CC_N )))) \
+                                       CLR_CC_V(); \
+                               else \
+                                       SET_CC_V()
+
+
+/* Macros to read and write loctions in
+ * main memory.
+ */
+
+extern u_int16_t *adptr;
+
+#define copylong(to,from) \
+       buf = (char *) &(to); buf2 = (char *) &(from); \
+       buf[0]=buf2[2]; buf[1]=buf2[3]; buf[2]=buf2[0]; buf[3]=buf2[1]
+
+#ifndef EMUV1
+/* lli_word() - Load a word from the given ispace logical address. */
+#define lli_word(addr, word) \
+       { adptr= (u_int16_t *)&(ispace[addr]); word= *adptr; }
+
+/* ll_word() - Load a word from the given logical address. */
+#define ll_word(addr, word) \
+       { adptr= (u_int16_t *)&(dspace[addr]); word= *adptr; }
+
+/* sl_word() - Store a word at the given logical address. */
+#ifdef WRITEBASE
+#define sl_word(addr, word) \
+       { if ((u_int16_t)addr < dwrite_base) seg_fault(); \
+         adptr= (u_int16_t *)&(dspace[addr]); *adptr= word; }
+#else
+#define sl_word(addr, word) \
+       { adptr= (u_int16_t *)&(dspace[addr]); *adptr= word; }
+#endif
+
+/* lli_byte() - Load a byte from the given logical ispace address. */
+#define lli_byte(addr, byte) \
+    byte = ispace[addr];
+
+/* ll_byte() - Load a byte from the given logical address. */
+#define ll_byte(addr, byte) \
+    byte = dspace[addr];
+
+/* sl_byte() - Store a byte at the given logical address. */
+#ifdef WRITEBASE
+#define sl_byte(addr, byte) \
+       { if (addr < dwrite_base) seg_fault(); \
+         dspace[addr]= byte; }
+#else
+#define sl_byte(addr, byte) \
+       { dspace[addr]= byte; }
+#endif
+#else
+/* These versions of the macros are required */
+/* because the KE11-A module is mapped into */
+/* a process' memory space in 1st Edition */
+#define KE11LO 0177300
+#define KE11HI 0177317
+
+/* lli_word() - Load a word from the given ispace logical address. */
+#define lli_word(addr, word) \
+       { if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
+               word= kell_word(addr);                                  \
+         } else { adptr= (u_int16_t *)&(ispace[addr]); word= *adptr; } \
+       }
+
+/* ll_word() - Load a word from the given logical address. */
+#define ll_word(addr, word) \
+       { if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
+               word= kell_word(addr);                                  \
+         } else { adptr= (u_int16_t *)&(dspace[addr]); word= *adptr; } \
+       }
+
+/* sl_word() - Store a word at the given logical address. */
+#ifdef WRITEBASE
+#define sl_word(addr, word) \
+       { if ((u_int16_t)addr < dwrite_base) seg_fault(); \
+         if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
+               kesl_word(addr, word);                                  \
+         } else { adptr= (u_int16_t *)&(dspace[addr]); *adptr= word; } \
+       }
+#else
+#define sl_word(addr, word) \
+       { if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
+               kesl_word(addr, word);                                  \
+         } else { adptr= (u_int16_t *)&(dspace[addr]); *adptr= word; } \
+       }
+#endif
+
+/* lli_byte() - Load a byte from the given logical ispace address. */
+#define lli_byte(addr, byte) \
+    byte = ispace[addr];
+
+/* ll_byte() - Load a byte from the given logical address. */
+#define ll_byte(addr, byte) \
+       { if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
+               byte= kell_byte(addr);                                  \
+         } else byte = dspace[addr];                                   \
+       }
+
+/* sl_byte() - Store a byte at the given logical address. */
+#ifdef WRITEBASE
+#define sl_byte(addr, byte) \
+       { if (addr < dwrite_base) seg_fault(); \
+         if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
+               kesl_byte(addr, byte);                                  \
+         } else dspace[addr]= byte;                                    \
+       }
+#else
+#define sl_byte(addr, byte) \
+       { if ((Binary<IS_V3) && (addr>=KE11LO) && (addr<=KE11HI)) {     \
+               kesl_byte(addr, byte);                                  \
+         } else dspace[addr]= byte;                                    \
+       }
+#endif
+#endif
+
+
+/* branch.c */
+void br P((void));
+void blos P((void));
+void bge P((void));
+void blt P((void));
+void ble P((void));
+void bgt P((void));
+void jmp P((void));
+void jsr P((void));
+void rts P((void));
+void bne P((void));
+void beq P((void));
+void bpl P((void));
+void bmi P((void));
+void bhi P((void));
+void bvc P((void));
+void bvs P((void));
+void bcc P((void));
+void bcs P((void));
+void scc P((void));
+void ccc P((void));
+void sob P((void));
+void mfps P((void));
+void mtps P((void));
+void mfpi P((void));
+void mtpi P((void));
+void ash P((void));
+void mul P((void));
+void divide P((void));
+void ashc P((void));
+void xor P((void));
+
+/* double.c */
+void mov P((void));
+void movsreg P((void));
+void movsreg1 P((void));
+void movsreg1pc P((void));
+void cmp P((void));
+void add P((void));
+void sub P((void));
+void bit P((void));
+void bic P((void));
+void bis P((void));
+void movb P((void));
+void cmpb P((void));
+void bitb P((void));
+void bicb P((void));
+void bisb P((void));
+
+/* cpu.c */
+void run P((void));
+void sim_init P((void));
+void bus_error P((int));
+void seg_fault P((void));
+void waiti P((void));
+void halt P((void));
+void iot P((void));
+void emt P((void));
+void bpt P((void));
+void fis P((void));
+void illegal P((void));
+void not_impl P((void));
+void mark P((void));
+void mfpd P((void));
+void mtpd P((void));
+void trap P((void));
+void bad_FP_reg P((void));
+void sigcatcher P((int sig));
+
+/* ea.c */
+void load_ea P((void));
+void pop P((void));
+void push P((void));
+void loadb_dst P((void));
+void loadb_src P((void));
+void storeb_dst P((void));
+void storeb_dst_2 P((void));
+void loadp_dst P((void));
+void storep_dst P((void));
+void load_src P((void));
+void store_dst P((void));
+void load_dst P((void));
+void store_dst_2 P((void));
+
+/* fp.c */
+void fpset P((void));
+void ldf P((void));
+void stf P((void));
+void clrf P((void));
+void addf P((void));
+void subf P((void));
+void negf P((void));
+void absf P((void));
+void mulf P((void));
+void moddf P((void));
+void divf P((void));
+void cmpf P((void));
+void tstf P((void));
+void ldfps P((void));
+void stfps P((void));
+void lcdif P((void));
+void stcfi P((void));
+void stexp P((void));
+void stcdf P((void));
+void ldcdf P((void));
+void stst P((void));
+void ldexpp P((void));
+
+/* itab.c */
+void dositab0 P((void));
+void dositab1 P((void));
+
+/* single.c */
+void adc P((void));
+void asl P((void));
+void asr P((void));
+void clr P((void));
+void com P((void));
+void dec P((void));
+void inc P((void));
+void neg P((void));
+void rol P((void));
+void ror P((void));
+void sbc P((void));
+void swabi P((void));
+void sxt P((void));
+void tst P((void));
+void tstb P((void));
+void aslb P((void));
+void asrb P((void));
+void clrb P((void));
+void comb P((void));
+void decb P((void));
+void incb P((void));
+void negb P((void));
+void rolb P((void));
+void rorb P((void));
+void adcb P((void));
+void sbcb P((void));
+
+/* ke11a.c */
+#ifdef EMUV1
+int16_t kell_word P((u_int16_t addr));
+void kesl_word P((u_int16_t addr, u_int16_t word));
+int8_t kell_byte P((u_int16_t addr));
+void kesl_byte P((u_int16_t addr, u_int8_t byte));
+void set_SR P((void));
+#endif
+
+#undef P
+
+#endif
similarity index 100%
rename from single.c
rename to pdp11/single.c