# The ARMv6K instruction set: what changes from ARMv5TE The specification's semantics reference is the ARM ARM, ARM DDI 0100I (2005), which covers ARMv6 and the K extensions; its pseudo-code is what the handlers are written from. GBATEK's ARM CPU Reference ("Special ARM11 Instructions (Misc)", "(SIMD)", "New THUMB Opcodes in ARM11") is the second reading and states what was seen on 3DS hardware where it says so. This page lists **the delta from ARMv5TE** (arm946es-python's isa-v5te.md is the base), so the build session knows what is new. All rows DOC unless marked. ## New ARM-state instructions | Group | Instructions | Notes | | --- | --- | --- | | Exclusive access | LDREX, STREX (v6); LDREXB/H/D, STREXB/H/D, CLREX (v6K) | the local and global exclusive monitors are part of the MPCore model (mmu-caches-mpcore.md); STREX's result register says whether the store happened | | Hints | NOP (true NOP), YIELD, WFE, WFI, SEV (v6K) | WFI is how the New 3DS applies a clock-mode change: only when every ARM11 is in WFI (GBATEK, CFG11_MPCORE_CLKCNT); WFE/SEV interact with the event register across CPUs | | Processor state | CPS, CPSID, CPSIE (A, I, F, mode); SETEND; SRS; RFE | CPSR gains E (data endianness) and A (imprecise abort mask) | | SIMD (media) | SADD16/8, SSUB16/8, SASX/SSAX (ADDSUBX/SUBADDX), their Q (saturating), SH (halving), U, UQ and UH forms; SEL with the four CPSR.GE flags; USAD8, USADA8; SSAT, USAT, SSAT16, USAT16; PKHBT, PKHTB; SXTB/H/B16 and UXTB/H/B16 with optional add (SXTAB...) and rotation; REV, REV16, REVSH | the GE[3:0] flags are new CPSR state; every SIMD op names which GE bits it writes | | Multiplies | UMAAL; SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD (with X); SMMUL, SMMLA, SMMLS (with R); SMMUL rounding | timing in DDI 0360F 15.7 | | Misc | CPY (alias of MOV) | | ## New Thumb instructions SXTH, SXTB, UXTH, UXTB; REV, REV16, REVSH; CPS; SETEND (DOC: GBATEK "New THUMB Opcodes in ARM11"; DDI 0100I). Thumb-2 is **not** in ARMv6K (that is ARMv6T2/ARMv7): the 32-bit Thumb encodings stay the v5 BL/BLX pairs. ## Changed rules for existing instructions - **Unaligned access.** With CP15 c1.U = 1, LDR/STR/LDRH/STRH (and their signed forms) at unaligned addresses perform the unaligned access instead of the ARMv5 rotation; LDM/STM, LDRD/STRD, LDREX/STREX and SWP still require alignment (DDI 0360F chapter 4; DDI 0100I part A2.8). With U = 0 the legacy rules apply. The A bit (strict alignment fault) takes priority over U (DDI 0360F 4.x, "The A bit setting takes priority over the U bit"). Which setting the 3DS's software runs with is a property of the CP15 state the boot ROM and kernel leave, read from the trace of a FIRM payload or a test (unknown U3 in the brief). - **Mixed endian.** CPSR.E switches data accesses to big-endian (BE-8); instruction fetch stays little-endian; the EE bit in CP15 c1 sets E on exception entry (DDI 0360F 4.5-4.7). - **Exceptions.** The v6 exception model: imprecise data aborts are held while CPSR.A = 1; SRS and RFE save and restore R14/SPSR; the high-vector bit (c1.V) maps the vectors to FFFF0000h (the 3DS's ARM11 boot ROM is mirrored at both 00000000h and FFFF0000h: GBATEK "3DS Memory and I/O Map"). - **SWP and SWPB** are deprecated in v6 in favour of LDREX/STREX but still execute; on an MPCore their atomicity against the other CPUs is a bus-lock question (HYPOTHESIS until the TRM's SCU chapter is read for it: unknown U5). - **MCR/MRC p15** reach a v6 CP15 with an MMU, TLB and cache maintenance operations, barrier operations (c7: data synchronization barrier, data memory barrier, prefetch flush), the thread ID registers (c13) and the performance monitors (c15) (DDI 0360F chapter 3; GBATEK "ARM CP15 System Control Coprocessor", which lists the ARM11 rows). ## Coprocessors present - CP15: system control (mmu-caches-mpcore.md). - CP14: debug (DDI 0360F chapter 12). Out of scope for the first build except the reads that software performs (unknown U8: does any title touch CP14?). - CP10/CP11: the VFP11 ([vfp.md](vfp.md)). Other coprocessor numbers are undefined instructions. ## Jazelle The TRM lists three instruction sets, ARM, Thumb and "the 8-bit Java bytecodes used in Jazelle state" (DDI 0360F 1.9). ARM does not publish how Jazelle executes bytecodes. The first build implements BXJ as the architecture's trivial form (enter ARM state at the target, as BX does when Jazelle is disabled) and records a HYPOTHESIS that no 3DS title enters Jazelle state (unknown U9; a trace of every title's BXJ use would settle it).