home *** CD-ROM | disk | FTP | other *** search
- ****************************************************************************
- *
- * $RCSfile: NEW.asm $
- * Description: Runtime support for the Oberon-A compiler
- *
- * Created by: fjc (Frank Copeland)
- * $Revision: 1.4 $
- * $Author: fjc $
- * $Date: 1994/07/24 18:28:24 $
- *
- * 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"
-
- XREF OberonSys_CLEANUP
-
- ABSEXECBASE EQU 4
-
- AllocMem EQU -198
-
- ;---------------------------------------------------------------------
- ; Macros
-
- CALLSYS MACRO
- JSR \1(A6)
- ENDM
-
- ;---------------------------------------------------------------------
- ; PROCEDURE OberonSys_NEW (
- ; pSize {D0} : LONGINT;
- ; pTag {D1} : ADDRESS)
- ;
- ; A call to this procedure is generated by the compiler when it
- ; translates a call to NEW () with an Oberon pointer variable.
- ; The type tag for the variable is passed in D1. If bit 1 in the
- ; type tag is set, an ArrayBlk is allocated using the size passed
- ; in D0, otherwise a RecordBlk is allocated using the size in the
- ; type descriptor. The procedure calculates the actual number of
- ; bytes required by adding 8 bytes for a RecordBlk or 20 for an
- ; ArrayBlk. See Memory.doc for a discussion of the memory
- ; allocation strategy.
- ;
- ; TYPE
- ; RecordBlkPtr = POINTER TO RecordBlk;
- ; RecordBlk = RECORD
- ; link, tag : ADDRESS;
- ; data : ...
- ; END;
- ; ArrayBlkPtr = POINTER TO ArrayBlk;
- ; ArrayBlk = RECORD
- ; arrpos, elemSize, size : LONGINT;
- ; link, tag : ADDRESS;
- ; data : ...
- ; END;
- ;
- ; CONST
- ; MEMCLEAR = {16};
- ;
- ; VAR
- ; size {D0} : LONGINT;
- ; memReqs {D1} : LONGSET;
- ; savedSize {D2} : LONGINT;
- ; mem {A0} : ADDRESS;
- ; tag {A2} : ADDRESS;
- ;
- ;---------------------------------------------------------------------
-
- SECTION OberonSys,CODE
-
- XDEF OberonSys_NEW
-
- OberonSys_NEW:
-
- BTST #31,D1 ; IF 31 IN pTag THEN
- BEQ.S 1$
- LEA OberonSys_VAR,A5 ; HALT (OS_BadTag)
- MOVE.L #OS_BadTag,OS_returnCode(A5)
- JMP OberonSys_CLEANUP
- 1$ ; END;
- MOVEA.L D1,A2 ; tag := pTag;
- BTST #1,D1 ; IF 1 IN tag THEN (* ArrayBlk *)
- BEQ.S 2$
- MOVE.L D0,D2 ; savedSize := pSize;
- ADDI.L #20,D0 ; INC (size, 20)
- BRA.S 5$
- 2$ ; ELSE
- MOVE.L (A2),D0 ; size := tag.size;
- ADDQ.L #8,D0 ; INC (size, 8)
- 5$ ; END;
- MOVEQ #1,D1 ; memReqs := MEMCLEAR;
- SWAP D1
- 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 3$
- MOVE.L A2,D0 ; IF 1 IN tag THEN
- BTST #1,D0
- BEQ.S 4$
- MOVE.L -2(A2),4(A0) ; mem.elemSize := tag.size
- MOVE.L D2,8(A0) ; mem.size := savedSize
- ADDQ.L #8,A0 ; INC (mem, 12)
- ADDQ.L #4,A0
- 4$ ; END;
- MOVE.L A5,-(A7)
- LEA OberonSys_VAR,A5
- MOVE.L OS_memList(A5),(A0) ; mem.link := memList;
- MOVE.L A0,OS_memList(A5) ; memList := mem;
- MOVE.L (A7)+,A5
- MOVE.L A2,4(A0) ; mem.tag := tag;
- ADDQ.L #8,A0 ; INC (mem, 8)
- MOVE.L A0,D0 ; RETURN mem
- 3$
- RTS
-
- ;---------------------------------------------------------------------
-
- END ; OberonSys
-
- ****************************************************************************
- *
- * $Log: NEW.asm $
- * Revision 1.4 1994/07/24 18:28:24 fjc
- * - Changed code for calling HALT().
- *
- * Revision 1.3 1994/05/12 20:31:15 fjc
- * - Prepared for release
- *
- * Revision 1.2 1994/02/24 16:54:28 fjc
- * Changed parameters to pass size in D0 and tag in D1
- *
- * Revision 1.1 1994/01/15 18:31:52 fjc
- * Start of revision control
- *
- * (12 Jan 1994) Modified to handle change in ArrayBlk (elemSize added)
- * Modified to assemble with PhxAss instead of A68K
- * ( 4 Jan 1994) Complete rewrite as part of implementation of the
- * garbage collector. OberonSysNEW is now one of two
- * allocator procedures, instead of the sole allocator.
- * (28 Jun 1993) Changed the way it handles the sizeTag field.
- * General overhaul.
- * (29 May 1993) Split OberonSys.asm into several files to create
- * OberonSys.lib.
- *
- ****************************************************************************
-
-