-- File: AMCUHot.mesa,  Last Edit: HGM  January 7, 1981  12:21 PM

DIRECTORY
  InlineDefs USING [COPY, HighHalf],
  Mopcodes USING [zPOP, zBLTL],
  CommUtilDefs USING [],
  DriverDefs USING [Glitch];

AMCUHot: PROGRAM IMPORTS InlineDefs, DriverDefs EXPORTS CommUtilDefs =
  BEGIN

  Shorten: PROCEDURE [LONG POINTER] RETURNS [POINTER] = MACHINE CODE
    BEGIN Mopcodes.zPOP; END;

  BltLong: PROCEDURE [from: LONG POINTER, nwords: CARDINAL, to: LONG POINTER] =
    MACHINE CODE BEGIN Mopcodes.zBLTL; END;

  hyperspaceOk: BOOLEAN ← FALSE;

  SetHyperspaceOk: PUBLIC PROCEDURE [new: BOOLEAN] =
    BEGIN hyperspaceOk ← new; END;

  UnsupportedPointerToHyperspace: PUBLIC ERROR = CODE;

  FriendOfCopyLong, CopyLong: PUBLIC PROCEDURE [
    from: LONG POINTER, nwords: CARDINAL, to: LONG POINTER] =
    BEGIN
    source, dest: POINTER;
    IF hyperspaceOk THEN BltLong[from: from, nwords: nwords, to: to]
    ELSE
      BEGIN
      IF from = NIL OR InlineDefs.HighHalf[from] # 0 OR to = NIL OR
	InlineDefs.HighHalf[to] # 0 THEN
	DriverDefs.Glitch[UnsupportedPointerToHyperspace];
      source ← Shorten[from];
      dest ← Shorten[to];
      InlineDefs.COPY[from: source, nwords: nwords, to: dest];
      END;
    END;

  END.