[net.micro.atari16] What is wrong with this program???

uh@unido.UUCP (07/21/86)

What is wrong with this program???

I want to write some sort of interrupt handler in TDI Modula-2 for the
Atari ST series, using the IOTransfer procedure.
Following is a small Modula-2 test program which has the same task as
the Megamax C interrupt test program, which have been posted two or three 
weeks ago in net.micro.atari16. I used the TDI Version 2.10a Modula-2 compiler.
The documentation is very poor at this point, so if anybody knows a
hint how to get this program running, please mail to

uh@unido

Many thanks in advance.
---------------------------cut here---------------------------------
MODULE INTRTEST;

FROM SYSTEM  IMPORT ADDRESS, PROCESS, NEWPROCESS, TRANSFER, IOTRANSFER;
FROM XBIOS   IMPORT Timer, SetTimerInterrupt;
FROM Storage IMPORT ALLOCATE;
FROM InOut   IMPORT WriteInt, WriteLn;

CONST INTTIMER = 77; (*Interrupt number of timer A interrupt*)

VAR I     : CARDINAL;
    N     : CARDINAL;
    ROOT  : PROCESS;
    INT   : PROCESS;
    IADDR : ADDRESS;

PROCEDURE DUMMY; 
BEGIN 
   (*Should a CODE(RTE) stand here ?!?*)
END DUMMY;

PROCEDURE INTHANDLER; 
BEGIN
   LOOP                                (*Interrupt handler never ends*)
      IOTRANSFER(INT,ROOT,4*INTTIMER); (*Give controll back to root; but only  
\012                                      until a timer A interrupt arrives*)
      INC(N);                          (*Count interrupts*)
   END;
END INTHANDLER;

BEGIN
   N := 0;                                (*Initialize interrupt counter*)
   SetTimerInterrupt(TimerA,1,100,DUMMY); (*Set timer A interrupt to dummy
					   procedure until IOTRANSFER takes
					   over control*)
   ALLOCATE(IADDR,1024);                  (*Create process space, then ..*)
   NEWPROCESS(INTHANDLER,IADDR,1024,INT); (*.. create the process*)
   TRANSFER(ROOT,INT);                    (*Give control to new created
					   process*)
   I := 0;                                (*Now wait a while*)
   WHILE I < 30000 DO
      INC(I);
   END;
   SetTimerInterrupt(TimerA,0,0,PROC(0)); (*Disable Timer A (I hope that 
					    will do?!?)*)
   WriteInt(N,10);                        (*Display number of interrupts ..*)
   WriteLn;                               (*.. during wait*)
END INTRTEST.
---------------------------cut here---------------------------------
This program bombs: 3 mushrooms (aah bombs).
But first if you hack something on the keyboard (i.e. move the mouse) when
the program is ended (N is 0).

Some words about my configuration:
   260ST upgraded to 1MB,
   SF 354,
   SM124,
   TOS in ROM.
   
Please, please help!!!

     Uwe Hoch
     Computer Science Department, University of Dortmund
     4600 Dortmund 50, P.O. Box 500500, W.-Germany
     E-mail address: uh@unido.uucp, uh@unido.bitnet