CMOS Explained

What is it?

CMOS is simply some memory that has battery backup so that it maintains its state between power cycles.

It is part of a chip that can be seen in your computer. Its part number is usually MC146818.

Why is it?

Information about the make up of the system needed to be retained between power cycles so that the system could boot properly. CMOS was designed to maintain that information in the simplest manner possible. It also had to be modifiable in the event that the make up of the system changed. Its design also mandated that a machine come from the factory with the CMOS configured to reflect the make up of the system at the time it was shipped.

What can it affect?

How is it set?

The CMOS is set at the factory so that it conforms to the configuration shipped. During the boot procedure you can stop the process and change this. Usually a message indicating how this can be done will be help on the screen for a few seconds so that you might do this.

There are also ways to read and write this memory from a programmer's standpoint.

Access via the BIOS

This method limits you to the DOS clock and the real-time clock. Here is an example:

	mov ah, 03h;	function 03H
	mov cl, 45h;	45 minutes
	mov ch,	12h;	12 hours
	mov dl, 00h;	no daylight saving
	mov dh, 00h;	0 seconds
	int 1ah	   ;	set time via interrupt 1ah

Access via Address and Data Registers

	IN  al, 70h;	 read old byte from port 70h
	AND al, e0h;	 clear the five low order bytes
	OR  al, 12h;	 load accumulator al with address
		   ;	 of byte 18, bit 7 remains unchanged
	OUT 70h, al;	 write address of byte 18 into address
		   ;	 register
	IN  al, 71h;	 read drive type into accumulator