PDP-10 / its

Incompatible Timesharing System
Other
862 stars 83 forks source link

CONS microcode, and assembler #1424

Open larsbrinkhoff opened 5 years ago

larsbrinkhoff commented 5 years ago

LISPM1; UCONS 975
LISPM; CDMP 42
LISPM1; CONSLP 251

larsbrinkhoff commented 5 years ago

I don't know what the depedencies are, or how they should be loaded. I also don't know what the relationship is between CDMP and CONSLP, or if there are more parts.

larsbrinkhoff commented 5 years ago

First try, load CONSLP:

;IF-FOR-MACLISP UNDEFINED FUNCTION OBJECT

Ok, IF-FOR-MACLISP is defined in LISPM2; LMMAC 128. Or maybe DEFMAC 45, or IFMAC 1.

So first load LMMAC:

;DEFSUBST UNDEFINED FUNCTION OBJECT

Hey, it should also be defined in LMMAC. But it's used before it's defined! Ok, maybe load LISPM first?

Yes, now LMMAC loads fine. And CONSLP too! Success.

larsbrinkhoff commented 5 years ago

Now, how to load and assemble the microcode source code file, LISPM1; UCONS 975?

Just load it? Nope.

;BKPT GC-OVERFLOW

The entry point seems to be CONS-LAP. There's no ASSEMBLE like in CADRLP. But it needs a U-CODE input parameter, presumably the UCONS symbol or its value as defined in the UCONS file.

Likely GC-OVERFLOW means the memory is full. Should try to compile all files first before loading.

larsbrinkhoff commented 5 years ago

Tried setting allocations according to LISPM; * LISP, but that didn't work.


(COMMENT CORE 160 LIST 140000 SYMBOL 13000 FIXNUM 40000 BIGNUM 10000)
larsbrinkhoff commented 5 years ago

Typed ^D to get more GC information:


(load "lispm1; ucons")
;ADDING A NEW FIXNUM SEGMENT -- FIXNUM SPACE NOW 10000 WORDS
;GC DUE TO LIST AND SYMBOL SPACES
; 65[0%] LIST, 526[8%] FIXNUM, 1000[100%] FLONUM, 
; 770[98%] BIGNUM, 0[0%] SYMBOL, 754[96%] ARRAY WORDS FREE
;ADDING 13 NEW LIST SEGMENTS -- LIST SPACE NOW 65000 WORDS
;ADDING A NEW FIXNUM SEGMENT -- FIXNUM SPACE NOW 11000 WORDS
;ADDING A NEW SYMBOL SEGMENT -- SYMBOL SPACE NOW 5000 WORDS

;GC DUE TO LIST SPACE
; 0[0%] LIST, 326[4%] FIXNUM, 1000[100%] FLONUM, 
; 770[98%] BIGNUM, 401[10%] SYMBOL, 754[96%] ARRAY WORDS FREE
;ADDING 16 NEW LIST SEGMENTS -- LIST SPACE NOW 103000 WORDS
;ADDING 2 NEW FIXNUM SEGMENTS -- FIXNUM SPACE NOW 13000 WORDS

;ADDING A NEW SYMBOL SEGMENT -- SYMBOL SPACE NOW 6000 WORDS
;GC DUE TO LIST SPACE
; 0[0%] LIST, 1012[9%] FIXNUM, 1000[100%] FLONUM, 
; 770[98%] BIGNUM, 712[14%] SYMBOL, 754[96%] ARRAY WORDS FREE
;ADDING 21 NEW LIST SEGMENTS -- LIST SPACE NOW 124000 WORDS
;ADDING 2 NEW FIXNUM SEGMENTS -- FIXNUM SPACE NOW 15000 WORDS

;GC DUE TO LIST SPACE
; 0[0%] LIST, 1447[12%] FIXNUM, 1000[100%] FLONUM, 
; 770[98%] BIGNUM, 150[3%] SYMBOL, 754[96%] ARRAY WORDS FREE
;ADDING 25 NEW LIST SEGMENTS
; BUT DIDN'T SUCCEED -- LIST SPACE NOW 141000 WORDS
;ADDING 2 NEW FIXNUM SEGMENTS -- FIXNUM SPACE NOW 17000 WORDS
;ADDING A NEW SYMBOL SEGMENT -- SYMBOL SPACE NOW 7000 WORDS

