
/***************************************************************************
**
**    $Header:   D:/EPSLDV1/SRC/LOG/MEMADDR.CPP   1.8   20 Jun 1996 09:24:54   ZJRD  $
**
**    $Log:   D:/EPSLDV1/SRC/LOG/MEMADDR.CPP  $
** 
**    Rev 1.8   20 Jun 1996 09:24:54   ZJRD
** EasyPack/SLD Version 1.20a
** 
**    Rev 1.6   10 Jun 1996 10:19:34   ZJRD
** EasyPack/SLD Version 1.20
** 
**    Rev 1.4   29 May 1996 09:28:40   ZJRD
** No change.
** 
**    Rev 1.3   16 May 1996 09:05:56   ZJRD
** No change.
** 
**    Rev 1.2   10 May 1996 09:11:58   ZJRD
** No change.
** 
**    Rev 1.1   02 May 1996 10:23:46   ZJRD
** EasyPack/SLD Version 1.92
** 
**    Rev 1.31   18 Apr 1996 12:57:36   Shirley
** No change.
** 
**    Rev 1.30   12 Apr 1996 10:43:04   Shirley
** EasyPack/SLD Version 1.90
** 
**    Rev 1.28   15 Feb 1996 08:55:08   Shirley
** No change.
** 
**    Rev 1.27   12 Feb 1996 14:03:22   Shirley
** No change.
** 
**    Rev 1.26   06 Feb 1996 15:29:52   Shirley
** No change.
** 
**    Rev 1.25   06 Feb 1996 13:44:14   Shirley
** No change.
** 
**    Rev 1.24   01 Feb 1996 10:17:12   Shirley
** No change.
** 
**    Rev 1.23   26 Jan 1996 09:19:46   Shirley
** No change.
** 
**    Rev 1.22   25 Jan 1996 13:19:40   Shirley
** No change.
** 
**    Rev 1.21   24 Jan 1996 10:32:48   Shirley
** No change.
** 
**    Rev 1.20   23 Jan 1996 11:26:34   Shirley
** No change.
** 
**    Rev 1.19   18 Jan 1996 10:11:22   Shirley
** No change.
** 
**    Rev 1.18   15 Jan 1996 16:12:56   Shirley
** No change.
** 
**    Rev 1.17   04 Jan 1996 11:11:00   Shirley
** No change.
** 
**    Rev 1.16   30 Nov 1995 09:14:50   Shirley
** No change.
** 
**    Rev 1.15   28 Nov 1995 15:29:22   Shirley
** No change.
** 
**    Rev 1.14   21 Nov 1995 11:21:36   Shirley
** No change.
** 
**    Rev 1.13   13 Nov 1995 09:27:18   Shirley
** No change.
** 
**    Rev 1.12   12 Nov 1995 11:32:44   Shirley
** No change.
** 
**    Rev 1.11   08 Nov 1995 16:31:08   Shirley
** No change.
** 
**    Rev 1.10   08 Nov 1995 12:45:46   Shirley
** No change.
** 
**    Rev 1.9   02 Nov 1995 10:07:56   Shirley
** No change.
** 
**    Rev 1.8   27 Oct 1995 16:45:14   Shirley
** No change.
** 
**    Rev 1.7   27 Oct 1995 13:47:32   Shirley
** No change.
** 
**    Rev 1.6   25 Oct 1995 14:30:22   Shirley
** No change.
** 
**    Rev 1.5   18 Oct 1995 14:51:46   Shirley
** No change.
** 
**    Rev 1.4   13 Oct 1995 13:18:44   Shirley
** No change.
** 
**    Rev 1.3   29 Sep 1995 09:52:20   Shirley
** No change.
** 
**    Rev 1.2   20 Sep 1995 10:53:46   Shirley
** No change.
** 
**    Rev 1.1   15 Sep 1995 09:45:12   Shirley
** No change.
** 
**    Rev 1.0   07 Sep 1995 09:54:40   Shirley
** Initial revision.
**
****************************************************************************/

/////////////////////////////////////////////////////////////////////////////
//
//  File name: MEMADDR.CPP
//
//  Description: The implementation file for the class: CMemoryAddr.
//
//  Author: Chen Jun
//
//  Date: 04/17/95
//
//  Modification:
//      1. 04/17/95, Initial version of the class: CMemoryAddr.
//
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// Include files.
#include "stdafx.h"
#include "resource.h"

#include "memaddr.h"


/////////////////////////////////////////////////////////////////////////////
// Debug flags.
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// Type definitions.


