[comp.sys.atari.st] errorchk

leo@philmds.UUCP (Leo de Wit) (06/19/88)

    Having had a small problem recently with this program that is in
Comp.sources.atari.st (address error on exit of other - GEM - program)
I have added a fix. The reason seems to be that when some GEM programs
terminate they are using the GEM-exit vector, and the exit routine
still relies on A4 having a valid contents (I'm not sure). After I
modified the code to save A4 on the stack the problem disappeared.

    Here is the relevant part of the code (comments omitted), with 2
instructions added:


DTOPWAIT
      MOVE.L   $602C,A0
      MOVEQ.L  #0,D1
      BRA.S    DTOPAREND
DTOPARNT
      ADDQ.L   #1,D1
      MOVE.L   36(A0),A0
DTOPAREND
      TST.L    (A0)
      BNE.S    DTOPARNT
      CMP.B    #3,D1
      BNE.S    DTWEND
      MOVE.L   A4,-(SP)            *  Added this instruction to save A4 ....
      LEA      WAITMSG(PC),A4
      BRA.S    DTOPW3
DTOPW2
      EXT.W    D0
      MOVE.W   D0,-(SP)
      MOVE.W   #2,-(SP)
      MOVE.W   #3,-(SP)
      TRAP     #BIOS
      ADDQ.L   #6,SP
DTOPW3
      MOVE.B   (A4)+,D0
      BNE.S    DTOPW2
      MOVE.W   #2,-(SP)
      MOVE.W   #2,-(SP)
      TRAP     #BIOS
      ADDQ.L   #4,SP
      MOVE.L   (SP)+,A4            *  .... and this one to restore A4
DTWEND
      MOVE.L   OLDVEC(PC),-(SP)
      RTS


      Leo.                         * Not an instruction, more a periferal 8-)