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

  1. ****************************************************************************
  2. *
  3. *    $RCSfile: MOVE.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/05/12 20:31:15 $
  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 procedure SYSTEM.MOVE ().
  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. **********************************************************************
  28.  
  29. ;---------------------------------------------------------------------
  30. ;    Program unit hunk name
  31.  
  32.      TTL OberonSys
  33.  
  34. ;---------------------------------------------------------------------
  35. ;    Imports  (sort of ...)
  36.  
  37. ABSEXECBASE    EQU  4     ; The only absolute memory address in the
  38.                           ; Amiga OS.  Contains a pointer to the base
  39.                           ; of the Exec system library.
  40.  
  41. CopyMem        EQU  -624  ; Offset of the CopyMem () function from the
  42.                           ; base of the Exec library.
  43.  
  44. ;---------------------------------------------------------------------
  45.  
  46.      ;----------------------------------------------------------------
  47.      ; PROCEDURE OberonSys_MOVE (
  48.      ;   src {A0} : LONGINT;
  49.      ;   dst {A1} : LONGINT;
  50.      ;   len {D0} : LONGINT)
  51.      ;
  52.      ; This procedure is called by the compiler when it translates a
  53.      ; call to SYSTEM.MOVE ().  In this initial implementation, it
  54.      ; sends non-overlapping blocks to the Exec function CopyMem ()
  55.      ; and handles overlapping blocks with a simple byte copy from
  56.      ; high memory to low.
  57.      ;
  58.      ; Algorithm
  59.      ;
  60.      ; BEGIN
  61.      ;   IF (src = dst) OR (len <= 0) THEN RETURN END;
  62.      ;   IF (dst > src) & (dst < (src + len)) THEN
  63.      ;     (* The blocks overlap, so copy bytes from the *top* down *)
  64.      ;     INC (src, len); INC (dst, len);
  65.      ;     REPEAT
  66.      ;       DEC (src); DEC (dst);
  67.      ;       Mem [dst] := Mem [src];
  68.      ;       DEC (len)
  69.      ;     UNTIL len = 0
  70.      ;   ELSE
  71.      ;     (* Non-overlapping blocks, let CopyMem() do it. *)
  72.      ;     Exec.CopyMem (src, dst, len)
  73.      ;   END;
  74.      ; END OberonSys_MOVE;
  75.      ;
  76.      ; Register use
  77.      ;
  78.      ;   A0, A1 & D0 are used to pass parameters.  They match the
  79.      ;   parameters needed by Exec.CopyMem(), so they are left
  80.      ;   undisturbed until it is certain Exec.CopyMem() will not be
  81.      ;   called. D1 is used as a temporary.
  82.      ;
  83.      ;   All these registers are considered scratch by the compiler,
  84.      ;   so they do not need to be saved.
  85.      ;
  86.      ;----------------------------------------------------------------
  87.  
  88.      SECTION OberonSys,CODE   ; The linker will merge this hunk with
  89.                               ; all the others with the same name.
  90.  
  91.      XDEF      OberonSys_MOVE ; Export the procedure name so the
  92.                               ; linker can see it.
  93.  
  94. OberonSys_MOVE:
  95.  
  96.      CMPA.L    A1,A0     ; IF (src = dst) THEN RETURN
  97.      BEQ.S     3$
  98.      TST.L     D0        ; IF (len <= 0) THEN RETURN
  99.      BLE.S     3$
  100.  
  101.      CMPA.L    A0,A1     ; IF (dst > src)
  102.      BLE.S     2$
  103.      MOVE.L    A0,D1     ;   (D1 <- src + len)
  104.      ADD.L     D0,D1
  105.      CMPA.L    D1,A1     ; & (dst < (src + len)) THEN
  106.      BGE.S     2$
  107.  
  108.      MOVE.L    D1,A0     ;   INC (src, len) (src + len already in D1)
  109.      ADDA.L    D0,A1     ;   INC (dst, len)
  110. 1$                       ;   REPEAT
  111.      MOVE.B    -(A0),-(A1);    DEC (src); DEC (dst);
  112.                          ;     Mem[dst] := Mem[src]
  113.      SUBQ      #1,D0     ;     DEC (len)
  114.      BGT.S     1$        ;   UNTIL len = 0
  115.      BRA.S     3$
  116. 2$                       ; ELSE
  117.      MOVE.L    ABSEXECBASE,A6
  118.      JSR       CopyMem(A6);  Exec.CopyMem (src, dst, len)
  119. 3$                       ; END
  120.      RTS
  121.  
  122. ;---------------------------------------------------------------------
  123.  
  124.      END  ; OberonSys
  125.  
  126. ****************************************************************************
  127. *
  128. * $Log: MOVE.asm $
  129. * Revision 1.2  1994/05/12  20:31:15  fjc
  130. * - Prepared for release
  131. *
  132. * Revision 1.1  1994/01/15  18:31:52  fjc
  133. * Start of revision control
  134. *
  135. * (12 Jan 1994) Modified to assemble with PhxAss instead of A68K
  136. *
  137. ****************************************************************************
  138.  
  139.