; > MemSize works out memory size, then prints result in octal
;   Fills memory with zeros until it hits non-existent memory
;   Prints result on console.  Works on KF-11, KDF-11, KDJ-11 systems.
;
        ORG     O1000
        MOV     #O1000,R6       ; init stack
        MOV     #VEC,@#4        ; set bus timeout trap vector at loc'n 4
        CLR     @#6             ; set new PSW for use in trap routine
        MOV     #O2000,R5       ; start at 1st 1K boundary
LOOP:   COM     (R5)            ; read/modify/write location
        COM     (R5)+           ; restore original
        BR      LOOP            ; only break out on bus time-out
VEC:    DEC     R5              ; point down to true top
        DEC     R5
        JSR     R5,@#PRTA       ; print following text
        DEF     13              ; <CR>
        DEF     10 OR &8000     ; <LF> with top bit set to mark endoftext
        MOV     #O30,R4         ; R4 will be 6x after shifts
        ROL     R5              ; rotate 1 bit from R5 to R4
        ROL     R4
        JSR     R7,@#PRTN       ; print - as ASCII since it's 6x
        MOV     #5,R0           ; set to do five octets
CLOOP:  MOV     #6,R4           ; shifted 3 times, becomes octal 60, ie "0"
        ROL     R5              ; rotate R5>R4: 3 bits of octal number
        ROL     R4              ; could use ASHC R4,#3 if we have EIS
        ROL     R5
        ROL     R4
        ROL     R5
        ROL     R4
        JSR     R7,@#PRTN       ; print a digit
        DEC     R0              ; one less digit to do
        BNE     CLOOP
HALT:   HALT                    ; stop when done
        JSR     R5,@#PRTA       ; if restarting, say "Can't"
        DEF     32              ; ASCII space
        DEF     ASC("C")
        DEF     ASC("a")
        DEF     ASC("n")
        DEF     ASC("'")
        DEF     ASC("t")
        DEF     13
        DEF     &800A           ; finish with <CR><LF>
        BR      HALT
PRTN:   TSTB    @#O177564       ; look for RDY bit in CSR
        BPL     PRTN
        MOV     R4,@#O177566    ; send char to TX buffer
        RTS     R7
PRTA:   MOV     (R5),R4         ; get char just past where we were
        JSR     R7,@#PRTN       ; print it
        TST     (R5)+           ; see if it was last, and point to next
        BPL     PRTA            ; top bit set = finished
        RTS     R5
