     1 000000           ; > MemTest writes memory block and tests it
     2 000000           ;
     3 000000                   ORG     O1000
     4 001000 012706    START:  MOV     #O1000,R6               ; set up stack
     4 001002 001000    
     5 001004 012700            MOV     #&FFFF,R0               ; test data in R0
     5 001006 177777    
     6 001010 012701    LOOP:   MOV     #O20000,R1              ; start address in R1
     6 001012 020000    
     7 001014 012702            MOV     #O40000,R2              ; upper boundary in R2
     7 001016 040000    
     8 001020 004737            JSR     R7,@#WRT                ; write data block
     8 001022 001034    
     9 001024 004737            JSR     R7,@#TST                ; test data block
     9 001026 001050    
    10 001030 005100            COM     R0                      ; toggle all bits
    11 001032 000766            BR      LOOP                    ; repeat until error
    12 001034           ;
    13 001034 010103    WRT:    MOV     R1,R3                   ; save start address for re-use
    14 001036 010021    WRT1:   MOV     R0,(R1)+                ; write a word, and point to next
    15 001040 020102            CMP     R1,R2                   ; see if finished block
    16 001042 001375            BNE     WRT1                    ; if not, repeat
    17 001044 010301            MOV     R3,R1                   ; restore address
    18 001046 000207            RTS     R7
    19 001050           ;
    20 001050 010103    TST:    MOV     R1,R3                   ; save start
    21 001052 020102    TST1:   CMP     R1,R2                   ; see if finished
    22 001054 001407            BEQ     DONE                    ; if so, go home
    23 001056 020021            CMP     R0,(R1)+                ; else test and point to next
    24 001060 001774            BEQ     TST1                    ; if OK, repeat
    25 001062 005301            DEC     R1                      ; point back...
    26 001064 005301            DEC     R1                      ; ...to faulty word
    27 001066 011100            MOV     (R1),R0                 ; copy bad data
    28 001070 000000            HALT                            ; and return to ODT
    29 001072 000742            BR      START                   ; if restarting, do it properly
    30 001074 010301    DONE:   MOV     R3,R1                   ; restore pointer
    31 001076 000207            RTS     R7                      ; and return to sender
