     1 000000           ; > MemDump dumps memory between given parameters
     2 000000           ;   Prints result on console in 8 columns
     3 000000           ;
     4 000000                   ORG     O1000
     5 001000 012706            MOV     #O1000,R6       ; init stack
     5 001002 001000    
     6 001004 004737            JSR     R7,@#CRLF       ; newline
     6 001006 001224    
     7 001010 004737            JSR     R7,@#PROMPT     ; ask for address
     7 001012 001104    
     8 001014 010201            MOV     R2,R1           ; start addr in R1
     9 001016 004737            JSR     R7,@#PROMPT     ; get end address in R2
     9 001020 001104    
    10 001022 042701            BIC     #3,R1           ; make sure R1 is xxxxx0
    10 001024 000003    
    11 001026 052702            BIS     #3,R2           ; and R2 is xxxxx7
    11 001030 000003    
    12 001032 004737            JSR     R7,@#CRLF       ; blank line
    12 001034 001224    
    13 001036 004737    LOOP:   JSR     R7,@#CRLF       ; newline
    13 001040 001224    
    14 001042 020201            CMP     R2,R1           ; finished ?
    15 001044 103001            BCC     LINE
    16 001046 000000            HALT
    17 001050 010105    LINE:   MOV     R1,R5
    18 001052 004737            JSR     R7,@#PRTO       ; print address of line
    18 001054 001246    
    19 001056 004737            JSR     R7,@#PRTCS      ; then do colon and space
    19 001060 001320    
    20 001062 012105    VALUE:  MOV     (R1)+,R5        ; R5 is value and pointer increments
    21 001064 004737            JSR     R7,@#PRTO       ; print value
    21 001066 001246    
    22 001070 004737            JSR     R7,@#PRTS
    22 001072 001330    
    23 001074 032701            BIT     #15,R1          ; see if R1 is MOD 16 (8 words)
    23 001076 000017    
    24 001100 001370            BNE     VALUE
    25 001102 000755            BR      LOOP
    26 001104           ;
    27 001104 004737    PROMPT: JSR     R7,@#CRLF
    27 001106 001224    
    28 001110 004537            JSR     R5,@#PRTA
    28 001112 001350    
    29 001114 000101            DEF     ASC"A"
    30 001116 000144            DEF     ASC"d"
    31 001120 000144            DEF     ASC"d"
    32 001122 000162            DEF     ASC"r"
    33 001124 000145            DEF     ASC"e"
    34 001126 000163            DEF     ASC"s"
    35 001130 000163            DEF     ASC"s"
    36 001132 000040            DEF     &20
    37 001134 000077            DEF     ASC"?"
    38 001136 100040            DEF     &8020
    39 001140 005002            CLR     R2
    40 001142 105737    CHAR:   TSTB    @#O177560       ; wait for character
    40 001144 177560    
    41 001146 100375            BPL     CHAR
    42 001150 013700            MOV     @#O177562,R0    ; get character
    42 001152 177562    
    43 001154 020027            CMP     R0,#13          ; carriage-return ?
    43 001156 000015    
    44 001160 001001            BNE     NUMB
    45 001162 000207            RTS     R7
    46 001164 020027    NUMB:   CMP     R0,#ASC"0"      ; if not CR, test for numeric
    46 001166 000060    
    47 001170 100764            BMI     CHAR
    48 001172 020027            CMP     R0,#ASC"8"
    48 001174 000070    
    49 001176 100361            BPL     CHAR
    50 001200 010004            MOV     R0,R4
    51 001202 004737            JSR     R7,@#PRTN       ; good, so echo it to console
    51 001204 001334    
    52 001206 042700            BIC     #&F8,R0         ; mask off to make octal
    52 001210 000370    
    53 001212 006302            ASL     R2              ; move one octet
    54 001214 006302            ASL     R2
    55 001216 006302            ASL     R2
    56 001220 060002            ADD     R0,R2           ; add this octet
    57 001222 000747            BR      CHAR
    58 001224 012704    CRLF:   MOV     #13,R4
    58 001226 000015    
    59 001230 004737            JSR     R7,@#PRTN
    59 001232 001334    
    60 001234 012704            MOV     #10,R4
    60 001236 000012    
    61 001240 004737            JSR     R7,@#PRTN
    61 001242 001334    
    62 001244 000207            RTS     R7
    63 001246 012704    PRTO:   MOV     #O30,R4         ; R4 will be 6x after shifts
    63 001250 000030    
    64 001252 006105            ROL     R5              ; rotate 1 bit from R5 to R4
    65 001254 006104            ROL     R4
    66 001256 004737            JSR     R7,@#PRTN       ; print - as ASCII since it's 6x
    66 001260 001334    
    67 001262 012700            MOV     #5,R0           ; set to do five octets
    67 001264 000005    
    68 001266 012704    CLOOP:  MOV     #6,R4           ; 6>>3 becomes octal 60, ie "0"
    68 001270 000006    
    69 001272 006105            ROL     R5              ; rotate R5>R4: 3 bits of octal number
    70 001274 006104            ROL     R4              ; could use ASHC R4,#3 if we have EIS
    71 001276 006105            ROL     R5
    72 001300 006104            ROL     R4
    73 001302 006105            ROL     R5
    74 001304 006104            ROL     R4
    75 001306 004737            JSR     R7,@#PRTN       ; print a digit
    75 001310 001334    
    76 001312 005300            DEC     R0              ; one less digit to do
    77 001314 001364            BNE     CLOOP
    78 001316 000207            RTS     R7              ; stop when done
    79 001320 012704    PRTCS:  MOV     #ASC":",R4      ; print colon, then space
    79 001322 000072    
    80 001324 004737            JSR     R7,@#PRTN
    80 001326 001334    
    81 001330 012704    PRTS:   MOV     #&20,R4         ; print ascii space
    81 001332 000040    
    82 001334 105737    PRTN:   TSTB    @#O177564       ; look for RDY bit in CSR
    82 001336 177564    
    83 001340 100375            BPL     PRTN
    84 001342 010437            MOV     R4,@#O177566    ; send char to TX buffer
    84 001344 177566    
    85 001346 000207            RTS     R7
    86 001350 011504    PRTA:   MOV     (R5),R4         ; get char just past where we were
    87 001352 004737            JSR     R7,@#PRTN       ; print it
    87 001354 001334    
    88 001356 005725            TST     (R5)+           ; see if it was last, and point to next
    89 001360 100373            BPL     PRTA            ; top bit set = finished
    90 001362 000205            RTS     R5