;BKPT GC-OVERFLOW
ams commented 5 years ago

You probobly should use READFILE or equivalent to read the ucode. CONS-LAP should take a symbol, which should be the ucode.

To make it simpler, you could try the following incantation:

(setq ucons '(
(locality m-mem)
(m-garbage (0)))
(cons-lap ucons)  ; or 'ucode?
larsbrinkhoff commented 5 years ago

CONSLP calls ALLREMPROP defined in LISPM; UTIL.

Needs PAGE-SIZE defined in LISPM; QCOM.

ams commented 5 years ago

I don't know what the depedencies are, or how they should be loaded. I also don't know what the relationship is between CDMP and CONSLP, or if there are more parts.

The dependencies for CADRLP are the following, which shouldn't be much dissimilar to CONSLP:

(PACKAGE-DECLARE MICRO-ASSEMBLER GLOBAL 5000.  ;actually uses about 3028.
   (("LISPM;COMPAT QFASL" DEFS) ;Needed to compile, I guess also to run
    ;Order of these files may be important, I'm not sure...
    ("LISPM;CADRLP QFASL")  ;Assembler itself
     ;Load QCOM after CADRLP because it needs LOGDPB
    ("LISPM;QCOM >")        ;System constant definitions
    ("LISPM;CDMP QFASL")    ;Writing out the results
    ("LCADR;QWMCR QFASL")   ;Writing out the results also
    ("LMIO;FREAD QFASL")    ;Fast reader
    ("LISPM;DEFMIC >")      ;Microcode entry definitions
    ("LISPM;CADSYM >")      ;Machine definitions
    ("LISPM2;USYMLD QFASL"))    ;Stuff to augment microcode of running machine, etc.
   (SHADOW FIXNUM INCLUDE)  ;COMPAT redefines these as functions
   (SHADOW AREA-LIST)       ;Things which QCOM would bash nicely
   (MYREFNAME GLOBAL UA))

This is modolus any #+MACLISP hacks ofcourse.

larsbrinkhoff commented 5 years ago

Got things to load with this:


