DEFINITION MODULE SyntaxAnalyzer;
(* Analyzes the operands to provide information for CodeGenerator *)

   FROM LongNumbers IMPORT
      LONG;

   FROM Parser IMPORT
      OPERAND;


   EXPORT QUALIFIED
      SizeType, OpConfig, OpMode, Xtype,         (*      TYPEs       *)
      GetValue, GetSize,                         (*    PROCEDURE's   *)
      GetInstModeSize, GetOperand, GetMultReg;   (*    PROCEDURE's   *)


   TYPE
      OpMode = (DReg,      (* Data Register *)
                ARDir,     (* Address Register Direct *)
                ARInd,     (* Address Register Indirect *)
                ARPost,    (* Address Register with Post-Increment *)
                ARPre,     (* Address Register with Pre-Decrement *)
                ARDisp,    (* Address Register with Displacement *)
                ARDisX,    (* Address Register with Disp. & Index *)
                AbsW,      (* Absolute Word (16-bit Address) *)
                AbsL,      (* Absolute Word (32-bit Address) *)
                PCDisp,    (* Program Counter Relative, with Displacement *)
                PCDisX,    (* Program Counter Relative, with Disp. & Index *)
                Imm,       (* Immediate *)
                MultiM,    (* Multiple Register Move *)
                SR,        (* Status Register *)
                CCR,       (* Condition Code Register *)
                USP,       (* User's Stack Pointer *)
                Null);     (* Error Condition, or Operand missing *)

      Xtype = (X0, Dreg, Areg);
      SizeType = (S0, Byte, Word, S3, Long);

      OpConfig = RECORD                 (* OPERAND CONFIGURATION *)
                    Mode : OpMode;
                    Value : LONG;
                    Loc : CARDINAL;     (* Location of Operand on line *)
                    Rn : CARDINAL;      (* Register number *)
                    Xn : CARDINAL;      (* Index Reg. nbr. *)
                    Xsize : SizeType;   (* size of Index *)
                    X : Xtype;          (* Is index Data or Address register? *)
                 END;



   PROCEDURE GetValue (Operand : OPERAND; VAR Value : LONG);
   (* determines value of operand (in Decimal, HEX, or via Symbol Table) *)


   PROCEDURE GetSize (VAR Symbol : ARRAY OF CHAR; VAR Size : SizeType);
   (* determines size of opcode: Byte, Word, or Long *)

   PROCEDURE GetAbsSize (VAR Symbol : ARRAY OF CHAR; VAR AbsSize : SizeType);
   (* determines size of operand: Word or Long *)

   PROCEDURE GetInstModeSize (Mode : OpMode; Size : SizeType;
                                 VAR InstSize : CARDINAL) : CARDINAL;
   (* Determines the size for the various instruction modes.    *)

   PROCEDURE GetOperand (Oper : OPERAND; VAR Op : OpConfig);
   (* Finds mode and value for source or destination operand *)

   PROCEDURE GetMultReg (Oper : OPERAND; PreDec : BOOLEAN;
                         Loc : CARDINAL; VAR MultExt : BITSET);
   (* Builds a BITSET marking each register used in a MOVEM instruction *)

END SyntaxAnalyzer.
