1%default { "store":"sw", "shift":"2", "data_offset":"MIRROR_INT_ARRAY_DATA_OFFSET" }
2
3    /*
4     * Array put, 32 bits or less.  vBB[vCC] <- vAA.
5     *
6     * for: aput, aput-boolean, aput-byte, aput-char, aput-short
7     *
8     * NOTE: this assumes data offset for arrays is the same for all non-wide types.
9     * If this changes, specialize.
10     */
11    /* op vAA, vBB, vCC */
12    FETCH_B(a2, 1, 0)                      #  a2 <- BB
13    GET_OPA(rOBJ)                          #  rOBJ <- AA
14    FETCH_B(a3, 1, 1)                      #  a3 <- CC
15    GET_VREG(a0, a2)                       #  a0 <- vBB (array object)
16    GET_VREG(a1, a3)                       #  a1 <- vCC (requested index)
17    # null array object?
18    beqz      a0, common_errNullObject     #  yes, bail
19    LOAD_base_offMirrorArray_length(a3, a0) #  a3 <- arrayObj->length
20    .if $shift
21    EASN(a0, a0, a1, $shift)               #  a0 <- arrayObj + index*width
22    .else
23    addu      a0, a0, a1
24    .endif
25    bgeu      a1, a3, common_errArrayIndex #  index >= length, bail
26    FETCH_ADVANCE_INST(2)                  #  advance rPC, load rINST
27    GET_VREG(a2, rOBJ)                     #  a2 <- vAA
28    GET_INST_OPCODE(t0)                    #  extract opcode from rINST
29    $store a2, $data_offset(a0)            #  vBB[vCC] <- a2
30    GOTO_OPCODE(t0)                        #  jump to next instruction
31