@ vim set ft=armv4 noet:

.arch armv4
.cpu  arm7tdmi

.thumb
wait_for_vbl: @ alt version
	ldrh r0, =0x04000004
	tst r0, #1<<#0
	bz wait_for_vbl @ TODO: use correct flag

.arm
@ irq handler, untested
	ldr r0, =1
	ldr r1, =REG_IME
	stm r0, [r1]
	ldr r0, =BRANCH_TO_irq_handler_OPCODE
	stm r0, [r1, -#0x20C]
	@ -- 10 bytes
irq_handler:
	ldr r0, =REG_IE
	ldm r1, [r0] @ ie
	ldm r2, [r0+REG_IF-REG_IE] @ ie&if
	and r2, r1
	stm r2, [r0+REG_IF-REG_IE]
	ldm r3, [r0+REG_IFBIOS-REG_IE]
	orr r3, r2
	stm r3, [r0+REG_IFBIOS-REG_IE]
	bx lr
@	@ -- 36 bytes :(

