     1 000000           ; > MemDump dumps memory between given parameters
     2 000000           ;   Prints result on console in 8 columns
     3 000000           ;
     4 000000                   ORG     O153000
     5 153000 012706            MOV     #O153000,R6     ; init stack
     5 153002 153000    
     6 153004 004737            JSR     R7,@#CRLF       ; newline
     6 153006 153224    
     7 153010 004737            JSR     R7,@#PROMPT     ; ask for address
     7 153012 153104    
     8 153014 010201            MOV     R2,R1           ; start addr in R1
     9 153016 004737            JSR     R7,@#PROMPT     ; get end address in R2
     9 153020 153104    
    10 153022 042701            BIC     #3,R1           ; make sure R1 is xxxxx0
    10 153024 000003    
    11 153026 052702            BIS     #3,R2           ; and R2 is xxxxx7
    11 153030 000003    
    12 153032 004737            JSR     R7,@#CRLF       ; blank line
    12 153034 153224    
    13 153036 004737    LOOP:   JSR     R7,@#CRLF       ; newline
    13 153040 153224    
    14 153042 020201            CMP     R2,R1           ; finished ?
    15 153044 103001            BCC     LINE
    16 153046 000000            HALT
    17 153050 010105    LINE:   MOV     R1,R5
    18 153052 004737            JSR     R7,@#PRTO       ; print address of line
    18 153054 153262    
    19 153056 004737            JSR     R7,@#PRTCS      ; then do colon and space
    19 153060 153334    
    20 153062 012105    VALUE:  MOV     (R1)+,R5        ; R5 is value and pointer increments
    21 153064 004737            JSR     R7,@#PRTO       ; print value
    21 153066 153262    
    22 153070 004737            JSR     R7,@#PRTS
    22 153072 153344    
    23 153074 032701            BIT     #15,R1          ; see if R1 is MOD 16 (8 words)
    23 153076 000017    
    24 153100 001370            BNE     VALUE
    25 153102 000755            BR      LOOP
    26 153104           ;
    27 153104 004737    PROMPT: JSR     R7,@#CRLF
    27 153106 153224    
    28 153110 004537            JSR     R5,@#PRTA
    28 153112 153364    
    29 153114 000101            DEF     ASC"A"
    30 153116 000144            DEF     ASC"d"
    31 153120 000144            DEF     ASC"d"
    32 153122 000162            DEF     ASC"r"
    33 153124 000145            DEF     ASC"e"
    34 153126 000163            DEF     ASC"s"
    35 153130 000163            DEF     ASC"s"
    36 153132 000040            DEF     &20
    37 153134 000077            DEF     ASC"?"
    38 153136 100040            DEF     &8020
    39 153140 005002            CLR     R2
    40 153142 105737    CHAR:   TSTB    @#O177560       ; wait for character
    40 153144 177560    
    41 153146 100375            BPL     CHAR
    42 153150 013700            MOV     @#O177562,R0    ; get character
    42 153152 177562    
    43 153154 020027            CMP     R0,#13          ; carriage-return ?
    43 153156 000015    
    44 153160 001001            BNE     NUMB
    45 153162 000207            RTS     R7
    46 153164 020027    NUMB:   CMP     R0,#ASC"0"      ; if not CR, test for numeric
    46 153166 000060    
    47 153170 100764            BMI     CHAR
    48 153172 020027            CMP     R0,#ASC"8"
    48 153174 000070    
    49 153176 100361            BPL     CHAR
    50 153200 010004            MOV     R0,R4
    51 153202 004737            JSR     R7,@#PRTN       ; good, so echo it to console
    51 153204 153350    
    52 153206 042700            BIC     #&F8,R0         ; mask off to make octal
    52 153210 000370    
    53 153212 006302            ASL     R2              ; move one octet
    54 153214 006302            ASL     R2
    55 153216 006302            ASL     R2
    56 153220 060002            ADD     R0,R2           ; add this octet
    57 153222 000747            BR      CHAR
    58 153224 012704    CRLF:   MOV     #13,R4
    58 153226 000015    
    59 153230 004737            JSR     R7,@#PRTN
    59 153232 153350    
    60 153234 012704            MOV     #10,R4
    60 153236 000012    
    61 153240 004737            JSR     R7,@#PRTN
    61 153242 153350    
    62 153244 012704            MOV     #0,R4
    62 153246 000000    
    63 153250 004737            JSR     R7,@#PRTN
    63 153252 153350    
    64 153254 004737            JSR     R7,@#PRTN
    64 153256 153350    
    65 153260 000207            RTS     R7
    66 153262 012704    PRTO:   MOV     #O30,R4         ; R4 will be 6x after shifts
    66 153264 000030    
    67 153266 006105            ROL     R5              ; rotate 1 bit from R5 to R4
    68 153270 006104            ROL     R4
    69 153272 004737            JSR     R7,@#PRTN       ; print - as ASCII since it's 6x
    69 153274 153350    
    70 153276 012700            MOV     #5,R0           ; set to do five octets
    70 153300 000005    
    71 153302 012704    CLOOP:  MOV     #6,R4           ; 6>>3 becomes octal 60, ie "0"
    71 153304 000006    
    72 153306 006105            ROL     R5              ; rotate R5>R4: 3 bits of octal number
    73 153310 006104            ROL     R4              ; could use ASHC R4,#3 if we have EIS
    74 153312 006105            ROL     R5
    75 153314 006104            ROL     R4
    76 153316 006105            ROL     R5
    77 153320 006104            ROL     R4
    78 153322 004737            JSR     R7,@#PRTN       ; print a digit
    78 153324 153350    
    79 153326 005300            DEC     R0              ; one less digit to do
    80 153330 001364            BNE     CLOOP
    81 153332 000207            RTS     R7              ; stop when done
    82 153334 012704    PRTCS:  MOV     #ASC":",R4      ; print colon, then space
    82 153336 000072    
    83 153340 004737            JSR     R7,@#PRTN
    83 153342 153350    
    84 153344 012704    PRTS:   MOV     #&20,R4         ; print ascii space
    84 153346 000040    
    85 153350 105737    PRTN:   TSTB    @#O177564       ; look for RDY bit in CSR
    85 153352 177564    
    86 153354 100375            BPL     PRTN
    87 153356 010437            MOV     R4,@#O177566    ; send char to TX buffer
    87 153360 177566    
    88 153362 000207            RTS     R7
    89 153364 011504    PRTA:   MOV     (R5),R4         ; get char just past where we were
    90 153366 004737            JSR     R7,@#PRTN       ; print it
    90 153370 153350    
    91 153372 005725            TST     (R5)+           ; see if it was last, and point to next
    92 153374 100373            BPL     PRTA            ; top bit set = finished
    93 153376 000205            RTS     R5