/////////////////////////////////////////////////////////////////////////////
// Macro definitions.


/////////////////////////////////////////////////////////////////////////////
// Global variables.


/////////////////////////////////////////////////////////////////////////////
// Static variables.


/////////////////////////////////////////////////////////////////////////////
// External variables.


/////////////////////////////////////////////////////////////////////////////
// Global function prototypes.


/////////////////////////////////////////////////////////////////////////////
// Local function prototypes.


/////////////////////////////////////////////////////////////////////////////
// External function prototypes.



/////////////////////////////////////////////////////////////////////////////
// Executable codes.


/////////////////////////////////////////////////////////////////////////////
// Public functions.


/////////////////////////////////////////////////////////////////////////////
// Implementation codes of class: CMemoryAddr.

// Construction.
CMemoryAddr::CMemoryAddr()
{

}   // End of CMemoryAddr().

// Copy construction.
CMemoryAddr::CMemoryAddr(unsigned short uAddr, unsigned char uchType)
{
    // Assertion of the input parameters.
    ASSERT( uchType >= 0 && uchType <= 5 );
    
    // Copy construction.
    m_uAddr = uAddr;
    m_uchType = uchType;

}   // End of CMemoryAddr().

// Destruction.
CMemoryAddr::~CMemoryAddr()
{

}   // End of ~CMemoryAddr().


/////////////////////////////////////////////////////////////////////////////
//
//  Name:   CMemoryAddr::operator*().
//
//  Description: The operator function of CMemoryAddr class.
//               Operator(+, -, =, ==, >, <, >=, <=).
//
//  Input:  CMemoryAddr.
//
//  Output: CMemoryAddr.
//
//  Return: CMemoryAddr.
//
/////////////////////////////////////////////////////////////////////////////

// CMemoryAddr1 + CMemoryAddr2.
CMemoryAddr CMemoryAddr::operator+(const CMemoryAddr& Addr)
{
    // Assertion of the input parameters.
    // ASSERT( m_uchType == Addr.m_uchType );

    // Convert.
    CMemoryAddr TmpAddr;
    TmpAddr.m_uAddr = m_uAddr + Addr.m_uAddr;
    TmpAddr.m_uchType = m_uchType;

    if ( 3 == m_uchType || 4 == m_uchType || 5 == m_uchType ) {
        TmpAddr.m_uAddr %= 0x0100;
    }

    return (TmpAddr);
    
}   // End of CMemoryAddr::operator+().

// CMemoryAddr1 + uSize.
CMemoryAddr CMemoryAddr::operator+(const unsigned short& uSize)
{
    // Assertion of the input parameters.
    
    // Convert.
    CMemoryAddr TmpAddr;
    TmpAddr.m_uAddr = m_uAddr + uSize;
    TmpAddr.m_uchType = m_uchType;

    if ( 3 == m_uchType || 4 == m_uchType || 5 == m_uchType ) {
        TmpAddr.m_uAddr %= 0x0100;
    }
    
    return (TmpAddr);

}   // End of CMemoryAddr::operator+().


// CMemoryAddr1 - CMemoryAddr2.
CMemoryAddr CMemoryAddr::operator-(const CMemoryAddr& Addr)
{
    // Assertion of the input parameters.
    // ASSERT( m_uchType == Addr.m_uchType );

    // Convert.
    CMemoryAddr TmpAddr;
    TmpAddr.m_uAddr = m_uAddr - Addr.m_uAddr;
    TmpAddr.m_uchType = m_uchType;

    if ( 3 == m_uchType || 4 == m_uchType || 5 == m_uchType ) {
        TmpAddr.m_uAddr %= 0x0100;
    }

    return (TmpAddr);
    
}   // End of CMemoryAddr::operator-().

// CMemoryAddr1 - uSize.
CMemoryAddr CMemoryAddr::operator-(const unsigned short& uSize)
{
    // Assertion of the input parameters.
    
    // Convert.
    CMemoryAddr TmpAddr;
    TmpAddr.m_uAddr = m_uAddr - uSize;
    TmpAddr.m_uchType = m_uchType;
    
    if ( 3 == m_uchType || 4 == m_uchType || 5 == m_uchType ) {
        TmpAddr.m_uAddr %= 0x0100;
    }

    return (TmpAddr);

}   // End of CMemoryAddr::operator-().


