     1 000000           ; > DiscBash2   Reads/writes a sector using the RXV11 or F311-L11 controller, 
     2 000000           ;               to/from an address given by the user from the console.
     3 000000           ;
     4 000000           ;               Prompts user for track/sector (IN DECIMAL), address required (IN OCTAL).
     5 000000           ;
     6 000000                   ORG     1024            ; Octal 2000
     7 002000           ;
     8 002000 000401            BR      START
     9 002002 000000    STOP:   HALT
    10 002004 012706    START:  MOV     #1024,R6        ; initialise stack
    10 002006 002000    
    11 002010 000240    MLOOP:  NOP                     ; patch space
    12 002012 000240            NOP
    13 002014 000240            NOP
    14 002016 004737            JSR     R7,@#CRLF
    14 002020 002412    
    15 002022 004737            JSR     R7,@#CRLF
    15 002024 002412    
    16 002026 004537            JSR     R5,@#MSSG
    16 002030 002576    
    17 002032 <string>          DEFS 
    18 002055    240            DEFB    &A0
    19 002056                   ALIGN
    20 002056 004737            JSR     R7,@#GETV
    20 002060 002640    
    21 002062 010500            MOV     R5,R0           ; R0=track
    22 002064 004537            JSR     R5,@#MSSG
    22 002066 002576    
    23 002070 <string>          DEFS 
    24 002113    240            DEFB    &A0
    25 002114                   ALIGN
    26 002114 004737            JSR     R7,@#GETV
    26 002116 002640    
    27 002120 010501            MOV     R5,R1           ; R1=sector
    28 002122 004537            JSR     R5,@#MSSG
    28 002124 002576    
    29 002126 <string>          DEFS 
    30 002151    240            DEFB    &A0
    31 002152                   ALIGN
    32 002152 004737            JSR     R7,@#GETO
    32 002154 002724    
    33 002156 010502            MOV     R5,R2           ; R2=address
    34 002160 004537    COMMND: JSR     R5,@#MSSG
    34 002162 002576    
    35 002164 <string>          DEFS 
    36 002207    240            DEFB    &A0
    37 002210                   ALIGN
    38 002210 004737            JSR     R7,@#GETA
    38 002212 002624    
    39 002214 120527            CMPB    R5,#33
    39 002216 000041    
    40 002220 103670            BLO     STOP            ; any CTRL-char ends program
    41 002222 042705            BIC     #&FFA0,R5       ; ensure upper case
    41 002224 177640    
    42 002226 004737            JSR     R7,@#PRTA
    42 002230 002476    
    43 002232 012703            MOV     #7,R3           ; make for read
    43 002234 000007    
    44 002236 020527            CMP     R5,#ASC"R"
    44 002240 000122    
    45 002242 001417            BEQ     DISCOP
    46 002244 012703            MOV     #5,R3           ; nope, maybe write
    46 002246 000005    
    47 002250 020527            CMP     R5,#ASC"W"
    47 002252 000127    
    48 002254 001341            BNE     COMMND
    49 002256 012737    WRITE:  MOV     #1,@#O177170    ; load FILL BUFFER command and GO bit
    49 002260 000001    
    49 002262 177170    
    50 002264 105737    WRLOOP: TSTB    @#O177170       ; look for DONE bit (O40) or TR bit (O200)
    50 002266 177170    
    51 002270 001775            BEQ     WRLOOP          ; if it was TST not TSTB you'd be checking for error
    52 002272 100003            BPL     DISCOP
    53 002274 112237    WRTBYT: MOVB    (R2)+,@#O177172 ; put a byte
    53 002276 177172    
    54 002300 000771            BR      WRLOOP
    55 002302 010337    DISCOP: MOV     R3,@#O177170    ; load READ/WRITE SECTOR command and GO bit
    55 002304 177170    
    56 002306 004737            JSR     R7,@#TREQ
    56 002310 002400    
    57 002312 010137            MOV     R1,@#O177172    ; load sector number
    57 002314 177172    
    58 002316 004737            JSR     R7,@#TREQ
    58 002320 002400    
    59 002322 010037            MOV     R0,@#O177172    ; load track number
    59 002324 177172    
    60 002326 004737            JSR     R7,@#DONE
    60 002330 002366    
    61 002332 022703            CMP     #7,R3           ; check command
    61 002334 000007    
    62 002336 001224            BNE     MLOOP           ; if not reading, we just finished the task
    63 002340 012737    READ:   MOV     #3,@#O177170    ; load EMPTY BUFFER command and GO bit
    63 002342 000003    
    63 002344 177170    
    64 002346 105737    RDLOOP: TSTB    @#O177170       ; look for DONE bit (O40) or TReq bit (O200)
    64 002350 177170    
    65 002352 001775            BEQ     RDLOOP
    66 002354 100215            BPL     MLOOP           ; finished if DONE set
    67 002356 000240    RDBYTE: NOP                     ; a small delay, necessary on LSI-11/23 for F311 to catch up
    68 002360 113722            MOVB    @#O177172,(R2)+ ; get a byte
    68 002362 177172    
    69 002364 000770            BR      RDLOOP
    70 002366           ;
    71 002366           ;
    72 002366 032737    DONE:   BIT     #O40,@#O177170  ; look for DONE bit
    72 002370 000040    
    72 002372 177170    
    73 002374 001774            BEQ     DONE
    74 002376 000207            RTS     R7
    75 002400           ;
    76 002400 032737    TREQ:   BIT     #O200,@#O177170 ; look for TRANSFER REQUEST bit
    76 002402 000200    
    76 002404 177170    
    77 002406 001774            BEQ     TREQ
    78 002410 000207            RTS     R7
    79 002412           ;
    80 002412           ; > Print_Lib   Library of console print subroutines
    81 002412           ;
    82 002412           ;               Includes PRTH - prints R5 (16 bits) in hex
    83 002412           ;                        PRTO - prints R5 (16 bits) in octal
    84 002412           ;                        PRTA - prints R5 (8 bits) in ASCII
    85 002412           ;                        MSSG - prints the string following the JSR
    86 002412           ;                               (terminate with top-bit-set character/byte)
    87 002412           ;                        CRLF - prints carriage-return/linefeed
    88 002412           ;
    89 002412           ;       All subroutines link with R7 except MSSG (link with R5)
    90 002412           ;
    91 002412           ;
    92 002412 012705    CRLF:   MOV     #13,R5          ; print <CR> and <LF> on console
    92 002414 000015    
    93 002416 004737            JSR     R7,@#PRTA
    93 002420 002476    
    94 002422 012705            MOV     #10,R5
    94 002424 000012    
    95 002426 004737            JSR     R7,@#PRTA
    95 002430 002476    
    96 002432 000207            RTS     R7
    97 002434           ;
    98 002434 010546    PRTH:   MOV     R5,-(R6)        ; print R5 in hex
    99 002436 006205            ASR     R5
   100 002440 006205            ASR     R5
   101 002442 006205            ASR     R5
   102 002444 006205            ASR     R5
   103 002446 004737            JSR     R7,@#HEX1
   103 002450 002460    
   104 002452 012605            MOV     (R6)+,R5
   105 002454 042705            BIC     #&F0,R5
   105 002456 000360    
   106 002460 052705    HEX1:   BIS     #ASC"0",R5      ; make hex into ASCII and print it
   106 002462 000060    
   107 002464 122705            CMPB    #ASC"9",R5
   107 002466 000071    
   108 002470 100002            BPL     PRTA
   109 002472 062705            ADD     #7,R5
   109 002474 000007    
   110 002476           ;
   111 002476 105737    PRTA:   TSTB    @#O177564       ; wait for console XBUFF to be ready
   111 002500 177564    
   112 002502 100375            BPL     PRTA
   113 002504 010537            MOV     R5,@#O177566
   113 002506 177566    
   114 002510 000207            RTS     R7
   115 002512           ;
   116 002512 010046    PRTO:   MOV     R0,-(R6)        ; save R0,R4 on stack
   117 002514 010446            MOV     R4,-(R6)
   118 002516 010504            MOV     R5,R4
   119 002520 012705            MOV     #O30,R5         ; R4 will be 6x after shifts
   119 002522 000030    
   120 002524 006104            ROL     R4              ; rotate 1 bit from R4 to R5
   121 002526 006105            ROL     R5
   122 002530 004737            JSR     R7,@#PRTA       ; print - as ASCII since it's 6x
   122 002532 002476    
   123 002534 012700            MOV     #5,R0           ; set to do five octets
   123 002536 000005    
   124 002540 012705    CLOOP:  MOV     #6,R5           ; 6>>3 becomes octal 60, ie "0"
   124 002542 000006    
   125 002544 006104            ROL     R4              ; rotate R4>R5: 3 bits of octal number
   126 002546 006105            ROL     R5              ; could use ASHC R4,#3 if we have EIS
   127 002550 006104            ROL     R4
   128 002552 006105            ROL     R5
   129 002554 006104            ROL     R4
   130 002556 006105            ROL     R5
   131 002560 004737            JSR     R7,@#PRTA       ; print a digit
   131 002562 002476    
   132 002564 005300            DEC     R0              ; one less digit to do
   133 002566 001364            BNE     CLOOP
   134 002570 012604            MOV     (R6)+,R4        ; restore caller's R4,R0
   135 002572 012600            MOV     (R6)+,R0
   136 002574 000207            RTS     R7
   137 002576           ;
   138 002576 105737    MSSG:   TSTB    @#O177564       ; prints message at word following call
   138 002600 177564    
   139 002602 100375            BPL     MSSG
   140 002604 111537            MOVB    (R5),@#O177566  ; print char just past where we were
   140 002606 177566    
   141 002610 105725            TSTB    (R5)+           ; see if it was last, and point to next
   142 002612 100371            BPL     MSSG            ; top bit set = finished
   143 002614 005205            INC     R5              ; in case it's not on a word boundary
   144 002616 042705            BIC     #1,R5           ; in case it was
   144 002620 000001    
   145 002622 000205            RTS     R5
   146 002624           ;
   147 002624           ; > Input_Lib   Library of subroutines to call console for input.
   148 002624           ;
   149 002624           ;               Includes GETA - gets a single ASCII character in R5
   150 002624           ;                        GETV - gets a 16-bit decimal value in R5.
   151 002624           ;                        GETO - gets a 16-bit octal value in R5
   152 002624           ;                        GETH - gets a 16-bit hex value in R5
   153 002624           ;                        GETS - gets a string to the buffer located by R5
   154 002624           ;                               Size of buffer must be in R4.
   155 002624           ;
   156 002624           ;   All routines linked to by R7.
   157 002624           ;
   158 002624 105737    GETA:   TSTB    @#O177560       ; wait for character
   158 002626 177560    
   159 002630 100375            BPL     GETA
   160 002632 013705            MOV     @#O177562,R5
   160 002634 177562    
   161 002636 000207            RTS     R7
   162 002640           ;
   163 002640 005046    GETV:   CLR     -(R6)           ; clear a word on the stack
   164 002642 004737    GETV1:  JSR     R7,@#GETA       ; get a character
   164 002644 002624    
   165 002646 022705            CMP     #33,R5
   165 002650 000041    
   166 002652 100404            BMI     DECIN           ; terminate on any control char or space
   167 002654 004737            JSR     R7,@#CRLF       ; ***** remove if not required *****
   167 002656 002412    
   168 002660 012605            MOV     (R6)+,R5
   169 002662 000207            RTS     R7
   170 002664 020527    DECIN:  CMP     R5,#ASC"0"      ; check character>="0"
   170 002666 000060    
   171 002670 100764            BMI     GETV1
   172 002672 022705            CMP     #ASC"9",R5      ; check character<="9"
   172 002674 000071    
   173 002676 100761            BMI     GETV1
   174 002700 004737            JSR     R7,@#PRTA       ; ***** remove if not required *****
   174 002702 002476    
   175 002704 042705            BIC     #ASC"0",R5      ; ascii-to-decimal
   175 002706 000060    
   176 002710 006316            ASL     (R6)            ; times 2
   177 002712 061605            ADD     (R6),R5         ; add to the new value
   178 002714 006316            ASL     (R6)            ; times 4
   179 002716 006316            ASL     (R6)            ; times 8
   180 002720 060516            ADD     R5,(R6)         ; times 10, plus new value
   181 002722 000747            BR      GETV1
   182 002724           ;
   183 002724 005046    GETO:   CLR     -(R6)           ; stack space for value
   184 002726 004737    GETO1:  JSR     R7,@#GETA
   184 002730 002624    
   185 002732 022705            CMP     #33,R5          ; terminate on any control char or space
   185 002734 000041    
   186 002736 100404            BMI     OCTIN
   187 002740 004737            JSR     R7,@#CRLF       ; ***** remove if not required *****
   187 002742 002412    
   188 002744 012605            MOV     (R6)+,R5
   189 002746 000207            RTS     R7
   190 002750 020527    OCTIN:  CMP     R5,#ASC"0"      ; if not CR, test for numeric
   190 002752 000060    
   191 002754 100764            BMI     GETO1
   192 002756 020527            CMP     R5,#ASC"8"
   192 002760 000070    
   193 002762 100361            BPL     GETO1
   194 002764 004737            JSR     R7,@#PRTA       ; ***** remove if not required *****
   194 002766 002476    
   195 002770 042705            BIC     #&F8,R5         ; mask off to make octal
   195 002772 000370    
   196 002774 006316            ASL     (R6)            ; move one octet
   197 002776 006316            ASL     (R6)
   198 003000 006316            ASL     (R6)
   199 003002 060516            ADD     R5,(R6)         ; add this octet
   200 003004 000750            BR      GETO1
   201 003006           ;
   202 003006 005046    GETH:   CLR     -(R6)           ; clear a word on the stack
   203 003010 004737    GETH1:  JSR     R7,@#GETA
   203 003012 002624    
   204 003014 022705            CMP     #33,R5          ; terminate on any control char or space
   204 003016 000041    
   205 003020 100404            BMI     HEXIN
   206 003022 004737            JSR     R7,@#CRLF       ; ***** remove if not required *****
   206 003024 002412    
   207 003026 012605            MOV     (R6)+,R5
   208 003030 000207            RTS     R7
   209 003032 020527    HEXIN:  CMP     R5,#ASC"0"
   209 003034 000060    
   210 003036 100764            BMI     GETH1
   211 003040 022705            CMP     #ASC"F",R5
   211 003042 000106    
   212 003044 100761            BMI     GETH1
   213 003046 022705            CMP     #ASC"9",R5
   213 003050 000071    
   214 003052 100003            BPL     OKVAL
   215 003054 020527            CMP     R5,#ASC"A"
   215 003056 000101    
   216 003060 100753            BMI     GETH1
   217 003062 004737    OKVAL:  JSR     R7,@#PRTA       ; ***** remove if not required *****
   217 003064 002476    
   218 003066 022705            CMP     #ASC"9",R5
   218 003070 000071    
   219 003072 100003            BPL     $+6
   220 003074 162705            SUB     #ASC"A"-ASC"9",R5
   220 003076 000010    
   221 003100 042705            BIC     #ASC"0",R5
   221 003102 000060    
   222 003104 006316            ASL     (R6)
   223 003106 006316            ASL     (R6)
   224 003110 006316            ASL     (R6)
   225 003112 006316            ASL     (R6)
   226 003114 060516            ADD     R5,(R6)
   227 003116 000734            BR      GETH1
   228 003120           ;
