# array-length

## Purpose

Store in the given destination register the length of the indicated array, in entries.

## Details

Op & Format | Mnemonic / Syntax | Arguments
--- | --- | ---
21 12x | array-length vA, vB | `A:` destination register (4 bits) `B:` array reference-bearing register (4 bits)

## Constraints

- Both A and B must be valid register indices for the current stack frame.
- Register vB must contain a reference to an array.

## Behavior

- The length of the array referenced by vB is stored in vA, that is vA' = length(vB).
- If register v(A-1) is the lower half of a register pair, register v(A-1)' becomes undefined.
- If register v(A+1) is the upper half of a register pair, register v(A+1)' becomes undefined.

## Exceptions

- NullPointerException is thrown if the value of register vB is null.