  # Polaris Service Manual: Computer Tutorial

This section is provided as a brief explanation of microprocessors. It is hoped that the reader already has some familiarity with the topic.

Keep in mind that this was published in 1985!

## Binary Numbers

All digital circuits encode information as binary numbers. The binary number system is a method of representing numbers using only the digits 0 and 1. Its advantage is that 0's and 1's are easy to represent electronically by two voltages, while representing decimal digits would require discriminating among ten different voltage levels.

In the decimal number system each digit has a "weight". The rightmost digit has a weight of 1 and each succeeding digit to the left has a weight that is ten times that of its neighbor. Thus, the number 123 equals, of course, (1 x 100) + (2 x 10) + (3 x 1). In the binary number system each digit or "bit" has a weight that is only two times that of its neighbor. Thus, the binary number 10101 equals (1 x 16) + (0 x 8) + (1 x 4) (0 x 2) + (1 x 1), or 21.

When writing numbers we usually write only as many digits as are necessary to represent the number. When a number is represented by something mechanical or electronic, though, it is usually represented by a fixed number of digits. For instance, if your car has 123 miles on it, the odometer will read 00123. Computer numbers generally have a fixed number of bits depending upon the number of parallel lines or serial time-slots used to carry the number. Most computers are capable of processing information 8 bits at a time; this size number is called a "byte". A binary number that is 16 bits long is often called a "word". A binary number that is 32 bits long is often called a "double word" or a "long word".

If a decimal number has "n" digits, it can represent numbers from 0 up to ten to the nth power minus one. For instance, a five-digit odometer can represent numbers from 0 to 99999. If a binary number has "n" bits it can represent numbers from 0 up to two to the nth power minus one. A byte, therefore, can represent numbers from 0 to 255, while a word can represent numbers from 0 to 65535. Any attempt to represent a number larger than the available number or digits causes "wraparound", just as an odometer rolls over from 99999 back to 0.

It is often necessary to refer to a particular bit within a binary number. For this purpose, bits are always numbered from right to left starting with 0. Thus a byte starts on the left with bit 7 and ends on the right with bit 0. The purpose of this numbering is that the weight of bit n is two to the nth power. For instance, the leftmost bit in a byte, bit 7, has a weight of 27, or 128. Bit 0 is also called the "least significant bit" or "lsb", while the leftmost bit is called the "most significant bit" or "msb".

In a binary word or double word each byte can be referred to by number. A 16-bit word contains two bytes; byte 0 is the "least significant byte" or "LSB" while byte 1 is the "most significant byte" or "MSB". Note that these abbreviations use capital letters. In a double word, byte 0 is the LSB and byte 3 is the MSB.

If you examine the following table of powers of two, you will notice that some of the numbers are close to a power of ten. This gives rise to the shorthand notation of using the letters K or M as abbreviations for "kilo" and "mega". Normally, these prefixes mean exactly one thousand and one million; when applied to binary numbers, they actually refer to multiples of 1024 and 1048576. Thus, powers of two can be written in the following shorthand:

power value power value shorthand power value shorthand
0 1 10 1024 1K 20 048576 1M
1 2 11 2048 2K 21 2097152 2M
2 4 12 4096 4K 22 41944304 4M
3 8 13 8192 8K 23 8388608 8M
4 16 14 16384 16K 24 16777216 16M
5 32 15 32768 32K 25 33554432 32M
6 64 16 65536 64K 26 67108864 64M
7 128 17 131072 128K 27 134217738 128M
8 256 18 262144 256K 28 268435476 256M
9 512 19 524288 512K 29 537870952 512M

One final observation on binary numbers: the lsb tells whether the number is odd or even. If the bit is a 0, the number is even; if it is a 1, the number is odd.

Binary numbers, while easy for an electronic circuit to manipulate, are hard for a human to read and write because they have so many digits. For instance, one million in binary is 11110100001001000000. However, converting between binary and decimal is not very easy to do manually, so computer numbers are generally written in a third number system, called "hexadecimal".

Hexadecimal, usually abbreviated "hex", means "base 16". Each digit has a weight that is sixteen times the digit to the right, which means that a total of 16 different symbols are needed to write hex numbers. Hex notation uses the ten decimal digits plus the six letters A through F for this purpose. Thus, one would count in hex: 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 1C, 1D, 1E, 1F, 20, 21, etc. The digits A through F are equivalent to the decimal quantities 10 through 15, while 10 in hex is equivalent to 16 in decimal.

The purpose of hex notation is that it takes very few digits to represent a number and yet it is easy to convert to and from binary. Since sixteen equals two to the fourth power, each hex digit is equivalent to exactly four bits. Thus, one million in hex is F4240 which is (15 x 65536) + (4 x 4096) + (2 x 256) + (4 x 16) + (0 x 1). You will note that each hex digit corresponds to a group or four bits in the binary equivalent 1111,0100,0010,0100,0000.

The range of values represented by a byte is 0 to 255 in decimal. In hex, the range is 00 to FF. The range of values represented by a word (16 bits) is 0000 to FFFF. The range of values represented by a double word is 00000000 to FFFFFFFF. In hex notation multiple F's appear frequently as they represent "all ones".

## Computer Principles

### System Components

A computer is a digital device that sequentially inputs data from and outputs data to external devices, including memory. All data operated on by the computer is represented by binary numbers. In addition the specific operations performed by the computer are selected by the computer's "program", which is a set of instructions also represented as binary numbers. Thus, a computer memory chip can hold both data to be operated on and instructions that tell the computer what operations to perform.

