home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_oth / amigalib.lzh / AMIGALIB / AMIGALIB.LZH / asm_source / wbend.asm < prev    next >
Encoding:
Assembly Source File  |  1990-01-17  |  2.8 KB  |  73 lines

  1. ************************************************************************
  2. *
  3. *   WBEND   version 1.0
  4. *
  5. *
  6. *  Perform all necessary operations to shut down a Fortran program which
  7. *  was started from Workbench.  For use with Amiga AbSoft Fortran v 2.3,
  8. *  the module STDOPEN.ASM, and the Fortran-Workbench startup module
  9. *  WBINIT.ASM (INIT.SC).  Compatible with normal CLI startup.
  10. *
  11. *  Author:  Jim Locker, SofTech Inc.  Published in Amazing Computing
  12. *
  13. *  This program is placed in the public domain, but the Author accepts no
  14. *  responsibility whatsoever for anything that anyone does with it.
  15. *
  16. *  USAGE:
  17. *
  18. *      CALL WBEND
  19. *
  20. *        This call must be the last statement in the program, except for the
  21. *        normal END statement.  If you call this from anywhere else in the 
  22. *        program, you will crash.
  23. *
  24. *  This program must be linked into your executable using F77L.  It will 
  25. *  crash if run unlinked.
  26. *
  27. *************************************************************************
  28.  
  29. AEXEC   EQU     -16                     * "exec_lib" pointer
  30. DOS     EQU     AEXEC-4                 * "dos.library" pointer
  31. STDIN   EQU     DOS-4                   * file handle for STDIN
  32. STDOUT  EQU     STDIN-4                 * file handle for STDOUT
  33. H.BASE  EQU     STDOUT-4                * base of heap
  34. H.SIZE  EQU     H.BASE-4                * size of heap
  35. WBSTAT  EQU     H.SIZE-2                * running from workbench?
  36. WBMSG   EQU     WBSTAT-4                * loc of WB message
  37. OURTSK  EQU     WBMSG-4                 * loc of our TCB
  38. AMIGA   EQU     -OURTSK                 * size of Amiga global storage
  39.  
  40. * - from "exec.library"
  41.  
  42. _LVOForbid        EQU     -132
  43. _LVOFreeMem       EQU     -210
  44. _LVOReplyMsg      EQU     -378
  45. _LVOCloseLibrary  EQU     -414
  46. _LVODebug         EQU     -114
  47.  
  48. * - from "dos.library"
  49.  
  50. _LVOClose         EQU     -36
  51.  
  52. WBEND:
  53.          tst.w WBSTAT(A0)                   * did we start from workbench?
  54.          bne.s contnu                       * no.
  55.          rts
  56. contnu:
  57.          MOVE.L  A0,-(A7)
  58.          MOVE.L  WBMSG(A0),D2               * grab the WB message pointer
  59.          MOVE.L  DOS(A0),A6                 * move in DOS lib pointer
  60.          MOVE.L  STDIN(A0),D1               * move in STDIO pointer
  61.          beq.s   skip                       * if no STDIO, skip
  62.          jsr     _LVOClose(A6)              * close STDIO
  63. skip:
  64.          MOVEA.L A6,A1                      * prepare to close DOS lib
  65.          MOVEA.L (A7)+,A0
  66.          MOVE.L  AEXEC(A0),A6               * move in EXEC lib pointer
  67.          jsr     _LVOCloseLibrary(A6)       * close DOS lib
  68.          jsr     _LVOForbid(A6)             * so workbench can't unloadseg()
  69. *                                               us until we're done
  70.          MOVEA.L  D2,A1                     * reply to the workbench msg
  71.          jsr     _LVOReplyMsg(A6)
  72.          rts
  73.