SHCC WYSIWYG Article from June 2002

Previous Next

This article appeared in the June 2002 WYSIWYG newsletter.


by Jerry Carson

In April we discussed computer programs and the fact that computers can only do what their programs tell them to do.  In fact, your computer (when turned on) is ALWAYS running a program. Usually that program is checking the keyboard to see if you're typing anything.  But wait, if computers are so stupid, how does it know how to check the keyboard?  Remember, the basic instructions that most computers know are ADD, SUBTRACT, MULTIPLY, DIVIDE, STORE, LOAD, JUMP, and COMPARE.  I don't see any CHECK KEYBOARD instruction.

Well, the computer gets a little help from the rest of its hardware.  When a key on the keyboard is pressed, an electrical signal is sent into the computer where it is received by a keyboard decoder chip.  This chip, based on the signal received, determines which key was pressed and places a code into a special memory location.  Then, the computer only has to check that  location (using LOAD and COMPARE instructions) to find out which key, if any, was pressed.

Sending characters, say out to the printer, works in the other direction.  The computer puts the code into a  special location and the hardware takes care of getting it to the device.  The status of the transfer is placed in a memory location so the computer can check to make sure everything went OK or retry if there was an error.

This is a little simplified but basically, these same steps are taken to send information out of the computer (output) or to get information in to the computer (input).  That includes modems, printers, scanners, keyboards, mouses, graphics, networks, hard disks, floppy disks, tape backups, etc.

So if a computer program needed to read the keyboard, read and write to a floppy, write to the screen, and print, it would have to deal with all those special memory locations and all the retries and setup steps as well.  And this is exactly what the first programs did.

However there were incompatibility problems.  Even computers that used the same machine language might use different locations for their input and output (I/O).  So a program that worked on one computer might not work with a different computer, even if they used the same chip.  Also, if you wanted to use a different printer, you had to rewrite your program.

This problem was solved by creating a collection of routines (small pieces of machine language) that handled the special memory locations.  So if you wanted to check the keyboard, the computer could JUMP to the routine that checked the keyboard.  That  routine would handle all the special memory locations and would JUMP back with the character received.  And, most importantly, the location of the "check keyboard" routine would be the same across a number of different computers.  So the program would not need to be changed to work with a different computer. These routines where placed into a ROM chip and soldered onto the computer.

This also solved another very difficult problem.  If the computer always needs to be running a program, how does it know how to read the hard disk and get the first program?  Again, the answer was the BIOS (Basic Input Output System) chip.  One of the routines in the BIOS chip handles reading the first program from the hard drive (or floppy, CDROM, or network).  Once that first program is loaded, the computer JUMPs to it and starts running.

Over the years the BIOS has gotten more and more complicated.  Today they may perform self diagnostics, virus checking, configure option cards, and even handle security.  And, oddly enough, most computers today no longer use the BIOS for I/O.  Instead they use device drivers.  More about what a device driver is and why they are used instead of the BIOS in the next installment.

End of Article

Previous Next

To discuss the article with the author, send an email.

Article Index Page

Club members should contact the webmaster with comments and suggestions about this web site.