; global variable shared by both main() and ISRs
INT_FLAGS  DATA 0x20
FLG_INT_A  BIT  INT_FLAGS.0
FLG_INT_B  BIT  INT_FLAGS.1
FLG_INT_C  BIT  INT_FLAGS.2
FLG_INT_D  BIT  INT_FLAGS.3
;....

; an interrupt service routine
; (others have similar piece of code with appropriate bit set)
ISR_INT_A:
	SETB  FLG_INT_A	; set own flag
; rest of ISR code (if needs)
	RETI

; --- program body ---
; at program setup, clear INT_FLAGS variable,
; init interrupt system etc...
 
; now the main loop
MAIN:	SETB EI			; enable interrupts
	MOV  PCON,#1		; sleep mode
	NOP			; some parts require it
LOOKUP:	JBC  FLG_INT_A,EVENT_A_ROUTINE
	JBC  FLG_INT_B,EVENT_B_ROUTINE
	JBC  FLG_INT_C,EVENT_C_ROUTINE
	JBC  FLG_INT_D,EVENT_D_ROUTINE
; ....
LOOK_AGAIN:
        CLR  EI			; disable ITs temporally
        MOV  A,INT_FLAGS       
	JZ   MAIN		; no interrupts occured
; if we are here then it was at least one interrupt processed
; while we react on events - check them again
        SETB	EI
	JMP  LOOKUP

; here you may place EVENT_x_ROUTINE long call
EVENT_A_ROUTINE:
	CALL	EVENT_A_SR
	JMP	LOOK_AGAIN

; and event reaction subroutines as well
EVENT_A_SR:
; reaction code
	RET


	END