home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / oberon-a-1.4ß.lha / Oberon-A / source / oberonsys / STACKCHK.asm < prev    next >
Assembly Source File  |  1994-08-08  |  3KB  |  97 lines

  1. ****************************************************************************
  2. *
  3. *    $RCSfile: STACKCHK.asm $
  4. * Description: Runtime support for the Oberon-A compiler
  5. *
  6. *  Created by: fjc (Frank Copeland)
  7. *   $Revision: 1.2 $
  8. *     $Author: fjc $
  9. *       $Date: 1994/08/08 16:31:56 $
  10. *
  11. * Copyright © 1994, Frank Copeland.
  12. * This file is part of the Oberon-A Library.
  13. * See Oberon-A.doc for conditions of use and distribution.
  14. *
  15. * Log entries are at the end of the file.
  16. *
  17. ****************************************************************************
  18. *
  19. * This file contains the MC68000 source code for part of the runtime
  20. * support library of the Oberon-A compiler.  It contains the code to
  21. * implement stack checking on procedure entry.
  22. *
  23. * Other parts of the runtime system may be found in the other files in
  24. * this directory.  The object files resulting from assembling these
  25. * files are concatenated to create OberonSys.lib.
  26. *
  27. * This code is by definition *not* re-entrant and is not suitable for
  28. * creating shared-code libraries.
  29. *
  30. ****************************************************************************
  31.  
  32. ;---------------------------------------------------------------------
  33. ;    Program unit hunk name
  34. ;    !! DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING !!
  35.  
  36.      TTL OberonSys
  37.  
  38. ;---------------------------------------------------------------------
  39. ;    Imports
  40.  
  41.      INCLUDE   "OberonSys.i"
  42.  
  43. ABSEXECBASE    EQU  4
  44. ThisTask       EQU  276
  45. tc_SPLower     EQU  58
  46.  
  47. ;---------------------------------------------------------------------
  48. ; PROCEDURE OberonSys_STACKCHK
  49. ;   ( size {D0} : LONGINT )
  50. ;
  51. ; A call to this procedure is generated by the compiler when it
  52. ; generates the code for entry to a procedure.
  53. ;
  54. ; The procedure assumes that 1500 bytes must remain free on the stack,
  55. ; to allow for the parameters of procedures called in the body of the
  56. ; procedure, and the extra stack required by dos.library functions.
  57. ; This limit is the same as the constant OCG.ParLimit. If that
  58. ; constant changes, this code must be modified and re-assembled.
  59. ;
  60. ; OberonSys_STACKCHK trashes the A0 register.
  61. ;---------------------------------------------------------------------
  62.  
  63.      SECTION OberonSys,CODE
  64.  
  65.      XDEF      OberonSys_STACKCHK
  66.  
  67. OberonSys_STACKCHK:
  68.  
  69.         MOVE.L  A0,-(A7)            ; (* Save register *)
  70.         MOVE.L  ABSEXECBASE,A0      ; IF SysBase.ThisTask.tc_SPLower
  71.         MOVE.L  ThisTask(A0),A0
  72.         MOVE.L  tc_SPLower(A0),A0
  73.         ADD.L   D0,A0               ;   + size + OCG.ParLimit
  74.         ADD.W   #1500,A0
  75.         CMP.L   A7,A0               ;   > A7 THEN
  76.         BLS.S   1$
  77.         TRAP    #OS_StackChk        ;   TRAP #StackChk
  78. 1$
  79.         MOVE.L  (A7)+,A0            ; (* Restore register *)
  80.         RTS                         ; END
  81.  
  82. ;---------------------------------------------------------------------
  83.  
  84.      END  ; OberonSys
  85.  
  86. ****************************************************************************
  87. *
  88. * $Log: STACKCHK.asm $
  89. ;; Revision 1.2  1994/08/08  16:31:56  fjc
  90. ;; Release 1.4
  91. ;;
  92. ;; Revision 1.1  1994/07/24  18:31:36  fjc
  93. ;; Initial revision
  94. ;;
  95. ****************************************************************************
  96.  
  97.