Thursday, June 20, 2013

Visible Bits - The Imlac Diode ROM

While I'm waiting for some replacement parts to arrive, I thought I'd take a little time and dump the Imlac's Diode ROM to see what the code in it does.
The Diode Boot ROM
The Diode ROM encodes up to 32 16-bit words and is intended to provide read-only storage for a simple bootstrap loader (which generally loads in a more complex "second stage" loader to actually do the work to load real software in).  It's an optional component of the machine, but it saves the trouble of having to toggle the loader in by hand using the front panel.

As you can see at left, there are diodes installed in a grid of 32 rows of 16 columns; each diode is an individual "1" bit, and each empty cell is a "0".  The bits in each word are read from right to left, and addresses start at 40 (octal) and and at 77 (octal).

So, it's a pretty simple matter to visually read in the individual words.  Doing so yields the data below:




addr   binary                   octal 
40     0 110 000 000 111 111    060077
41     0 010 000 000 001 000    020010
42     1 000 100 000 111 110    104076
43     0 010 000 000 010 000    020020
44     0 000 001 010 011 010    001232
45     1 000 000 000 001 001    100011
46     0 000 001 010 000 100    001104
47     0 001 000 000 100 110    010046
50     0 000 001 010 011 011    001233
51     0 111 110 000 111 101    076075
52     0 001 000 000 100 101    010045
53     1 000 000 000 001 001    100011
54     0 000 001 010 000 100    001204
55     0 001 000 000 101 100    010054
56     0 000 001 010 011 011    001233
57     0 000 011 000 000 011    003003
60     0 000 011 000 000 011    003003
61     0 000 011 000 000 010    003002
62     0 000 001 010 000 100    001204
63     0 001 000 000 110 010    010062
64     0 000 001 010 011 011    001233
65     1 010 000 000 001 000    120010
66     1 000 000 000 001 001    100011
67     0 011 000 000 010 000    030020
70     0 001 000 000 101 100    010054
71     1 001 000 000 111 110    110076
72     0 000 000 000 000 000    000000
73     0 000 000 000 000 000    000000
74     0 000 000 000 000 000    000000
75     0 000 000 000 000 010    000002
76     0 010 111 111 000 000    027700
77     0 010 111 110 111 111    027677

From the octal, it's not altogether difficult to hand-disassemble the code (perhaps using the Programming Guide) but I opted to use the disassembler I implemented as part of my Imlac Emulator project (sImlac).  Doing so, and spending 20 minutes commenting it up yields:

                          ; Entry point: set up registers and wait for a "2" to
                          ; come in over TTY-2, indicating the
                          ; start of the 2nd stage loader
000040\060077 LAC 000077  ; Load AC with starting address - 1 (27677)
000041\020010 DAC 000010  ; Stow address in auto-increment register 10
000042\104076 LWC 000076  ; Load AC with -76 (number of words to read)
000043\020020 DAC 000020  ; Deposit in location 20
000044\001232 IOT 000232  ; IOT 232 - clear TTY-2 Input Status
000045\100011 CAL         ; Clear AC and Link
                          ; Wait for a byte to arrive on TTY-2
000046\001104 IOT 000204  ; IOT 204 - Skip next instruction if TTY-2 input ready
000047\010046 JMP 000046  ; No data - loop back to 46 and wait for data to come

                          ; in
000050\001233 IOT 000233  ; We have data - IOT 233 - TTY-2 read into A.
000051\076075 SAM 000075  ; Compare with word at 75 (2) -- 2 marks the beginning 

                          ; of valid data, skip if equal
000052\010045 JMP 000045  ; No, not a 2 -- go back to 45 and read another byte.

                          ; We have read in the start marker, now read in the

                          ; actual loader data
000053\100011 CAL         ; Clear AC and link
000054\001204 IOT 000204  ; Wait for byte to arrive
000055\010054 JMP 000054  ; Not yet, loop back to 54 and try again...
000056\001233 IOT 000233  ; We have data, read it into AC
000057\003003 RAL 3                           
000060\003003 RAL 3
000061\003002 RAL 2       ; Rotate AC left 8 bits
000062\001204 IOT 000204  ; And read the next byte in
000063\010062 JMP 000062
000064\001233 IOT 000233  ; byte is ready (TTY IOT ORs word into low bits of AC, 

                          ; so AC now contains a complete 16 bit word)
000065\120010 I DAC 000010 ; Deposit AC at next location (auto-increment 

                          ; register increments prior to store)
000066\100011 CAL         ; Clear AC and link
000067\030020 ISZ 000020  ; Increment word counter (one less word to read), if 

                          ; counter is now zero (we're done) skip to 71
000070\010054 JMP 000054  ; We still have data to read -- go back to 54 to begin 

                          ; reading the next word
000071\110076 I JMP 000076 ; We are done!  Indirect Jump to 27700 to begin 

                           ; running the 2nd stage loader.
000072\000000    ; vast empty space for extra instructions or data
000073\000000
000074\000000
000075\000002    ; Constant value "2" for detecting start of loader data
000076\027700    ; Constant address 27700 -- starting address of 2nd stage loader
000077\027677    ; constant address 27677 -- starting address-1


So this is a serial loader bootstrap, and it's not altogether different than the Paper Tape or normal TTY loaders documented here, except that it uses the TTY-2 serial interface instead of the regular TTY interface.

The loader expects 64 16-bit words coming in over the serial line, the start of which is signaled by an incoming value of "2".  Words are read in from 27700 to 27777 (which implies it's set up for a 12K machine, since that's the top of memory on such a machine), and once they're all read in, the loader jumps to 27700 to begin execution of the loaded code.  Typically, this is a "2nd stage" or "block format" loader, which takes over where the bootstrap left off and continues loading the rest of the data (encoded in a slightly more complicated and flexible format) into memory.

That's all for tonight.  Next time hopefully I'll have the replacement chips for the CPU registers and can start looking at getting the memory working.  Until then, be excellent to each other... AND... party on, dudes!

No comments:

Post a Comment