// ********************************************************************** // InfoTypes.h // // Definitions of types and classes that are used to represent // the data in the computer. // // ********************************************************************** // CS251 - Computer Organization // Spring 1997 // Dickinson College // Grant Braught // // ********************************************************************** // #ifndef INFOTYPES #define INFOTYPES #include #include "SysSpecs.h" #include "Logic.h" // // Define the number of bits in each type of data. // #define BIT 1 #define BITPAIR 2 #define NIBBLE 4 #define BYTE 8 #define WORD 8*WORD_SIZE #define MICROINST 39 // // Class used for representing all types of bit oriented data. // class BitData { private: int NumBits; // It would possibly be more efficient to allocate these // dynamically based on the Length of the instance declared. // However, it is much easier to do it this way. Bool theBits[MICROINST]; public: // Overloaded Constructor Function. BitData(int InitNumBits = 1, Bool InitValue = FALSE); BitData(int InitNumBits, BitString InitValue); // Member access functions. int Length() { return NumBits; }; int Length(int NewLength) { return (NumBits = NewLength); }; // Overloaded index operator. Bool& operator [] (int theIndex); // Value functions void Base2Value(BitString theValue); DecValue Base10Value(Bool Signed=FALSE); // Overloaded Assignment Operator BitData& operator = (BitString NewValue); BitData& operator = (BitData NewValue); BitData& operator = (Bool NewValue); // Overloaded upper half assignment operator. BitData& operator <<= (BitData NewValue); // Overloaded lower half assignment operator. BitData& operator >>= (BitData NewValue); }; // Overloaded output function for the BitData class. ostream& operator << (ostream& theStream, BitData theBitData); #endif