
;
;   Test of INDEX instruction
;
;   Assume an array X[10..15] that we must calculate subscripts for.
;   This checks the subscript, signals an exception if needed, and
;   returns the offset into the storage in R0.  The scale factor of
;   4 means we assume 4-byte array elements.
;

.print      "INDEX test"
.print      " "
.print      "After assembly, CALL MAIN( n ) where 'n' is a"
.print      "decimal value between 10 and 15, inclusive. "
.print      "The result is in R0 and is the offset in bytes"
.print      "of the selected array element."
.print
.print      "For exmaple, CALL MAIN(^d11) yields R0 of 4."

        .entry      main

        movl        b^4(ap), r1
  
        index       r1, #^d10, #^d15, #4, #0, r0
        subl2       #^d40,r0

        ret

        .end

