RBIL61 - Notes
Originally compiled from multiple sources by Padgett Peterson                   
<>.

No guarantees of any kind.

Copyrights/Trademarks belong to whoever they may belong to.

Found: Algorithm used by IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. in calculating CRC checksums for PS/2IBM PS/2, any model
       (see bytes 32h-33h). Complex (recursive part is 12 lines of
       assembly) and not yet validated for every model.

			Background

The CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. (complementary metal oxide semiconductor) memory is actually 
a 64 or 128 byte battery-backed RAM(Random Access Memory)	See also DRAM, SRAM. memory module that is a part of the 
system clock chip. Some IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. PS/2IBM PS/2, any model models have the capability for a
2k (2048 byte) CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. ROM(Read-Only Memory) A memory for program storage which may not be changed by the program as it runs. Extension.

First used with clock-calender cards for the IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. PC-XT, when the PCIBM PC/ATIBM PC AT
(Advanced Technology) was introduced in 1985, the Motorola MC146818 
became a part of the motherboard. Since the clock only uses fourteen of 
the RAM(Random Access Memory)	See also DRAM, SRAM. bytes, the rest are available for storing system configuration data.

Interestingly, the original IBM-PC/ATIBM PC AT (Advanced Technology) standard for 
the region 10h-3Fh is nearly universal with one notable exception: The 
IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. PS/2IBM PS/2, any model systems deviate considerably (Note: AMSTRAD 8086 machines were 
among the first to actively use the CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. memory available and since they 
*predate* the ATIBM PC AT, do not follow the ATIBM PC AT standard).

This is just another example of how IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. created a standard, lost control 
of it, tried to replace it, failed and lost market share in the process. 

Originally, the IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. PCIBM PC/ATIBM PC AT only made use of a small portion of CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. memory
and was defined in the IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. PCIBM PC/ATIBM PC AT Technical Reference Manual, specifically 
bytes 10h, 12h, 14h-18h, 2Eh-33h. The balance was left undefined but was 
quickly appropriated by various BIOS(Basic Input/Output System) A set of standardized calls giving low-level access to the hardware.  The BIOS is the lowest software layer above the actual hardware and serves to insulate programs (and operating systems) which use it from the details of accessing the hardware directly. manufacturers for such user-selectable 
options such as wait states, clock speeds, initial boot drive selection, and 
password storage.

Later, as CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. memory requirements grew, newer clock chips with 128
bytes of RAM(Random Access Memory)	See also DRAM, SRAM. came into use. However the fact remains that once the ATIBM PC AT 
standard was established, only IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. has tried to change the definitions 
of that first description.

			Accessing the CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption.

The CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. memory exists outside of the normal address space and cannot
contain directly executable code. It is reachable through IN and OUT
commands at port number 70h (112d) and 71h (113d). To read a CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. byte,
an OUT to port 70h is executed with the address of the byte to be read and
an IN from port 71h will then retrieve the requested information. The 
following BASIC(Beginner's All-purpose Symbolic Instruction Code) A programming language originally designed as a means of teaching FORTRAN.  There are many variations of BASIC with differing capabilities; the majority are interpreted but compiled BASIC is becoming more popular.	All genuine IBMInternational Busiuness Machines personal computers (including the latest PS/2IBM PS/2, any model models) come equipped with a cassette-based BASIC interpreter in ROM. fragment will read 128 CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. bytes and print them to the 
screen in 8 rows of 16 values.

The CMOS RAMA small amount (typically 64 or 128 bytes) of memory in the system's real-time clock chip that is preserved by the clock's battery and is used for storing configuration information.  See also Real-Time Clock. space has an upper limit of 128 bytes because of the structure
of port 70: only bits 0-6 are used for addressing, bit 7 is used to 
enable (0) or disable (1) Non-Maskable Interrupts (NMIsee Non-Maskable Interrupt) and explains why
IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. uses 80h OR <address> to read/write data & follows with  a "throw-away"
call.

Note that if the CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. only has 64 bytes available, addressing will 
generally wrap and addresses from 40h-7Fh will mirror 00h-3Fh. Output will 
be hexadecimal.

10 CLS
20 FOR i = 0 TO &H7F 
30 OUT &H70, i
40 PRINT USING "\   \"; HEX$(INP(&H71));
50 NEXT i
60 PRINT " " 

Note: where not otherwise noted, all data points are expressed as BYTES
      these are eight bit values and are read from MSB to LSB e.g.
      0000 0000	    0101 1010 binary would be written as 5Ah
      7654 3210	    where only some bits are used this is represented with
		    Xs e.g bits 5-3 would be shown as 00xx x000

Note: the entries for AMIAmerican Megatrends, Inc.(American Megatrends, Inc.) A hardware, software and firmware company founded in 1985. WinBIOS also apply to AMIBIOS with core dates of 
	12/15/95 or later


Newer BIOSes have two checksums in the CMOS RAMA small amount (typically 64 or 128 bytes) of memory in the system's real-time clock chip that is preserved by the clock's battery and is used for storing configuration information.  See also Real-Time Clock., the second one covering
bytes 40h through 7Ch (or 7Eh).  Unfortunately, the second checksum is at
a different location in different BIOSes.  The following code from 
Agapov Vasiliy Pavlovich <> (28 Aug 1996) is designed to
find the location of the second checksum byte on *any* BIOS(Basic Input/Output System) A set of standardized calls giving low-level access to the hardware.  The BIOS is the lowest software layer above the actual hardware and serves to insulate programs (and operating systems) which use it from the details of accessing the hardware directly. (successfully
tested on various versions of AMIAmerican Megatrends, Inc.(American Megatrends, Inc.) A hardware, software and firmware company founded in 1985. and AWARD BIOSes).

Agapov's instructions for use:
> Before starting this code make sure to load the 128 bytes of CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. data
> to the buffer at CMOS_DATA and assume DS as data area segment register.

START:	CALL	WHAT_CMOS
	JC	NO_SECOND_CHS

; Checksum location is in word at  CHECKS_ADDRESS

NO_SECOND_CHS:

; There's no second checksum in this CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption.

END:

;******************************* SUBS **********************************

WHAT_CMOS:	MOV	SI,OFFSET CMOS_DATA+40H
		MOV	DI,OFFSET CMOS_DATA+7EH
		CALL	FIND_CMOS_CHS
		JNC	END_WCMOS
		MOV	SI,OFFSET CMOS_DATA+41H
		MOV	DI,OFFSET CMOS_DATA+7EH
		CALL	FIND_CMOS_CHS
END_WCMOS:	RET


FIND_CMOS_CHS:	XOR	DX,DX
		MOV	AX,DX
FIND_CMOS_C1:	LODSB			; GET BYTE
		ADD	DX,AX
		CMP	SI,OFFSET CMOS_DATA+7CH	; ADDRESS OF CHECKSUM ?
		JB	FIND_CMOS_C1
		XCHG	DH,DL
		CMP	DX,[SI]		; CHECKSUM FOUND ?
		JZ	END_FCMOS
		XCHG	DH,DL
		CMP	SI,DI
		JB	FIND_CMOS_C1
		STC
		RET
END_FCMOS:	MOV	[CHECKS_ADDRESS],SI	; SAVE CHECKSUM POSITION
		CLC
		RET

******************************** DATA *******************************

CHECKS_ADDRESS	DW	0

CMOS_DATA	DB   128 DUP (?)
                                                                                

		Organization of CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. Memory - Clock

00h-0Eh is defined by the clock hardware and all must follow it.  Other 
manufacturers generally follow the same format as specified for the
region 10h - 2Fh. Some also follow the IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. format for 30h-33h but not all 
(Zenith in particular is different).

The first fourteen bytes are dedicated to the MC146818 chip clock functions 
and consist of ten read/write data registers and four status registers, two 
of which are read/write and two of which are read only.

The format of the ten clock data registers (bytes 00h-09h) is:
                                                                                

		Organization of CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. Memory - non-Clock

The last two bytes in the first hexadecimal decade (hexade ?) were not 
specified in the PCIBM PC/ATIBM PC AT but may have the following use on some systems:
                                                                                

The second group of values extends from address 10h to 2Dh. The word at
2Eh-2Fh is a byte-wise summation of the values in these bytes. Most BIOSes
will generate a CMOS(Complementary Metal-Oxide-Semiconductor) A type of integrated circuit design known for its low power consumption. Checksum error if this value is invalid however many 
programs ignore the checksum and report the apparent value. The current
version of MSD reports my XTIBM PC XT as having 20+ MB of extended memory. 

Where a definiton appears universal, no identification is made. Where
the definition is thought to be specific to a manufacturer/model (AMIAmerican Megatrends, Inc.(American Megatrends, Inc.) A hardware, software and firmware company founded in 1985., 
AMSTRAD, IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. ATIBM PC AT, IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. PS/2IBM PS/2, any model) the identification is enclosed in parens. The
AMSTAD definitions appear to relate to 8088/8086 (PCIBM PC and PCIBM PC/XTIBM PC XT class)
mchines only. ATIBM PC AT class machines appear to adhere to IBMInternational Busiuness MachinesInternational Busiuness Machines) A hardware, software and other service technology company founded in 1911. PCIBM PC/ATIBM PC AT fornat.