
Module: E:\SOURCE\TMP\CMOS\cmos.cpp
Group: 'DGROUP' CONST,CONST2,_DATA,_BSS

Segment: _TEXT  PARA   00000023 bytes  

#include <conio.h>

class CMOS;
class CMOSByte {
        friend class CMOS;
        unsigned char index;
        CMOSByte(unsigned char i) : index(i) {}
public:
        operator int() const;
};

class CMOS {
        friend class CMOSByte;
        static unsigned char read(unsigned char addr);
public:
        CMOSByte operator[](int index) {
                return CMOSByte((unsigned char)index);
        }
};

CMOSByte::operator int() const {
 0000                    near CMOSByte::operator int () const:
 0000  53                                push    bx
 0001  52                                push    dx
 0002  89 c3                             mov     bx,ax

        return CMOS::read(index);
 0004  ba 70 00                          mov     dx,0070H
 0007  8a 07                             mov     al,[bx]
 0009  ee                                out     dx,al
 000a  ba 71 00                          mov     dx,0071H
 000d  ec                                in      al,dx
 000e  28 e4                             sub     ah,ah

}

 0010  30 e4                             xor     ah,ah
 0012  5a                                pop     dx
 0013  5b                                pop     bx
 0014  c3                                ret     
 0015  fc                                cld     

unsigned char CMOS::read(unsigned char addr) {
 0016                    char unsigned near CMOS::read( char unsigned ):
 0016  52                                push    dx

        outp(0x70,addr);
 0017  ba 70 00                          mov     dx,0070H
 001a  ee                                out     dx,al

        return (unsigned char)inp(0x71);
 001b  ba 71 00                          mov     dx,0071H
 001e  ec                                in      al,dx
 001f  28 e4                             sub     ah,ah

}

 0021  5a                                pop     dx
 0022  c3                                ret     

No disassembly errors

------------------------------------------------------------
