home *** CD-ROM | disk | FTP | other *** search
- ****************************************************************************
- *
- * $RCSfile: SYSNEW.asm $
- * Description: Runtime support for the Oberon-A compiler
- *
- * Created by: fjc (Frank Copeland)
- * $Revision: 1.3 $
- * $Author: fjc $
- * $Date: 1994/07/24 18:29:16 $
- *
- * Copyright © 1994, Frank Copeland.
- * This file is part of the Oberon-A Library.
- * See Oberon-A.doc for conditions of use and distribution.
- *
- * Log entries are at the end of the file.
- *
- ****************************************************************************
- *
- * This file contains the MC68000 source code for part of the runtime
- * support library of the Oberon-A compiler. It contains the code to
- * implement the Oberon standard procedures NEW() and SYSTEM.NEW().
- *
- * Other parts of the runtime system may be found in the other files in
- * this directory. The object files resulting from assembling these
- * files are concatenated to create OberonSys.lib.
- *
- * This code is by definition *not* re-entrant and is not suitable for
- * creating shared-code libraries.
- *
- **********************************************************************
-
- ;---------------------------------------------------------------------
- ; Program unit hunk name
- ; !! DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING !!
-
- TTL OberonSys
-
- ;---------------------------------------------------------------------
- ; Imports
-
- INCLUDE "OberonSys.i"
-
- ABSEXECBASE EQU 4
- AllocMem EQU -198
-
- ;---------------------------------------------------------------------
- ; Macros
-
- CALLSYS MACRO
- JSR \1(A6)
- ENDM
-
- ;---------------------------------------------------------------------
- ; PROCEDURE OberonSys_SYSNEW (
- ; size {D0} : LONGINT;
- ; reqs {D1} : SET;
- ; traced {D2} : BOOLEAN)
- ;
- ; A call to this procedure is generated by the compiler when it
- ; translates a call to NEW with a CPointer or BPointer variable, or
- ; when it translates a call to SYSTEM.NEW. The procedure allocates a
- ; SysBlk memory block of (size + 8) bytes, rounding the size up to the
- ; next multiple of 4 bytes. It links the block to either OS_memList
- ; or OS_untraced, depending on the traced parameter. See Memory.doc
- ; for a discussion of the memory allocation strategy.
- ;
- ; Algorithm
- ;
- ; TYPE
- ; SysBlkPtr = POINTER TO SysBlk;
- ; SysBlk = RECORD
- ; link : ADDRESS;
- ; size : LONGINT;
- ; data : ...
- ; END;
- ;
- ; PROCEDURE OberonSys_SYSNEW (
- ; pSize {D0} : LONGINT;
- ; memReqs {D1} : SET;
- ; pTraced {D2} : BOOLEAN);
- ;
- ; CONST
- ; MEMCLEAR = {16};
- ; VAR
- ; size {D0} : LONGINT;
- ; savedSize {D3} : LONGINT;
- ; mem {A0} : ADDRESS;
- ; BEGIN
- ; pSize := AND (pSize + 3, 0FFFFFFFCH); (* round up to multiple of 4 *)
- ; savedSize := pSize;
- ; INC (pSize, 8)
- ; mem := Exec.AllocMem (size, memReqs);
- ; IF mem = NIL THEN RETURN NIL END;
- ; mem.size := savedSize + 1; (* Set bit 0 to indicate SysBlk *)
- ; IF pTraced THEN
- ; memList := mem;
- ; mem.link := memList;
- ; ELSE
- ; untraced := mem;
- ; mem.link := untraced;
- ; END
- ; INC (mem, 8)
- ; RETURN mem
- ; END OberonSys_NEW;
- ;
- ;---------------------------------------------------------------------
-
- SECTION OberonSys,CODE
-
- XDEF OberonSys_SYSNEW
-
- OberonSys_SYSNEW:
-
- ADDQ.L #3,D0 ; pSize := AND (pSize + 3, 0FFFFFFFCH)
- ANDI.B #$FC,D0
- MOVE.L D0,D3 ; savedSize := pSize;
- ADDQ.L #8,D0 ; INC (pSize, 8)
- MOVEA.L ABSEXECBASE,A6 ; mem := Exec.AllocMem (size, memReqs)
- CALLSYS AllocMem
- MOVEA.L D0,A0
- TST.L D0 ; IF mem = NIL THEN RETURN NIL END;
- BEQ.S 1$
- ADDQ.L #1,D3 ; mem.size := savedSize + 1;
- MOVE.L D3,4(A0)
- MOVE.L A5,-(A7)
- LEA OberonSys_VAR,A5
- TST.B D2 ; IF pTraced THEN
- BEQ.S 2$
- MOVE.L OS_memList(A5),(A0) ; mem.link := memList;
- MOVE.L A0,OS_memList(A5) ; memList := mem;
- BRA.S 3$
- 2$ ; ELSE
- MOVE.L OS_untraced(A5),(A0) ; mem.link := untraced;
- MOVE.L A0,OS_untraced(A5) ; untraced := mem;
- 3$ ; END
- MOVEA.L (A7)+,A5
- ADDQ.L #8,A0 ; INC (mem, 8)
- MOVE.L A0,D0 ; RETURN mem
- 1$
- RTS
-
- ;---------------------------------------------------------------------
-
- END ; OberonSys
-
- ****************************************************************************
- *
- * $Log: SYSNEW.asm $
- * Revision 1.3 1994/07/24 18:29:16 fjc
- * - Changed to add memory requirements parameter.
- *
- * Revision 1.2 1994/05/12 20:31:15 fjc
- * - Prepared for release
- *
- * Revision 1.1 1994/01/15 18:31:52 fjc
- * Start of revision control
- *
- * (12 Jan 1994) Modified to assemble with PhxAss instead of A68K
- * ( 4 Jan 1994) Procedure created as second part of memory allocator.
- * See OberonSysNEW.asm.
- *
- ****************************************************************************
-
-