In systems where the computer performs a dedicated function there are two kinds of memory: RAM (random-access memory), which is the kind of memory that can be written into as well as read from, generally holds data only. ROM (read-only memory) or EPROM (erasable programmable ROM) cannot be written into by the computer, and so is used to hold information that never changes, including the computer's program.

In order for a computer to do anything useful it must be connected to devices other than memory. The devices that connect a computer to the outside world are called "input devices" and "output devices", or "input/output devices", often abbreviated "I/O devices". The specific nature of the I/O devices in a system depends upon the purpose of the system. A personal computer might have a video interface chip for controlling a screen, keyboard scanning hardware for connecting to a typewriter keyboard, and a floppy disk controller for mass storage. A musical instrument, on the other hand, might have an analog to digital converter for measuring the position of various controls, a digital to analog converter and a bank of sample and hold circuits to generate analog control voltages, a keyboard scanner, and a number of latches to drive LEDS.

Since a computer is a sequential digital circuit it needs a timing source or clock. Frequently a computer chip will have an on-chip oscillator, so all that is needed is an external crystal. Other computer chips require a separate crystal, RC or LC oscillator circuit. Computer clocks generally run at several megahertz and all timing in a computer system is some subdivision of the clock frequency.

Computers usually need some means for an external device to force the computer to do something other than what it is already doing. The most obvious example is the "reset" signal that keeps the computer from doing anything until the power supply has had time to stabilize. Another example is the "non-maskable interrupt" signal, which is often used by a power-fail sensing circuit to allow the system to shut down gracefully. During normal operation, though, one or more "maskable interrupts" are often needed. These signals cause the computer to temporarily drop whatever it is doing and switch to a different program, presumably a program that services the device that generated the interrupt. When the service program is complete, the computer resumes the interrupted program where it left off. These interrupts are called "maskable" because they can be temporarily disabled, or "masked", when the computer is executing a critical section of its program that should not be interrupted.

### Computer Memory

A memory chip can store a large number of bits. The bits are arranged into an array that has a specific length and width. The width of a memory chip is the number of bits that can be read or written at a time; most memory chips are either 1, 4 or 8 bits wide, the smaller widths usually arranged in parallel to make larger widths. The length of a memory chip is the number of different "locations" in the memory chip. For instance, a 2764 EPROM has 65536 bits, arranged in an 8192 x 8 array; the 2764 has 8192 locations, each containing eight bits or one byte.

Memory chips almost always have widths and lengths that are powers or two. The length determines the number of bits needed to select any of the locations in the chip. The 2764, with 8192 locations, requires 13 bits. Each location is numbered, starting with 0, and these numbers are called "addresses". In hex the range of addresses in a 2764 would be written 0000 to IFFF. Thus, in addition to representing data and instructions, numbers can be used to represent the addresses or data and instructions.

A computer communicates with its memory by using two buses and some control signals. A bus is a set of parallel lines that connects multiple components in parallel, used to carry a binary number. The two buses used by a computer are the "address bus" and the "data bus".

A computer reads from its memory by placing an address on the address bus (which goes to the memory chip) and then generating a pulse on a control line called the "read strobe". The memory chip responds to this strobe by placing the data from that location onto the data bus (which goes back to the computer).

A computer writes to its memory by placing an address on the address bus and the data to be written on the data bus. It then generates a pulse on a control line called the "write strobe". The memory chip responds to this strobe by recording the state of the data bus in the specified location.

Usually, a computer will be connected to more than one memory chip. In this case, the most significant bits of the address bus connect to one or more decoder chips, such as the 74LS138, and the outputs of the decoder chips go to the "chip select" inputs on each memory chip. Only the least significant bits of the address bus connect directly to the memory chips. For instance, if a system required eight 2764 EPROMS, their address inputs might connect to the least significant 13 address bus lines, A0 through A12. Then address lines A13, A14 and A15 would be decoded by a 74LS138 to generate the chip select signals to each memory chip. When the read strobe pulse is generated only the memory chip whose chip select is active would respond.

In the above case, each memory chip would occupy a different range of system addresses. Locations 0000 through 1FFF within each chip would correspond to the following system addresses:

• `0000` through `1FFF` — chip #0
• `2000` through `3FFF` — chip #1
• `4000` through `5FFF` — chip #2
• `6000` through `TFFF` — chip #3
• `8000` through `9FFF` — chip #4
• `A000` through `BFFF` — chip #5
• `C000` through `DFFF` — chip #6
• `E000` through `FFFF` — chip #7

### Data Bus Width

Some computers have 8-bit data buses. In such systems all memory and I/O devices are connected to the same 8 lines. Many modern computers, though, have 16-bit or 32-bit data buses. In these systems it is still necessary to be able to manipulate data in byte-sized chunks.

In a 16-bit system half the memory chips are connected to each half of the data bus and the lsb of the address bus is used to select which half of the data bus data is to be transferred on. Therefore, all even-addressed bytes would be contained in memory chips on the lower half of the bus and all odd-addressed bytes would be contained in memory chips on the upper half of the bus. Such a system can access an entire 16-bit word at a time for speed where appropriate, yet can still access individual bytes. In a 16-bit system the address bus is shifted one place to the right before connecting to the memory chips; that is, address bit 1 goes to A0 on the memory chips, bit 2 goes to A1, bit 3 goes to A2, etc.

In a 32-bit system one quarter of the memory chips are connected to each quarter of the data bus and the two lsbs of the address bus select which section of the bus is to be used. Such a system can access an entire 32-bit double word at a time, or a 16-bit word, or an individual byte. In a 32-bit system the address bus is shifted two places to the right before connecting to the memory chips; that is, address bit 2 goes to A0 on the memory chips, bit 3 goes to A1, bit 4 goes to A2, etc.