DEFINITION MODULE LongNumbers;            
(* Routines to handle HEX digits for the X68000 cross assembler. *)
(* All but LongPut and LongWrite are limited to 8 digit numbers. *)

   FROM FileSystem IMPORT
      File;

   EXPORT QUALIFIED
      LONG, LongClear, LongAdd, LongSub, LongInc, LongDec, 
      LongCompare, CardToLong, LongToCard, LongToInt, LongPut, 
      LongWrite, StringToLong, BinStrToLong, AddrBoundL, AddrBoundW;

   CONST
      DIGITS = 8;
      BASE = 16;

   TYPE
      LONG = ARRAY [1..DIGITS] OF INTEGER;


   PROCEDURE LongClear (VAR A : LONG);
   (* Sets LONG to Zero *)

   PROCEDURE LongAdd (A, B : LONG; VAR Result : LONG);
   (* Add two LONGs, giving Result *)

   PROCEDURE LongSub (A, B : LONG; VAR Result : LONG);
   (* Subtract two LONGs (A - B), giving Result *)

   PROCEDURE CardToLong (n : CARDINAL; VAR A : LONG);
   (* Converts CARDINAL to LONG *)

   PROCEDURE LongToCard (A : LONG; VAR n : CARDINAL) : BOOLEAN;
   (* Converts LONG TO CARDINAL, returns FALSE if conversion impossible *)

   PROCEDURE LongToInt (A : LONG; VAR n : INTEGER) : BOOLEAN;
   (* Converts LONG to INTEGER, returns FALSE if conversion impossible *)

   PROCEDURE LongInc (VAR A : LONG; n : CARDINAL);
   (* Increment LONG by n *)

   PROCEDURE LongDec (VAR A : LONG; n : CARDINAL);
   (* Decrement LONG by n *)

   PROCEDURE LongCompare (A, B : LONG) : INTEGER;
   (* Returns: 0 if A = B, -1 if A < B, +1 if A > B *)

   PROCEDURE LongPut (VAR f : File; A : ARRAY OF INTEGER; Size : CARDINAL);
   (* Put LONG number in FILE f *)

   PROCEDURE LongWrite (A : ARRAY OF INTEGER; Size : CARDINAL);
   (* Write LONG number to console screen *)

   PROCEDURE StringToLong (S : ARRAY OF CHAR; VAR A : LONG) : BOOLEAN;
   (* Converts a string (in HEX, maximum of 32 bits) into a LONG *)

   PROCEDURE BinStrToLong (S : ARRAY OF CHAR; VAR A : LONG) : BOOLEAN;
   (* Converts a string (in Binary, maximum of 16 bits) into a LONG *)

   PROCEDURE AddrBoundL (VAR A : LONG);
   (* Forces Address to a 68000 long word boundary *)

   PROCEDURE AddrBoundW (VAR A : LONG);
   (* Forces Address to a 68000 word boundary *)

END LongNumbers.

