Difference between revisions of "PDP-11 Bootstrap Loader"

From Computer History Wiki
Jump to: navigation, search
m (Better cat)
(Replaced bootstrap code with valid macro11 assembly that more closely matches the DEC documentation. Replaced "0x" placeholder text with "xx" to avoid confusion with C hex prefix. Added tables of possible xx and yyyyyy values.)
Line 16: Line 16:
  
 
This is the actual bootstrap program:
 
This is the actual bootstrap program:
LOAD = 0x7400 ; Buffer address
+
 
+
<pre>
  0x7744 016701 BEGIN: MOV DEVICE, R1 ; Get Device CSR
+
                        LOAD=xx7400          ; Buffer start address
  0x7746 000026
+
 
  0x7750 012702 LOOP: MOV (PC)+, R2 ; Get buffer offset
+
                        .=LOAD+0344          ; Start address of bootstrap loader (xx7744)
  0x7752 000352 OFFSET: .-LOAD
+
 
  0x7754 005211 INC @R1 ; Turn on reader
+
xx7744 016701 START: MOV DEVICE, R1       ; Get reader CSR address
  0x7756 105711 READY: TSTB @R1 ; Done?
+
xx7746 000026
  0x7760 100376 BPL READY
+
xx7750 012702 LOOP:   MOV #.-LOAD+2, R2   ; Get buffer pointer
  0x7762 116162 MOVB 2(R1), LOAD(R2) ; Transfer
+
xx7752 000352                               ;  (<--- pointer to buffer)
  0x7764 000002
+
xx7754 005211         INC @R1             ; Enable the paper tape reader
  0x7766 0x7400
+
xx7756 105711 WAIT:   TSTB @R1             ; Wait until data available
  0x7770 005267 INC OFFSET ; Bump buffer offset
+
xx7760 100376         BPL WAIT
  0x7772 177756
+
xx7762 116162         MOVB 2(R1), LOAD(R2) ; Transfer word to buffer
  0x7774 000765 BR LOOP
+
xx7764 000002
  0x7776 yyyyyy DEVICE: yyyyyy ; Input device CSR address
+
xx7766 xx7400
 +
xx7770 005267         INC LOOP+2          ; Increment pointer to buffer
 +
xx7772 177756
 +
xx7774 000765         BR LOOP             ; Continue reading (<--- modified branch instruction)
 +
xx7776 yyyyyy DEVICE: yyyyyy               ; Paper tape reader CSR address
 +
</pre>
 +
 
 +
When inputting the bootstrap program, the first word is loaded at location xx7744, where xx is replaced with the
 +
address of the highest memory bank available according to the following table:
 +
 
 +
{| class="wikitable" style="text-align:center;"
 +
! Memory Bank
 +
! Total Memory
 +
! Bootstrap<br>Location
 +
! xx Value
 +
|-
 +
| 0
 +
| 4K
 +
| 017744
 +
| 01
 +
|-
 +
| 1
 +
| 8K
 +
| 037744
 +
| 03
 +
|-
 +
| 2
 +
| 12K
 +
| 057744
 +
| 05
 +
|-
 +
| 3
 +
| 16K
 +
| 077744
 +
| 07
 +
|-
 +
| 4
 +
| 20K
 +
| 117744
 +
| 11
 +
|-
 +
| 5
 +
| 24K
 +
| 137744
 +
| 13
 +
|-
 +
| 6
 +
| 28K
 +
| 157744
 +
| 15
 +
|}
 +
 
 +
Note also that, when inputting the word at xx7766, the value (xx7400) should be similarly adjusted.
 +
 
 +
The value of the word at location xx7776 (yyyyyy) should be replaced with the CSR address of the desired paper tape reader, e.g.:
 +
 
 +
{| class="wikitable"
 +
|-
 +
| Console Paper Tape Reader
 +
| 177560
 +
|-
 +
| High-Speed Paper Taper Reader
 +
| 177550
 +
|}
  
 
==Bootstrap Loader format==
 
