     1 000000           ; > DiscBash1   Reads a sector using the F311-L11 controller, and prints
     2 000000           ;               the contents of the sector on console.
     3 000000           ;
     4 000000           ;               Prompts user for track/sector required.
     5 000000           ;
     6 000000                   ORG     512             ; Octal 1000
     7 001000           ;
     8 001000 012706            MOV     #512,R6         ; initialise stack
     8 001002 001000    
     9 001004 004737            JSR     R7,@#CRLF
     9 001006 001232    
    10 001010 004737    LOOP:   JSR     R7,@#CRLF
    10 001012 001232    
    11 001014 004537            JSR     R5,@#MSSG
    11 001016 001416    
    12 001020 <string>          DEFS 
    13 001030    240            DEFB    &A0
    14 001031 000000            ALIGN
    15 001032 004737            JSR     R7,@#GETV
    15 001034 001460    
    16 001036 010500            MOV     R5,R0
    17 001040 004537            JSR     R5,@#MSSG
    17 001042 001416    
    18 001044 <string>          DEFS 
    19 001054    240            DEFB    &A0
    20 001055 000000            ALIGN
    21 001056 004737            JSR     R7,@#GETV
    21 001060 001460    
    22 001062 010501            MOV     R5,R1
    23 001064 004737            JSR     R7,@#DONE
    23 001066 001206    
    24 001070 012737            MOV     #7,@#O177170    ; load READ SECTOR command inc GO bit
    24 001072 000007    
    24 001074 177170    
    25 001076 004737            JSR     R7,@#TREQ
    25 001100 001220    
    26 001102 010137            MOV     R1,@#O177172    ; load sector number
    26 001104 177172    
    27 001106 004737            JSR     R7,@#TREQ
    27 001110 001220    
    28 001112 010037            MOV     R0,@#O177172    ; load track number
    28 001114 177172    
    29 001116 004737            JSR     R7,@#CRLF
    29 001120 001232    
    30 001122 005000            CLR     R0
    31 001124 004737            JSR     R7,@#DONE
    31 001126 001206    
    32 001130 012737            MOV     #3,@#O177170    ; load READ BUFFER command and GO bit
    32 001132 000003    
    32 001134 177170    
    33 001136 004737    BYTE:   JSR     R7,@#TREQ
    33 001140 001220    
    34 001142 013705            MOV     @#O177172,R5    ; get byte
    34 001144 177172    
    35 001146 004737            JSR     R7,@#PRTH
    35 001150 001254    
    36 001152 012705            MOV     #&20,R5         ; space after each byte
    36 001154 000040    
    37 001156 004737            JSR     R7,@#PRTA
    37 001160 001316    
    38 001162 005200            INC     R0
    39 001164 032700            BIT     #15,R0
    39 001166 000017    
    40 001170 001362            BNE     BYTE
    41 001172 004737            JSR     R7,@#CRLF         ; newline after every 16 bytes
    41 001174 001232    
    42 001176 032700            BIT     #128,R0
    42 001200 000200    
    43 001202 001755            BEQ     BYTE
    44 001204 000701            BR      LOOP
    45 001206           ;
    46 001206 032737    DONE:   BIT     #O40,@#O177170  ; look for DONE bit
    46 001210 000040    
    46 001212 177170    
    47 001214 001774            BEQ     DONE
    48 001216 000207            RTS     R7
    49 001220           ;
    50 001220 032737    TREQ:   BIT     #O200,@#O177170 ; look for TRANSFER REQUEST bit
    50 001222 000200    
    50 001224 177170    
    51 001226 001774            BEQ     TREQ
    52 001230 000207            RTS     R7
    53 001232           ;
    54 001232           ; > Print_Lib   Library of console print subroutines
    55 001232           ;
    56 001232           ;               Includes PRTH - prints R5 (16 bits) in hex
    57 001232           ;                        PRTO - prints R5 (16 bits) in octal
    58 001232           ;                        PRTA - prints R5 (8 bits) in ASCII
    59 001232           ;                        MSSG - prints the string following the JSR
    60 001232           ;                               (terminate with top-bit-set character/byte)
    61 001232           ;                        CRLF - prints carriage-return/linefeed
    62 001232           ;
    63 001232           ;       All subroutines link with R7 except MSSG (link with R5)
    64 001232           ;
    65 001232           ;
    66 001232 012705    CRLF:   MOV     #13,R5          ; print <CR> and <LF> on console
    66 001234 000015    
    67 001236 004737            JSR     R7,@#PRTA
    67 001240 001316    
    68 001242 012705            MOV     #10,R5
    68 001244 000012    
    69 001246 004737            JSR     R7,@#PRTA
    69 001250 001316    
    70 001252 000207            RTS     R7
    71 001254           ;
    72 001254 010546    PRTH:   MOV     R5,-(R6)        ; print R5 in hex
    73 001256 006205            ASR     R5
    74 001260 006205            ASR     R5
    75 001262 006205            ASR     R5
    76 001264 006205            ASR     R5
    77 001266 004737            JSR     R7,@#HEX1
    77 001270 001300    
    78 001272 012605            MOV     (R6)+,R5
    79 001274 042705            BIC     #&F0,R5
    79 001276 000360    
    80 001300 052705    HEX1:   BIS     #ASC"0",R5      ; make hex into ASCII and print it
    80 001302 000060    
    81 001304 122705            CMPB    #ASC"9",R5
    81 001306 000071    
    82 001310 100002            BPL     PRTA
    83 001312 062705            ADD     #7,R5
    83 001314 000007    
    84 001316           ;
    85 001316 105737    PRTA:   TSTB    @#O177564       ; wait for console XBUFF to be ready
    85 001320 177564    
    86 001322 100375            BPL     PRTA
    87 001324 010537            MOV     R5,@#O177566
    87 001326 177566    
    88 001330 000207            RTS     R7
    89 001332           ;
    90 001332 010046    PRTO:   MOV     R0,-(R6)        ; save R0,R4 on stack
    91 001334 010446            MOV     R4,-(R6)
    92 001336 010504            MOV     R5,R4
    93 001340 012705            MOV     #O30,R5         ; R4 will be 6x after shifts
    93 001342 000030    
    94 001344 006104            ROL     R4              ; rotate 1 bit from R4 to R5
    95 001346 006105            ROL     R5
    96 001350 004737            JSR     R7,@#PRTA       ; print - as ASCII since it's 6x
    96 001352 001316    
    97 001354 012700            MOV     #5,R0           ; set to do five octets
    97 001356 000005    
    98 001360 012705    CLOOP:  MOV     #6,R5           ; 6>>3 becomes octal 60, ie "0"
    98 001362 000006    
    99 001364 006104            ROL     R4              ; rotate R4>R5: 3 bits of octal number
   100 001366 006105            ROL     R5              ; could use ASHC R4,#3 if we have EIS
   101 001370 006104            ROL     R4
   102 001372 006105            ROL     R5
   103 001374 006104            ROL     R4
   104 001376 006105            ROL     R5
   105 001400 004737            JSR     R7,@#PRTA       ; print a digit
   105 001402 001316    
   106 001404 005300            DEC     R0              ; one less digit to do
   107 001406 001364            BNE     CLOOP
   108 001410 012604            MOV     (R6)+,R4        ; restore caller's R4,R0
   109 001412 012600            MOV     (R6)+,R0
   110 001414 000207            RTS     R7
   111 001416           ;
   112 001416 105737    MSSG:   TSTB    @#O177564       ; prints message at word following call
   112 001420 177564    
   113 001422 100375            BPL     MSSG
   114 001424 111537            MOVB    (R5),@#O177566  ; print char just past where we were
   114 001426 177566    
   115 001430 105725            TSTB    (R5)+           ; see if it was last, and point to next
   116 001432 100371            BPL     MSSG            ; top bit set = finished
   117 001434 005205            INC     R5              ; in case it's not on a word boundary
   118 001436 042705            BIC     #1,R5           ; in case it was
   118 001440 000001    
   119 001442 000205            RTS     R5
   120 001444           ;
   121 001444           ; > Input_Lib   Library of subroutines to call console for input.
   122 001444           ;
   123 001444           ;               Includes GETA - gets a single ASCII character in R5
   124 001444           ;                        GETV - gets a 16-bit decimal value in R5.
   125 001444           ;                        GETO - gets a 16-bit octal value in R5
   126 001444           ;                        GETH - gets a 16-bit hex value in R5
   127 001444           ;                        GETS - gets a string to the buffer located by R5
   128 001444           ;                               Size of buffer must be in R4.
   129 001444           ;
   130 001444           ;   All routines linked to by R7.
   131 001444           ;
   132 001444 105737    GETA:   TSTB    @#O177560       ; wait for character
   132 001446 177560    
   133 001450 100375            BPL     GETA
   134 001452 013705            MOV     @#O177562,R5
   134 001454 177562    
   135 001456 000207            RTS     R7
   136 001460           ;
   137 001460 005046    GETV:   CLR     -(R6)           ; clear a word on the stack
   138 001462 004737    GETV1:  JSR     R7,@#GETA       ; get a character
   138 001464 001444    
   139 001466 022705            CMP     #33,R5
   139 001470 000041    
   140 001472 100404            BMI     DECIN           ; terminate on any control char or space
   141 001474 004737            JSR     R7,@#CRLF       ; ***** remove if not required *****
   141 001476 001232    
   142 001500 012605            MOV     (R6)+,R5
   143 001502 000207            RTS     R7
   144 001504 020527    DECIN:  CMP     R5,#ASC"0"      ; check character>="0"
   144 001506 000060    
   145 001510 100764            BMI     GETV1
   146 001512 022705            CMP     #ASC"9",R5      ; check character<="9"
   146 001514 000071    
   147 001516 100761            BMI     GETV1
   148 001520 004737            JSR     R7,@#PRTA       ; ***** remove if not required *****
   148 001522 001316    
   149 001524 042705            BIC     #ASC"0",R5      ; ascii-to-decimal
   149 001526 000060    
   150 001530 006316            ASL     (R6)            ; times 2
   151 001532 061605            ADD     (R6),R5         ; add to the new value
   152 001534 006316            ASL     (R6)            ; times 4
   153 001536 006316            ASL     (R6)            ; times 8
   154 001540 060516            ADD     R5,(R6)         ; times 10, plus new value
   155 001542 000747            BR      GETV1
   156 001544           ;
   157 001544 005046    GETO:   CLR     -(R6)           ; stack space for value
   158 001546 004737    GETO1:  JSR     R7,@#GETA
   158 001550 001444    
   159 001552 022705            CMP     #33,R5          ; terminate on any control char or space
   159 001554 000041    
   160 001556 100404            BMI     OCTIN
   161 001560 004737            JSR     R7,@#CRLF       ; ***** remove if not required *****
   161 001562 001232    
   162 001564 012605            MOV     (R6)+,R5
   163 001566 000207            RTS     R7
   164 001570 020527    OCTIN:  CMP     R5,#ASC"0"      ; if not CR, test for numeric
   164 001572 000060    
   165 001574 100764            BMI     GETO1
   166 001576 020527            CMP     R5,#ASC"8"
   166 001600 000070    
   167 001602 100361            BPL     GETO1
   168 001604 004737            JSR     R7,@#PRTA       ; ***** remove if not required *****
   168 001606 001316    
   169 001610 042705            BIC     #&F8,R5         ; mask off to make octal
   169 001612 000370    
   170 001614 006316            ASL     (R6)            ; move one octet
   171 001616 006316            ASL     (R6)
   172 001620 006316            ASL     (R6)
   173 001622 060516            ADD     R5,(R6)         ; add this octet
   174 001624 000750            BR      GETO1
   175 001626           ;
   176 001626 005046    GETH:   CLR     -(R6)           ; clear a word on the stack
   177 001630 004737    GETH1:  JSR     R7,@#GETA
   177 001632 001444    
   178 001634 022705            CMP     #33,R5          ; terminate on any control char or space
   178 001636 000041    
   179 001640 100404            BMI     HEXIN
   180 001642 004737            JSR     R7,@#CRLF       ; ***** remove if not required *****
   180 001644 001232    
   181 001646 012605            MOV     (R6)+,R5
   182 001650 000207            RTS     R7
   183 001652 020527    HEXIN:  CMP     R5,#ASC"0"
   183 001654 000060    
   184 001656 100764            BMI     GETH1
   185 001660 022705            CMP     #ASC"F",R5
   185 001662 000106    
   186 001664 100761            BMI     GETH1
   187 001666 022705            CMP     #ASC"9",R5
   187 001670 000071    
   188 001672 100003            BPL     OKVAL
   189 001674 020527            CMP     R5,#ASC"A"
   189 001676 000101    
   190 001700 100753            BMI     GETH1
   191 001702 004737    OKVAL:  JSR     R7,@#PRTA       ; ***** remove if not required *****
   191 001704 001316    
   192 001706 022705            CMP     #ASC"9",R5
   192 001710 000071    
   193 001712 100003            BPL     $+6
   194 001714 162705            SUB     #ASC"A"-ASC"9",R5
   194 001716 000010    
   195 001720 042705            BIC     #ASC"0",R5
   195 001722 000060    
   196 001724 006316            ASL     (R6)
   197 001726 006316            ASL     (R6)
   198 001730 006316            ASL     (R6)
   199 001732 006316            ASL     (R6)
   200 001734 060516            ADD     R5,(R6)
   201 001736 000734            BR      GETH1
   202 001740           ;