// CMemoryAddr1 = CMemoryAddr2.
void CMemoryAddr::operator=(const CMemoryAddr& Addr)
{
    // Assertion of the input parameters.
    // ASSERT( m_uchType == Addr.m_uchType );

    // Convert.
    m_uAddr = Addr.m_uAddr;
    m_uchType = Addr.m_uchType;

}   // End of CMemoryAddr::operator=().

// CMemoryAddr1 = uNewAddr.
void CMemoryAddr::operator=(const unsigned short& uNewAddr)
{
    // Assertion of the input parameters.

    // Convert.
    m_uAddr = uNewAddr;

}   // End of CMemoryAddr::operator=().


// CMemoryAddr1 == CMemoryAddr2.
BOOL CMemoryAddr::operator==(const CMemoryAddr& Addr)
{
    // Assertion of the input parameters.
    ASSERT( m_uchType == Addr.m_uchType );

    // Convert.
    return ( m_uAddr == Addr.m_uAddr );

}   // End of CMemoryAddr::operator==().


// CMemoryAddr1 == uNewAddr.
BOOL CMemoryAddr::operator==(const unsigned short& uNewAddr)
{
    // Assertion of the input parameters.

    // Convert.
    return ( m_uAddr == uNewAddr );

}   // End of CMemoryAddr::operator==().


// CMemoryAddr1 != CMemoryAddr2.
BOOL CMemoryAddr::operator!=(const CMemoryAddr& Addr)
{
    // Assertion of the input parameters.
    ASSERT( m_uchType == Addr.m_uchType );

    // Convert.
    return ( m_uAddr != Addr.m_uAddr );

}   // End of CMemoryAddr::operator!=().


// CMemoryAddr1 != m_uAddr.
BOOL CMemoryAddr::operator!=(const unsigned short& uNewAddr)
{
    // Assertion of the input parameters.

    // Convert.
    return ( m_uAddr != uNewAddr );

}   // End of CMemoryAddr::operator!=().


// CMemoryAddr1 > CMemoryAddr2.
BOOL CMemoryAddr::operator>(const CMemoryAddr& Addr)
{
    // Assertion of the input parameters.
    ASSERT( m_uchType == Addr.m_uchType );

    // Convert.
    return ( m_uAddr > Addr.m_uAddr );

}   // End of CMemoryAddr::operator>().
                
// CMemoryAddr1 > uNewAddr.
BOOL CMemoryAddr::operator>(const unsigned short& uNewAddr)
{
    // Assertion of the input parameters.

    // Convert.
    return ( m_uAddr > uNewAddr );

}   // End of CMemoryAddr::operator>().


// CMemoryAddr1 < CMemoryAddr2.
BOOL CMemoryAddr::operator<(const CMemoryAddr& Addr)
{
    // Assertion of the input parameters.
    ASSERT( m_uchType == Addr.m_uchType );

    // Convert.
    return ( m_uAddr < Addr.m_uAddr );

}   // End of CMemoryAddr::operator<().

// CMemoryAddr1 < uNewAddr.
BOOL CMemoryAddr::operator<(const unsigned short& uNewAddr)
{
    // Assertion of the input parameters.

    // Convert.
    return ( m_uAddr < uNewAddr );

}   // End of CMemoryAddr::operator<().


// CMemoryAddr1 >= CMemoryAddr2.
BOOL CMemoryAddr::operator>=(const CMemoryAddr& Addr)
{
    // Assertion of the input parameters.
    ASSERT( m_uchType == Addr.m_uchType );

    // Convert.
    return ( m_uAddr >= Addr.m_uAddr );

}   // End of CMemoryAddr::operator>=().

// CMemoryAddr1 >= uNewAddr.
BOOL CMemoryAddr::operator>=(const unsigned short& uNewAddr)
{
    // Assertion of the input parameters.

    // Convert.
    return ( m_uAddr >= uNewAddr );

}   // End of CMemoryAddr::operator>=().


// CMemoryAddr1 <= CMemoryAddr2.
BOOL CMemoryAddr::operator<=(const CMemoryAddr& Addr)
{
    // Assertion of the input parameters.
    ASSERT( m_uchType == Addr.m_uchType );

    // Convert.
    return ( m_uAddr <= Addr.m_uAddr );

}   // End of CMemoryAddr::operator<=().

// CMemoryAddr1 <= uNewAddr.
BOOL CMemoryAddr::operator<=(const unsigned short& uNewAddr)
{
    // Assertion of the input parameters.

    // Convert.
    return ( m_uAddr <= uNewAddr );

}   // End of CMemoryAddr::operator<=().


//////////////////////////////// End of File ////////////////////////////////
