Skip to content

SWI 0x02 — Halt

  • Entry: 0x000001A0 (ARM)
  • Status: verified (hardware-checked 2026-07-08: fixture-driven runs on real GBA via the worker's no-blacklist opcode; see Hardware verification section)

Summary

Puts the CPU into low-power Halt mode: the CPU stops executing until any enabled interrupt is requested. Implemented by writing 0x00 to the low-power control register HALTCNT (0x04000301). Shares its tail with Stop (SWI 03h) and CustomHalt (SWI 27h).

Parameters

None.

Returns

Returns (via bx lr) after HALTCNT is written; the hardware resumes the CPU when an enabled interrupt occurs.

Clobbered registers

r2 and ip (r12) are used as scratch.

Algorithm

  1. Set r2 = 0 (the Halt selector value).
  2. Fall through into the shared tail at 0x000001AC: form the I/O base 0x04000000 and store the byte r2 to HALTCNT at 0x04000301.
  3. Return.

Real constants observed: HALTCNT byte address 0x04000301; Halt value 0x00.

Edge cases & known bugs

  • Halt only wakes on interrupts that are enabled in REG_IE (0x04000200). REG_IME state does not gate wake-up from Halt, but the standard usage is to have at least one IE source enabled or the CPU stays halted indefinitely.
  • Unlike IntrWait, Halt does not poll or acknowledge the BIOS IRQ-flag word at 0x03007FF8; it returns on the first interrupt of any enabled kind.

Hardware verification (2026-07-08)

Fixture-driven runs via the worker's no-blacklist opcode (swf), with wake sources / handlers installed through CpuSet pokes. Raw data: results/blacklist_fixtures1.csv.

Timer-2 IRQ fixture (prescaler 1024, IME = 0 throughout): - With a 4-second timer period armed ~2.3 s before the SWI, Halt slept for 28,850,098 cycles (~1720 ms) and woke exactly on the TM2 overflow IRQ — confirming that IE & IF wakes Halt with IME = 0. - With IF.TM2 already pending at entry, Halt returned in 72 cycles (immediate return, no sleep). - After wake-up the IF bit is left set — Halt does not acknowledge anything (unlike IntrWait's flag handling).

Cycle count

72 cycles (raw) for the pending-interrupt immediate return; otherwise the cost is the sleep time itself (externally determined).

Open questions (need hardware verification)

  • Confirm exact wake conditions vs. IME on this silicon revision.

GBATEK cross-reference

Matches GBATEK SWI 02h Halt (HALTCNT 4000301h := 00h). Confirms the shared code with Stop/CustomHalt.