Contributor: PETER VAN DER LANDEN 
{
From: landen@cir.frg.eur.nl (Peter van der Landen)>I am attempting to write a program in TP6.0 that reads the CMOS memory>(IBM PC) and saves the settings to a disk file. I know there are 255>locations, but I don't know where. If someone could point me to the>correct memory addresses, I'd really appreciate it. Thanks (in advance)!
This unit (by an unknown other) shows you how it's done. The CMOS memory is
not part of the PC's main memory. Values are written/read by accessing an
I/O port.
}
unit CMOS;
Interface
const
 ClockSec = 00ドル; { RTclock seconds }
 ClockMin = 02ドル; { RTclock minutes }
 ClockHour = 04ドル; { RTclock hours }
 ClockDOW = 06ドル; { RTclock day of week }
 ClockDay = 07ドル; { RTclock day in month }
 ClockMon = 08ドル; { RTclock month }
 ClockYear = 09ドル; { RTclock year (mod 100)}
 AlarmSec = 01ドル; { Alarm seconds }
 AlarmMin = 03ドル; { Alarm minutes }
 AlarmHour = 05ドル; { Alarm hours }
 Diskettes = 10ドル; { Floppy disk type byte }
 HardDisk = 12ドル; { Regular hard disk type }
 HDExt1 = 19ドル; { Extended hard disk type, unit 1 }
 HDExt2 = 1ドルA; { Extended hard disk type, unit 2 }
 Equipment = 14ドル; { Equipment list }
 CheckLo = 2ドルF; { Checksum low }
 CheckHi = 2ドルE; { Checksum high }
 BaseLo = 15ドル; { Base mem low }
 BaseHi = 16ドル; { Base mem high }
 ExpdLo = 17ドル; { Expansion mem size low }
 ExpdHi = 18ドル; { Expansion mem size high }
 StatRegA = 0ドルA; { Status Register A }
 StatRegB = 0ドルB; { Status register B }
 StatRegC = 0ドルC; { Status register C }
 StatRegD = 0ドルD; { Status register D }
 DiagStat = 0ドルE; { Diagnostic status byte }
 ShutDown = 0ドルF; { Shutdown status byte }
 Century = 32ドル; { BCD Century number }
 AltExpdLo = 30ドル; { Expansion mem size low (alternate) }
 AltExpdHi = 31ドル; { Expansion mem size high (alternate) }
 InfoFlags = 33ドル; { Bit 7 set = top 128k installed, bit
 6 set = first user message (?) }
function ReadCmos(Address: byte): byte;
 { Returns the byte at the given CMOS ADDRESS }
procedure WriteCmos(Address, Data: byte);
 { Writes DATA to ADDRESS in CMOS ram }
procedure SetCMOSCheckSum;
 { Sets the CMOS checksum after you've messed with it :-}
{ The following bytes are RESERVED: 11,ドル 13,ドル 1ドルB-2ドルD, and
 34ドル-3ドルF (3ドルF marks the end of the CMOS area). You'll note that
 some of these are included in the checksum calculation. }
implementation
const
 CmosAddr = 70ドル; { CMOS control port }
 CmosData = 71ドル; { CMOS data port }
function ReadCmos(Address: byte): byte;
begin
 port[CmosAddr] := Address;
 ReadCmos := port[CmosData]
end; {ReadCmos}
procedure WriteCmos(Address, Data: byte);
begin
 port[CmosAddr] := Address;
 port[CmosData] := Data
yend; {WriteCmos}
procedure SetCMOSCheckSum;
{ The checksum is simply the sum of 10ドル to 2ドルD 
 (some of these bytes are reserved) }
var
 I, Sum: word;
begin
 Sum := 0;
 for I:= 10ドル to 2ドルD do Sum := Sum + ReadCmos(I);
 WriteCmos(CheckHi, Hi(sum));
 WriteCmos(CheckLo, Lo(sum));
end; {SetCMOSCheckSum}
end.
 

AltStyle によって変換されたページ (->オリジナル) /