(alloc '(list 350000 fixnum 100000 bignum 20000 symbol 20000))
larsbrinkhoff commented 5 years ago

CONS-LAP wants UCODE passed in, not a symbol. However:

;PAGE-SIZE UNBOUND VARIABLE

This is defined in LISPM; QCOM, but loading that says

;LOGDPB UNDEFINED FUNCTION OBJECT

CADRLP has a definitions for this that CONSLP lacks. There's also a definition in LISPM; UTIL1, but loading that doesn't work:

;(GETDDTSYM TYPEP) CAN'T GET DDT SYMBOL - FASLOAD

Apparently, symbols need to be loaded for GETDDTSYM to work. Is there a way to do that from Maclisp? In any case the hackish (valret "$^K$P") works. Now UTIL1 and QCOM can be loaded.

larsbrinkhoff commented 5 years ago

The assembler is running, but runs into a problem:


(SKIP-IF-ATOM 37)((1637 1640) DISPATCH-BLOCK-UNDERFLOW WARN)
(SKIP-IF-LIST 37)((1577 1600) DISPATCH-BLOCK-UNDERFLOW WARN)
(D-QMRCL 37)((1537 1540) DISPATCH-BLOCK-UNDERFLOW WARN)
(CAR-PRE-DISPATCH 37)((1477 1500) DISPATCH-BLOCK-UNDERFLOW WARN)
(CDR-PRE-DISPATCH 37)((1437 1440) DISPATCH-BLOCK-UNDERFLOW WARN)
(QRACDT 37)((1337 1340) DISPATCH-BLOCK-UNDERFLOW WARN)
(QRDCDT 37)((1277 1300) DISPATCH-BLOCK-UNDERFLOW WARN)
(ERROR-UNLESS-FIX 37)((1237 1240) DISPATCH-BLOCK-UNDERFLOW WARN)
(TRAP-UNLESS-FIX 37)((1177 1200) DISPATCH-BLOCK-UNDERFLOW WARN)
(ILLOP-ON-BAD-FUNCTION-DATA-TYPE 37)((1137 1140) DISPATCH-BLOCK-UNDERFLOW WARN!
)
(TRAP-UNLESS-SYM 37)((537 540) DISPATCH-BLOCK-UNDERFLOW WARN)
(POPJ-IF-NOT-NUMBER 37)((477 500) DISPATCH-BLOCK-UNDERFLOW WARN)
(XARGI-DISPATCH 37)((437 440) DISPATCH-BLOCK-UNDERFLOW WARN)
(QMXRT 37)((377 400) DISPATCH-BLOCK-UNDERFLOW WARN)
(QMXRT1 37)((337 340) DISPATCH-BLOCK-UNDERFLOW WARN)
(D-TRANSPORT 76)((276 300) DISPATCH-BLOCK-UNDERFLOW WARN)
(A-SECOND-LEVEL-MAP-REUSE-POINTER-INIT 2)(P-BIT UNDEFINED-SYM WARN)
(A-SECOND-LEVEL-MAP-REUSE-POINTER-INIT 2)(R-BIT UNDEFINED-SYM WARN)
;NIL NON-NUMERIC VALUE

;BKPT WRNG-TYPE-ARG
larsbrinkhoff commented 5 years ago

Maybe bit rot in microcode or assembler?

;;; DISPATCH TABLES

(LOCALITY D-MEM)

(LOC 1777) ;LAST LOCATION IN D-MEMORY MUST BE DROP THROUGH FOR TRANSPORTER TO WORK RIGHT.
        (P-BIT R-BIT)
(END-DISPATCH)

At this point, DISPATCH-CONSTANT has never been set, so it's still NIL. However, trying to store a word at 1777 in D memory wants to increase DISPATCH-CONSTANT by 1. I worked around this by checking for NIL and skipping the add.

larsbrinkhoff commented 5 years ago

Having fixed that, next problem is that %SYS-COM-#-AREAS is undefined (the symbol needs # quoted by \ in the source text). It looks like it should be in the SYSTEM-COMMUNICATION-AREA-QS list in LISPM; QCOM. Maybe it was dropped for CADR?

This makes the entire QCOM 437 file questionable. Will it work for the CONS?

larsbrinkhoff commented 5 years ago

CONSLP-OUTPUT needs to be set to indicate the output filename.

These are similar to %SYS-COM-#-AREAS:

I don't know about %%AREA-MODE-FREE-STORAGE.

SG-INITIAL-FCTN-INDEX has been renamed to SG-INITIAL-FUNCTION-INDEX.

MICRO-CODE-SYMBOL-VECTOR is missing. Has is been renamed MICRO-CODE-SYMBOL-IMAGE?

larsbrinkhoff commented 5 years ago

More undefined symbols:

With those in place I finally get


LOCATIONS-USED 
(A-MEM 367) 
(M-MEM 37) 
(I-MEM 7670) 
(D-MEM 1747) 

;BKPT (QUOTE FINISHED)
larsbrinkhoff commented 5 years ago

Had to continue past three (BREAK 'FOO). There are also lots of warnings, so I assume something is not quite right.

larsbrinkhoff commented 5 years ago

I-MEM should be filled to 7642 according to LISPM1; UCONS LOCS. The other memories are right.

larsbrinkhoff commented 5 years ago

You're supposed to call CONS-DUMP-MEMORIES in CDMP to get the file UCONS ULOAD, but it says:

;PACKAGE UNBOUND VARIABLE

I see this:

        (LET (#Q (PACKAGE (PKG-FIND-PACKAGE "MICRO-ASSEMBLER")))

I think #Q means evaluate following form if running on a Lispm. There's also #M for Maclisp.

Looks like this code rotted and no longer works as is in Maclisp.

larsbrinkhoff commented 5 years ago

Works OK if LMCONS; CADREG is loaded first. I assume LISPM; CONREG would be more appropriate, but that file is missing.

I did get a UCONS ULOAD file, and it does look similar to the original one. I wouldn't expect it to work due to the large number of diagnostic messages from the assembler.

larsbrinkhoff commented 5 years ago

I used this to load everything and run the assembler:


(comment core 160 list 350000 fixnum 100000 bignum 20000 symbol 20000)

(load "liblsp; lispm")
(load "lispm2; lmmac")
(load "lispm; util")
(valret "◊^K◊P") ;Load symbols.
(load "lispm; util1")
(load "lispm; qcom")
(load "lispm; consym")

(setq conslp-output 'ucons)
(setq %%area-mode-free-storage 0)
(setq %%area-mode-access-status-and-meta-bits 0)
(setq dtp-forward 0)
(setq micro-code-symbol-vector nil)
(setq %pht-map-status-second-level-map-not-valid 0)
(setq sg-reg-pdl-array 0)
(setq SG-LINEAR-BINDING-ARRAY 0)

(load "lispm1; conslp")
(load "lmcons; cadreg")
(load "lispm; cdmp")

;(setq ^D t)
(load "lispm1; ucons")

(cons-lap ucons)
larsbrinkhoff commented 5 years ago

About MICRO-CODE-SYMBOL-VECTOR, from LISPM; MLAP.


;MICRO-CODE-SYMBOL-AREA is divided in two sections.  0-577 are ref'ed by
;MISC instructions 200-777, and may also be ref'ed by DTP-U-ENTRY's as described above.
;600-777 are entries to microcompiled functions.   (The old MICRO-CODE-SYMBOL-VECTOR
;which used these has been flushed.)
larsbrinkhoff commented 5 years ago

LISPM1; ARC: QL 181 sets MICRO-CODE-SYMBOL-VECTOR to a list of symbols. That archive also has ULAP 86 which looks like it could be an older version of CONSLP.

ams commented 5 years ago

@aap Do you think there is an opportunity to ask some questions to Greenblatt? I can write them up.

larsbrinkhoff commented 5 years ago

There will be an opportunity in March!

larsbrinkhoff commented 5 years ago

From AI memo 444:

We do not yet have a microcompiler, but a prototype of one was written and heavily used as part of the Lisp machine simulator. It compiles for the PDP-10 rather than CONS, but uses similar techniques and a similar interface to the built-in microcode.

I think I have seen traces of this.

larsbrinkhoff commented 5 years ago

CURRENT STATUS (August 1977)

  The original prototype CONS machine was designed and built somewhat more than two years ago. It had no memory and no I/O capability, and remained pretty much on the back burner while software was developed with a simulator on the PDP-10 (the simulator executed the Lisp machine macro instruction set, a function now performed by CONS microcode.) Microprogramming got under way a little over a year ago, and in the beginning of 1977 the machine got memory, a disk, and a terminal.   We now have an almost-complete system running on the prototype machine. The major remaining "holes" are the lack of a garbage collector and the presence of only the most primitive error handling. Also, floating-point and big-integer numbers and microcompilation have been put off until he next machine. The system includes almost all the functions of Maclisp, and quite a few new ones. The machine is able to page off of its disk, accept input from the keyboard and the mouse, display on the TV, and do I/O to files on the PDP-10. The display editor is completely working, and the compiler runs on the machine, so the system is quite usable for typing in, editing, compiling, and debugging Lisp functions.   As a demonstration of the system, and a test of its capabilities, two large programs have been brought over from the PDP-10. William Woods's LUNAR English-language data-base query system was converted from InterLisp to Maclisp, thence to Lisp machine Lisp. On the Lisp machine it runs approximately 3 times as fast as in Maclisp on the KA-10, which in turn is 2 to 4 times as fast as in InterLisp. Note that the Lisp machine time is elapsed real time, while the PDP-10 times are virtual run times as given by the operating system and do not include the delays due to timesharing.   Most of the Macsyma symbolic algebraic system has been converted to the Lisp machine; nearly all the source files were simply compiled without any modifications. Most of Macsyma works except for some things that require bignums. The preliminary speed is the same as on the KA-10, but a number of things have not been optimally converted. (This speed measurement is, again, elapsed time on the Lisp machine version versus reported run tim on the KA-10 time sharing system. Thus, paging and scheduling overhead in the KA-10 case are not counted in this measurement.)   LUNAR (including the dictionary) and Macsyma can reside together in the Lisp machine with plenty of room left over; either program alone will not entirely fit in a PDP-10 address space.   The CONS machine is currently being redesigned, and a new machine will be built soon, replacing our present prototype. The new machine will have larger sizes for certain internal memories, will incorporate newer technology, will have greatly improved packaging, and will be faster. It will fit entirely in one cabinet and will be designed for ease of construction and servicing. In late 1977 and early 1978 we plan to build seven additional machines and install them at the MIT AI Lab. During he fall of 1977 we plan to finish the software, bringing it to a point where users can be put on the system.