home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / dev / obero / oberon-a / source / oberonsys / sysnew.asm < prev   
Encoding:
Assembly Source File  |  1994-08-08  |  5.0 KB  |  164 lines

  1. ****************************************************************************
  2. *
  3. *    $RCSfile: SYSNEW.asm $
  4. * Description: Runtime support for the Oberon-A compiler
  5. *
  6. *  Created by: fjc (Frank Copeland)
  7. *   $Revision: 1.3 $
  8. *     $Author: fjc $
  9. *       $Date: 1994/07/24 18:29:16 $
  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 the Oberon standard procedures NEW() and SYSTEM.NEW().
  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. AllocMem       EQU  -198
  45.  
  46. ;---------------------------------------------------------------------
  47. ;    Macros
  48.  
  49. CALLSYS MACRO
  50.         JSR \1(A6)
  51.         ENDM
  52.  
  53. ;---------------------------------------------------------------------
  54. ; PROCEDURE OberonSys_SYSNEW (
  55. ;   size    {D0} : LONGINT;
  56. ;   reqs    {D1} : SET;
  57. ;   traced  {D2} : BOOLEAN)
  58. ;
  59. ; A call to this procedure is generated by the compiler when it
  60. ; translates a call to NEW with a CPointer or BPointer variable, or
  61. ; when it translates a call to SYSTEM.NEW.  The procedure allocates a
  62. ; SysBlk memory block of (size + 8) bytes, rounding the size up to the
  63. ; next multiple of 4 bytes.  It links the block to either OS_memList
  64. ; or OS_untraced, depending on the traced parameter.  See Memory.doc
  65. ; for a discussion of the memory allocation strategy.
  66. ;
  67. ; Algorithm
  68. ;
  69. ; TYPE
  70. ;   SysBlkPtr = POINTER TO SysBlk;
  71. ;   SysBlk = RECORD
  72. ;     link : ADDRESS;
  73. ;     size : LONGINT;
  74. ;     data : ...
  75. ;   END;
  76. ;
  77. ; PROCEDURE OberonSys_SYSNEW (
  78. ;   pSize    {D0} : LONGINT;
  79. ;   memReqs  {D1} : SET;
  80. ;   pTraced  {D2} : BOOLEAN);
  81. ;
  82. ; CONST
  83. ;     MEMCLEAR = {16};
  84. ; VAR
  85. ;     size {D0} : LONGINT;
  86. ;     savedSize {D3} : LONGINT;
  87. ;     mem {A0} : ADDRESS;
  88. ; BEGIN
  89. ;   pSize := AND (pSize + 3, 0FFFFFFFCH); (* round up to multiple of 4 *)
  90. ;   savedSize := pSize;
  91. ;   INC (pSize, 8)
  92. ;   mem := Exec.AllocMem (size, memReqs);
  93. ;   IF mem = NIL THEN RETURN NIL END;
  94. ;   mem.size := savedSize + 1; (* Set bit 0 to indicate SysBlk *)
  95. ;   IF pTraced THEN
  96. ;     memList := mem;
  97. ;     mem.link := memList;
  98. ;   ELSE
  99. ;     untraced := mem;
  100. ;     mem.link := untraced;
  101. ;   END
  102. ;   INC (mem, 8)
  103. ;   RETURN mem
  104. ; END OberonSys_NEW;
  105. ;
  106. ;---------------------------------------------------------------------
  107.  
  108.      SECTION OberonSys,CODE
  109.  
  110.      XDEF      OberonSys_SYSNEW
  111.  
  112. OberonSys_SYSNEW:
  113.  
  114.      ADDQ.L    #3,D0                ;   pSize := AND (pSize + 3, 0FFFFFFFCH)
  115.      ANDI.B    #$FC,D0
  116.      MOVE.L    D0,D3                ;   savedSize := pSize;
  117.      ADDQ.L    #8,D0                ;   INC (pSize, 8)
  118.      MOVEA.L   ABSEXECBASE,A6       ;   mem := Exec.AllocMem (size, memReqs)
  119.      CALLSYS   AllocMem
  120.      MOVEA.L   D0,A0
  121.      TST.L     D0                   ;   IF mem = NIL THEN RETURN NIL END;
  122.      BEQ.S     1$
  123.      ADDQ.L    #1,D3                ;   mem.size := savedSize + 1;
  124.      MOVE.L    D3,4(A0)
  125.      MOVE.L    A5,-(A7)
  126.      LEA       OberonSys_VAR,A5
  127.      TST.B     D2                   ;   IF pTraced THEN
  128.      BEQ.S     2$
  129.      MOVE.L    OS_memList(A5),(A0)  ;     mem.link := memList;
  130.      MOVE.L    A0,OS_memList(A5)    ;     memList := mem;
  131.      BRA.S     3$
  132. 2$                                  ;   ELSE
  133.      MOVE.L    OS_untraced(A5),(A0) ;     mem.link := untraced;
  134.      MOVE.L    A0,OS_untraced(A5)   ;     untraced := mem;
  135. 3$                                  ;   END
  136.      MOVEA.L   (A7)+,A5
  137.      ADDQ.L    #8,A0                ;   INC (mem, 8)
  138.      MOVE.L    A0,D0                ;   RETURN mem
  139. 1$
  140.      RTS
  141.  
  142. ;---------------------------------------------------------------------
  143.  
  144.      END  ; OberonSys
  145.  
  146. ****************************************************************************
  147. *
  148. * $Log: SYSNEW.asm $
  149. * Revision 1.3  1994/07/24  18:29:16  fjc
  150. * - Changed to add memory requirements parameter.
  151. *
  152. * Revision 1.2  1994/05/12  20:31:15  fjc
  153. * - Prepared for release
  154. *
  155. * Revision 1.1  1994/01/15  18:31:52  fjc
  156. * Start of revision control
  157. *
  158. * (12 Jan 1994) Modified to assemble with PhxAss instead of A68K
  159. * ( 4 Jan 1994) Procedure created as second part of memory allocator.
  160. *               See OberonSysNEW.asm.
  161. *
  162. ****************************************************************************
  163.  
  164.