;References:
;swi - vector_handler_forward

;vector_handler_6E
;------------------
;reset JIT space if applicable

.vector_handler_6E
 LDR     R14, jit_code			;is the JIT running?
 TEQ     R14, #0
 BEQ     vector_handler_forward		;NO, hand to OS

 #if JIT_WIMP_support == 1
   BL      check_task_ID		;is the task supported?
   BNE     vector_handler_forward	;NO, hand to OS
 #endif

 #if MMUControl2_support == 0
   LDR     R14, [R13, #4]		;get PC from stack
   #if compile_RO == 400
     BIC     R14, R14, #&FC000003	;clear flags
   #endif
   ADR     R12, CACHEOP_ACTION		;start of our code
   SUBS    R14, R14, R12
   BMI     _retain			;not us, so keep
   CMP     R14, #CACHEOP_ACTION_END - CACHEOP_ACTION	;is it us?
   BLO     vector_handler_forward		;YES, pass on

   ._retain
 #endif

 TST     R0, #%1			;all memory?
 BEQ     vector_handler_forward		;YES, pass on
; MOVEQ   R2, #&8000			;YES,
; MOVEQ   R4, #jit_allocate_memory	; |
; SUBEQ   R4, R4, R2			; |+  flush all memory
 STMFD   R13!, {R2, R4}
 SUBNE   R4, R2, R1			;NO,  size - 4
 ADDNE   R4, R4, #4			; |   correct size
 MOVNE   R2, R1				; |+  start address

 CMP     R2, #jit_code_start		;within JIT space?
 BLLO    hv_reset_memory_block		;reset JIT space

 LDMFD   R13!, {R2, R4}
B       vector_handler_trap
