%option "-nocheck-nodiag"
%externalintegerfnspec testsymbol
%begin {IBOL test}

@16_410 %routine phex4(%integer x)
@16_414 %routine phex2(%integer x)
@16_418 %routine phex1(%integer x)
@16_41c %routine psym(%integer k)
@16_420 %routine pstr(%string(255)s)

@16_1078 %integer ih6, ih7

%recordformat ptm -
  (%byte cr1 %or %byte cr3,*,cr2,*,
         ct1h,*,ct1l,*, ct2h,*,ct2l,*, ct3h,*,ct3l,*)
@16_400100 %record(ptm)timer

@16_400400 %bytearray page fc, page fd (0:255)
@16_400600 %byte camera a, *, camera b
@16_400700 %byte irq off, firq off, irq on, firq on,
           %half ints off, ints on

%owninteger oldih6, oldih7
%label newih6, newih7

%owninteger c,i

oldih6 = ih6; oldih7 = ih7
ih6 = addr(newih6); ih7 = addr(newih7)

pstr("Hello"); psym(nl)
%cycle
  c = testsymbol %until c>=0
  c = c!32 %if 'A'<=c<='Z'
  %exitif c='.'
  %if c='a' %start
    irqoff = c
  %elseif c='b'
    firqoff = c
  %elseif c='c'
    irqon = 'c'
  %elseif c='d'
    firqon = c
  %elseif c='e'
    ints off = c
  %elseif c='f'
    ints on = c
  %elseif c='g'
    c = camera a %for i = 1,1,10000
  %elseif c='h'
    c = camera b %for i = 1,1,10000
  %elseif c='i'
    c = page fc(0) %for i = 1,1,10000
  %elseif c='j'
    c = page fd(1) %for i = 1,1,10000
  %elseif c='k'
    camera a = 3 %for i = 1,1,10000
  %finish
%repeat

ih6 = oldih6; ih7 = oldih7
%stop

newih6:
  *movem d0/a0,-(sp)
  %if timer_cr2&4#0 %start
    *otsr #16_700
    *lea timer_ct3h,a0
    *movep.w 0(a0),d0
  %else
    pstr("IRQ");  psym(nl)
  %finish
  *movem (sp)+,d0/a0; *rte

newih7:
  *movem d0/a0,-(sp)
  pstr("FIRQ"); psym(nl)
  *movem (sp)+,d0/a0; *rte

%end
