The Bootstrap Process (including LMC)


Basic BootStrap Process Requirements

LMC Bootstrap Loader Choices


Assumptions:

  1. the bootstrap code will be stored in ROM memory; 20 locations will be reserved for this purpose.
  2. the application program will be loaded from the "Input Slot"

Choices:

  1. Bootstrap Code Location
    1. First 20 Mailboxes Will Be Bootstrap ROM: this means that all "application" programs must be re-translated to start at mailbox 20
    2. Last 20 Mailboxes Will Be Bootstrap ROM: this means that the "Reset" button will need to be "re-wired" to set the Counter to 80 (instead of 00)
    3. Bootstrap ROM Will Be Somewhere In The Middle Of The Mailbox Range: this will be considered "unworkable" since it divides the available memory for "application" programs into two small areas (note, however, this is how it is arranged for IBM PC machines with more than 1 Megabyte of memory).

  2. Determining Size Of Application Program For Input
    1. Fixed Size Applications: all "application" programs will be the same size (padded with 00's or garbage if necessary to reach the maximum size)
    2. Terminated With A Sentinal Value: the problem with this method is determining what to use as a "terminal" value and how to permit this value to appear (for example as a DAT value) without signalling the end of the application program.
      The most common solution is to use a mechanism similar to that used for backslashes in C/C++ strings; in the string "...\t..." the \t has a "special meaning", namely "treate as a "tab" character; to get a single backslash, C/C++ requires that two be entered in a string e.g. "...\\t..." is treated as a single backslash followed by the letter "t". Similarly we could use the sequence 999 000 to signal end of input and require that 999 be duplicated when a single 999 value were intended (so the sequence ... 999 999 000 would be treated as a single 999 value followed by a 000 value, and not as an end of input signal).
    3. Prefix Run-Length Value: an initial number could be sent before the actual code, containing the number of mailbox values which were to follow in forming the "application" program/

Sample LMC Bootstrap Loader

Assumptions for LMC Bootstrap Loader

  1. Applications will continue to be loaded into RAM starting at mailbox location zero.
  2. The bootstrap code will be stored in high ROM memory; 20 locations with high mailbox addresses 80 to 99 will be reserved for this purpose. These 20 locations will be assumed to keep their values even when the LMC is powered off.
  3. The application program will be loaded into LMC RAM memory one word at a time from the "Input Slot". The very first word read will be a "prefix run-length" value giving the total number of words that follow to be loaded.
  4. The LMC must be modified to start executing at the location of the bootstrap loader - mailbox 80 - not a the usual counter location of zero. At power-on, the counter must start at 80 so that the bootstrap program is the first thing to execute.
  5. The LMC "Reset" button must also be modified to set the counter to the address of the bootstrap loader at 80, not to zero.

LMC Bootstrap Loader Pseudocode

input countOfWordsToLoad
set ptr to lowestAddressForApplications
while (--countOfWordsToLoad) >= 0
   input Word
   store Word to memory location given by ptr (i.e. Memory[ptr] = Word)
   ptr++
endwhile
jump to lowestAddressForApplications

Issues with LMC implementation

LMC Bootstrap Loader Mnemonic Code

The listing below is in standard 5-column format: Mailbox, Code, Label, Mnemonic, Operand, with comments added on the right.

=== ==== ===== ==== ========
MBX CODE LABEL MNEM OPERANDS
=== ==== ===== ==== ========
00             ORG  00     ; applications load here at location zero
00  980  START JMP  BOOT   ; kludge to start BOOT loader when RESET is pushed
         
76             ORG  76     ; reserve space in RAM in front of bootstrap loader
76  000  SRET  DAT         ; return address of subroutine, used by "CALL"
77  000  SSTO  DAT         ; subroutine copied here from ROM:  STO 00    (200)
78  000  SJMP  DAT         ; subroutine copied here from ROM:  JMP SRET  (976)
         
79  000  COUNT DAT         ; variable - program length - first value input
         
80             ORG  80     ; start of BOOT: read-only ROM part of bootstrap loader
80  500  BOOT  IN          ; first input is length of the program being loaded
81  279        STO  COUNT
                           ; copy small two-mailbox subroutine from ROM into RAM
82  198        LDA  XSTO   ;  - copy "STO START"  (machine code: 200)
83  277        STO  SSTO   ;
84  199        LDA  XJMP   ;  - copy "JMP SRET"   (machine code: 976)
85  278        STO  SJMP   ;
         
86  179  WHILE LDA  COUNT  ; loop while there are still words to be loaded
87  497        SUB  ONE
88  279        STO  COUNT
89  802        SKP         ; skip *into* loop body if count >= 0
90  900        JMP  START  ; load is done - jump to start application just loaded
         
91  500        IN
92  077        CALL SSTO   ; call the "store" subroutine copied to RAM above
         
93  177        LDA  SSTO   ; add one to the "STO" instruction (self-modifying!)
94  397        ADD  ONE    ;   so that it stores into the next memory location
95  277        STO  SSTO
         
96  986        JMP  WHILE
         
97  001  ONE   DAT  001    ; constant 001 (everything from 80 to 99 is in ROM)
98  200  XSTO  STO  START  ; constant 200 ("STO 00") - part of small subroutine
99  976  XJMP  JMP  SRET   ; constant 976 ("JMP SRET") - part of small subroutine

References