==Bootstrap Loader format==

Revision as of 05:36, 5 March 2025

The PDP-11 Bootstrap Loader is a short program designed to be loaded into the main memory on a PDP-11 via the front panel; it is then run to load an initial program into the machine. I.e. it is a way of bootstrapping a totally empty machine, one with no ROM.

It is designed to be absolutely as short as possible (since it is manually toggled in via the switch register), and therefore has limitations, including how long a program can be loaded using it, and where in memory that program can be placed. The usual program to load with it is the PDP-11 Absolute Loader, which relaxes both of those limitations.

The original bootstrap loader is self-modifying code, since this allows a very short program. The program is not directly self-modifying; rather, the nature of its input is such that it modifies the bootstrap loader as it is read in. (Most bootstrap loader input files eventually restore the bootstrap loader to its original condition, allowing it to be re-used.)

Program

The bootstrap loader contains two locations which are modified by reading the input: the first is a pointer to the buffer in which to place data being read in; the second is a branch back to the beginning of the data input loop.

The program starts with the pointer set to itself, so the blank leader at the start of the data for the bootstrap loader (originally contained on paper tapes) starts with a special leader code which causes this to be left un-changed.

The buffer pointer is then modified to point it slightly before the bootstrap loader in memory, so at the end of the load the newly loaded code then progressively overlays the first several instructions of the bootstrap loader itself, finally patching the buffer pointer to point at the branch instruction, which is then modified to jump to the newly loaded code.

Code

This is the actual bootstrap program:

                        LOAD=xx7400          ; Buffer start address

                        .=LOAD+0344          ; Start address of bootstrap loader (xx7744)

xx7744  016701  START:  MOV DEVICE, R1       ; Get reader CSR address
xx7746  000026
xx7750  012702  LOOP:   MOV #.-LOAD+2, R2    ; Get buffer pointer
xx7752  000352                               ;   (<--- pointer to buffer)
xx7754  005211          INC @R1              ; Enable the paper tape reader
xx7756  105711  WAIT:   TSTB @R1             ; Wait until data available
xx7760  100376          BPL WAIT
xx7762  116162          MOVB 2(R1), LOAD(R2) ; Transfer word to buffer
xx7764  000002
xx7766  xx7400
xx7770  005267          INC LOOP+2           ; Increment pointer to buffer
xx7772  177756
xx7774  000765          BR LOOP              ; Continue reading (<--- modified branch instruction)
xx7776  yyyyyy  DEVICE: yyyyyy               ; Paper tape reader CSR address

When inputting the bootstrap program, the first word is loaded at location xx7744, where xx is replaced with the address of the highest memory bank available according to the following table:

Memory Bank Total Memory Bootstrap
Location
xx Value
0 4K 017744 01
1 8K 037744 03
2 12K 057744 05
3 16K 077744 07
4 20K 117744 11
5 24K 137744 13
6 28K 157744 15

Note also that, when inputting the word at xx7766, the value (xx7400) should be similarly adjusted.

The value of the word at location xx7776 (yyyyyy) should be replaced with the CSR address of the desired paper tape reader, e.g.:

Console Paper Tape Reader 177560
High-Speed Paper Taper Reader 177550

Bootstrap Loader format

The format of boostrap loader input is as follows:

  • Leader (all bytes 0351)
  • Load offset (1 byte)
  • Program to be loaded (up to 0344 bytes)
  • Copy of boostrap loader (first 6 bytes)
  • Offset to branch (1 byte)
  • Branch modification (1 byte)

Others

Several PDP-11 bootstrap ROMs, e.g. the BM792-YA, BM792-YK and BM873 ROM are prepared to read programs in bootstrap loader format. The code in them is obviously not self-modifying, but reacts to the bootstrap loader input format to produce the same effects.

ODT in the LSI-11 CPUs also has a command to load programs in bootstrap loader format.

Further reading

The Bootstrap Loader is documented in some detail in the "paper tape software programming handbook" (DEC-11-GGPB-D), pp. 6-1 to 6-8.