     1 000000           ; > RK07boot
     2 000000           ;
     3 000000           ; RK07 Bootstrap with unit choice 
     4 000000           ; (Adapted from RT-11 Ver.4.0 Sysgen Manual Appendix)
     5 000000           ; Asks for unit number before booting
     6 000000           ;
     7 000000                   ORG     O1000
     8 001000           ;
     9 001000 012706            MOV     #O1000,R6       ; set up stack 
     9 001002 001000    
    10 001004 012701            MOV     #O177440,R1     ; CSR in R1
    10 001006 177440    
    11 001010 004737            JSR     R7,@#crlf
    11 001012 001104    
    12 001014 004537            JSR     R5,@#mssg
    12 001016 001134    
    13 001020 <string>          DEFS 
    14 001036    000            DEFB    0
    15 001037 000000            ALIGN
    16 001040 004737            JSR     R7,@#getv       ; Get value 0-7
    16 001042 001162    
    17 001044 010061            MOV     R0,8(R1)        ; Unit number to 177450
    17 001046 000010    
    18 001050 012711            MOV     #O2003,(R1)     ; RK07 pack acknowledge to CSR
    18 001052 002003    
    19 001054 032711    test1:  BIT     #O100200,(R1)   ; wait for ready response
    19 001056 100200    
    20 001060 001775            BEQ     test1
    21 001062 012761            MOV     #O177400,2(R1)  ; two's complemented word count to RKWC
    21 001064 177400    
    21 001066 000002    
    22 001070 012711            MOV     #O2021,(R1)     ; read data command (bit 10 set for RK07)
    22 001072 002021    
    23 001074 032711    test2:  BIT     #O100200,(R1)   ; wait till done
    23 001076 100200    
    24 001100 001775            BEQ     test2
    25 001102 005007            CLR     R7              ; jump to locn 0
    26 001104           ;
    27 001104 012705    crlf:   MOV     #13,R5          ; print <CR> and <LF> on console
    27 001106 000015    
    28 001110 004737            JSR     R7,@#prta
    28 001112 001120    
    29 001114 012705            MOV     #10,R5          ; make <LF> and fall through to...
    29 001116 000012    
    30 001120           ;
    31 001120 105737    prta:   TSTB    @#O177564       ; wait for console XBUFF to be ready
    31 001122 177564    
    32 001124 100375            BPL     prta
    33 001126 010537            MOV     R5,@#O177566
    33 001130 177566    
    34 001132 000207            RTS     R7
    35 001134           ;
    36 001134 105737    mssg:   TSTB    @#O177564       ; prints message at word following call
    36 001136 177564    
    37 001140 100375            BPL     mssg
    38 001142 111537            MOVB    (R5),@#O177566  ; print char just past where we were
    38 001144 177566    
    39 001146 105725            TSTB    (R5)+           ; see if it was last, and point to next
    40 001150 001371            BNE     mssg            ; string is zero-terminated
    41 001152 005205            INC     R5              ; in case it's not on a word boundary
    42 001154 042705            BIC     #1,R5           ; in case it was
    42 001156 000001    
    43 001160 000205            RTS     R5
    44 001162           ;
    45 001162           ; This subroutine gets value 0-7 in R0 (also uses R5)
    46 001162           ;    null input gives value 0
    47 001162           ;    routine terminates on any CTRL char
    48 001162           ;    user can enter any printable char
    49 001162           ;    character will be converted to a single digit
    50 001162           ;
    51 001162 012705    getv:   MOV     #O100000,R5     ; set "no char yet" flag
    51 001164 100000    
    52 001166 105737    get:    TSTB    @#O177560       ; wait for character at console
    52 001170 177560    
    53 001172 100375            BPL     get
    54 001174 042705            BIC     #O377,R5        ; use clear/set instead of MOVB
    54 001176 000377    
    55 001200 153705            BISB    @#O177562,R5    ; MOVB extends sign into high byte, so destroys my flag
    55 001202 177562    
    56 001204 122705            CMPB    #O40,R5
    56 001206 000040    
    57 001210 100410            BMI     deltst
    58 001212 005705            TST     R5              ; is there a char already
    59 001214 100005            BPL     return
    60 001216 005000            CLR     R0              ; if no char, make unit #0
    61 001220 012705            MOV     #O60,R5         ; ascii 0
    61 001222 000060    
    62 001224 004737            JSR     R7,@#prta
    62 001226 001120    
    63 001230 000207    return: RTS     R7
    64 001232 122705    deltst: CMPB    #O177,R5        ; delete ?
    64 001234 000177    
    65 001236 001007            BNE     okchar
    66 001240 005705            TST     R5
    67 001242 100751            BMI     get             ; if no char on screen, ignore delete
    68 001244 004537            JSR     R5,@#mssg
    68 001246 001134    
    69 001250    010            DEFB    8               ; sequence of backsp,space,backsp
    70 001251    040            DEFB    32
    71 001252    010            DEFB    8
    72 001253    000            DEFB    0
    73 001254                   ALIGN
    74 001254 000742            BR      getv            ; set "no char" and go for next
    75 001256 110500    okchar: MOVB    R5,R0           ; save char, but leave flag for now
    76 001260 005705            TST     R5
    77 001262 100404            BMI     doit
    78 001264 012705            MOV     #8,R5           ; if not 1st char, do backspace
    78 001266 000010    
    79 001270 004737            JSR     R7,@#prta
    79 001272 001120    
    80 001274 042700    doit:   BIC     #O177770,R0     ; ensure range is 0-7
    80 001276 177770    
    81 001300 010005            MOV     R0,R5           ; for printing - also now bit 15 clear
    82 001302 052705            BIS     #O60,R5         ; make ascii
    82 001304 000060    
    83 001306 004737            JSR     R7,@#prta
    83 001310 001120    
    84 001312 000725            BR      get
