#include <def21161.h>

.section/pm seg_rth;
		NOP;NOP;NOP;NOP;                        // reserved (emulator) interrupt
reset:  IDLE;                                   // Implicit IDLE instruction at 0x40004
        JUMP start;           // 1st instruction executed after reset
        nop;
        nop;

.section/pm seg_pmco;                
start:
	ustat1 = FLG9O | FLG8O | FLG7O | FLG6O | FLG5O | FLG4O;
	dm(IOFLAG) = ustat1;
	
	ustat1 = dm(IOFLAG);
	bit clr ustat1 FLG9 | FLG8 | FLG7; 
	bit set ustat1 FLG6 | FLG5 | FLG4;
	dm(IOFLAG) = ustat1;

loophere:

	ustat1 = dm(IOFLAG);
	bit tgl ustat1  FLG6 | FLG5 | FLG4;
	dm(IOFLAG) = ustat1;
	
	lcntr = 0xFFFF, do _loop1 until lce;
	lcntr = 0xFF, do _loop2 until lce;		
_loop2: nop;nop;nop;nop;nop;
_loop1: nop;nop;nop;nop;nop;

	jump loophere;
	