1%default { "load":"ldr", "shift":"2", "data_offset":"MIRROR_INT_ARRAY_DATA_OFFSET" }
2    /*
3     * Array get, 32 bits or less.  vAA <- vBB[vCC].
4     *
5     * Note: using the usual FETCH/and/shift stuff, this fits in exactly 17
6     * instructions.  We use a pair of FETCH_Bs instead.
7     *
8     * for: aget, aget-boolean, aget-byte, aget-char, aget-short
9     *
10     * NOTE: assumes data offset for arrays is the same for all non-wide types.
11     * If this changes, specialize.
12     */
13    /* op vAA, vBB, vCC */
14    FETCH_B r2, 1, 0                    @ r2<- BB
15    mov     r9, rINST, lsr #8           @ r9<- AA
16    FETCH_B r3, 1, 1                    @ r3<- CC
17    GET_VREG r0, r2                     @ r0<- vBB (array object)
18    GET_VREG r1, r3                     @ r1<- vCC (requested index)
19    cmp     r0, #0                      @ null array object?
20    beq     common_errNullObject        @ yes, bail
21    ldr     r3, [r0, #MIRROR_ARRAY_LENGTH_OFFSET]    @ r3<- arrayObj->length
22    add     r0, r0, r1, lsl #$shift     @ r0<- arrayObj + index*width
23    cmp     r1, r3                      @ compare unsigned index, length
24    bcs     common_errArrayIndex        @ index >= length, bail
25    FETCH_ADVANCE_INST 2                @ advance rPC, load rINST
26    $load   r2, [r0, #$data_offset]     @ r2<- vBB[vCC]
27    GET_INST_OPCODE ip                  @ extract opcode from rINST
28    SET_VREG r2, r9                     @ vAA<- r2
29    GOTO_OPCODE ip                      @ jump to next instruction
30