;; Table printing routine for Assignment X
;; R0 should contain address of histogram table with ten elements
        .ORIG        x3800
        ST        R7,SaveR7
        ADD       R1,R0,#0         ;; R1 <- R0
        LD        R2,X             ;; R2 <- 10
        LD        R3,ASC0          ;; R3 <- '0'
        ADD       R4,R3,#0         ;; R4 <- '0'
;; Do this loop 10 times
Loop    LEA       R0,MSG1          ;; R0 <- MSG1
        STR       R4,R0,#5         ;; MSG1[5] <- R4  next character to print
        LDR       R5,R1,#0         ;; R5 <- *R1      value of next element
        ADD       R5,R5,R3         ;; R5 <- R5+R3    add in offset '0'
        STR       R5,R0,#11        ;; MSG1[5] <- R5
        PUTS                       ;; Print the message
        ADD       R4,R4,#1         ;; ++R4           '0','1','2',....
        ADD       R1,R1,#1         ;; ++R1           elements of histogram
        ADD       R2,R2,#-1        ;; --R2
        BRp       Loop             ;;                do the loop ten times
        LD        R7,SaveR7
        RET        
SaveR7  .BLKW     1
X       .FILL     #10
ASC0    .FILL     #48
MSG1    .STRINGZ "Slot X has Y elements\n"
        .END

