BSD 1 development
authorBill Joy <wnj@ucbvax.Berkeley.EDU>
Tue, 6 Dec 1977 19:11:45 +0000 (11:11 -0800)
committerBill Joy <wnj@ucbvax.Berkeley.EDU>
Tue, 6 Dec 1977 19:11:45 +0000 (11:11 -0800)
Work on file px/0x.h
Work on file px/07sub.s
Work on file px/palloc.c

Co-Authored-By: Charles B. Haley <cbh@research.uucp>
Co-Authored-By: Ken Thompson <ken@research.uucp>
Synthesized-from: 1bsd

px/07sub.s [new file with mode: 0644]
px/0x.h [new file with mode: 0644]
px/palloc.c [new file with mode: 0644]

diff --git a/px/07sub.s b/px/07sub.s
new file mode 100644 (file)
index 0000000..3d81dd8
--- /dev/null
@@ -0,0 +1,58 @@
+/
+/ SUBTRACTION
+/
+_SUB42:
+       mov     (sp)+,r0
+       mov     (sp)+,r1
+       br      1f
+_SUB2:
+       mov     (sp)+,r1
+       sxt     r0
+1:
+       mov     (sp)+,r3
+       sxt     r2
+       sub     r1,r3
+       sbc     r2
+       sub     r0,r2
+       mov     r3,-(sp)
+       mov     r2,-(sp)
+       return
+_SUB24:
+       mov     (sp)+,r1
+       sxt     r0
+       sub     r1,2(sp)
+       adc     r0
+       sub     r0,(sp)
+       return
+_SUB4:
+       sub     (sp)+,2(sp)
+       sub     (sp)+,2(sp)
+       sbc     (sp)
+       return
+_SUB8:
+       movf    (sp)+,fr0
+       movf    (sp)+,fr2
+       subf    fr0,fr2
+       movf    fr2,-(sp)
+       return
+_SUB28:
+       tst     (sp)
+       sxt     -(sp)
+_SUB48:
+       movif   (sp)+,fr0
+       movf    (sp)+,fr2
+       subf    fr0,fr2
+       movf    fr2,-(sp)
+       return
+_SUB82:
+       movf    (sp)+,fr0
+       tst     (sp)
+       sxt     -(sp)
+       br      1f
+_SUB84:
+       movf    (sp)+,fr0
+1:
+       movif   (sp)+,fr2
+       subf    fr0,fr2
+       movf    fr2,-(sp)
+       return
diff --git a/px/0x.h b/px/0x.h
new file mode 100644 (file)
index 0000000..902abe6
--- /dev/null
+++ b/px/0x.h
@@ -0,0 +1,132 @@
+/*
+ * px - UNIX Pascal interpreter
+ *
+ * Version 1.0, July 1977
+ *
+ * Written by Bill Joy and Chuck Haley
+ * November-December 1976
+ *
+ * Based on an earlier version by Ken Thompson
+ *
+ * Px is described in detail in the "PX 1.0 Implementation Notes"
+ * The source code for px is in several major pieces:
+ *
+ *     int.c           C main program which reads in interpreter code
+ *     00int.s         Driver including main interpreter loop
+ *     dd*.s           Where dd are digits, interpreter instructions
+ *                     grouped by their positions in the interpreter table.
+ *     p*.c            Various C language routines supporting the system.
+ *
+ * In addition there are several headers defining mappings for error
+ * messages names into codes, and a definition of the interpreter transfer
+ * table. These are made by the script Emake in this directory and the scripts
+ * in the directory '../opcodes'.
+ */
+
+int    argc;
+char   **argv;
+
+/*
+ * Pascal runtime errors cause emulator traps
+ * to the routine onemt which transfers to the
+ * routine 'error' in the file perror.c to decode them.
+ * This method saves at least one word per static error.
+ */
+int    onemt();
+
+/*
+ * Definitions for memory allocation
+ * Memory allocation routines are in 'palloc.c'
+ */
+char   *bottmem, *memptr, *high, *maxstk;
+
+/*
+ * The file i/o routines maintain a notion of a "current file".
+ * The printing name of this file is kept in the variable
+ * "file" for use in error messages.
+ */
+char   *file;
+\f
+/*
+ * THE RUNTIME DISPLAY
+ *
+ * The entries in the display point to the active static block marks.
+ * The first entry in the display is for the global variables,
+ * then the procedure or function at level one, etc.
+ * Each display entry points to a stack frame as shown:
+ *
+ *             base of stack frame
+ *               ---------------
+ *               |             |
+ *               | block mark  |
+ *               |             |
+ *               ---------------  <-- display entry points here
+ *               |             |
+ *               |   local     |
+ *               |  variables  |
+ *               |             |
+ *               ---------------
+ *               |             |
+ *               |  expression |
+ *               |  temporary  |
+ *               |  storage    |
+ *               |             |
+ *               - - - - - - - -
+ *
+ * The information in the block mark is thus at positive offsets from
+ * the display pointer entries while the local variables are at negative
+ * offsets. The block mark actually consists of two parts. The first
+ * part is created at CALL and the second at entry, i.e. BEGIN. Thus:
+ *
+ *             -------------------------
+ *             |                       |
+ *             |  Saved lino           |
+ *             |  Saved lc             |
+ *             |  Saved dp             |
+ *             |                       |
+ *             -------------------------
+ *             |                       |
+ *             |  Saved (dp)           |
+ *             |                       |
+ *             |  Current section name |
+ *             |   and entry line ptr  |
+ *             |                       |
+ *             |  Saved file name and  |
+ *             |   file buffer ptr     |
+ *             |                       |
+ *             |  Empty tos value      |
+ *             |                       |
+ *             -------------------------
+ */
+int    display[20], *dp;
+\f
+int    lino;
+int    nodump;
+
+/*
+ * Random number generator constants
+ */
+long   seed;
+double randa;
+double randc;
+double randm;
+double randim;
+
+/*
+ * Structures to access things on the stack
+ */
+struct {
+       char    pchar;
+};
+struct {
+       int     pint;
+       int     p2int;
+};
+struct {
+       long    plong;
+};
+struct {
+       double  pdouble;
+};
+
+char   discard;
diff --git a/px/palloc.c b/px/palloc.c
new file mode 100644 (file)
index 0000000..a6cc685
--- /dev/null
@@ -0,0 +1,43 @@
+#include "0x.h"
+#include "E.h"
+
+extern char *sbrk(), *brk();
+
+alloc(need)
+       char *need;
+{
+       register cnt, *wp;
+       register char *have;
+
+       need = (need+1) &~ 1;
+       if ((have=high-memptr) < need) {
+               if (sbrk(need > have + 1024 ? need-have:1024) == -1)
+                       error(EOUTOFMEM);
+               high = sbrk(0);
+       }
+       wp = memptr;
+       cnt = (need >> 1) & 077777;
+       do {
+               *wp++ = 0;
+       } while (--cnt);
+       wp = memptr;
+       memptr =+ need;
+       stklim();
+       return(wp);
+}
+
+setmem()
+{
+       high = bottmem = memptr = sbrk(0);
+       stklim();
+}
+
+free(cptr)
+       char *cptr;
+{
+}
+
+stklim()
+{
+       maxstk = ((memptr + 07777) &~ 07777) + 512;
+}