Chapter 1 Computer Organization

Chapter 1 Computer Organization

1 CHAPTER 1 c COMPUTER ORGANIZATION A computer can be organizationally broken down into four functions: SENSE, RESOLVE, STORE, and ACT. SENSE RES...

489KB Sizes 4 Downloads 235 Views

1

CHAPTER 1

c COMPUTER ORGANIZATION

A computer can be organizationally broken down into four functions: SENSE, RESOLVE, STORE, and ACT.

SENSE

RESOLVE

I-)

ACT

STORE

The SENSE function receives information from outside the system and transmits it to the machine for interpretation.

The

RESOLVE function performs all the logical and operational functions.

The STORE function must remember the correct

instructions and sequence of operations. function executes the decision. is a Builder.

Finally, the ACT

A human analogy to this system

In order for a Builder (Resolve) to make a House

(Act), he/she must use Materials (Sense) according to a set of Plans (Store). MATERIALS

BUILDER

PLANS

HOUSE

2

In a computer, the SENSE function is described by Inputs, the RESOLVE function by Processor, the STORE function by Memory, and the ACT function by Outputs.

INPUTS

PROCESSOR

OUTPUTS

MEMORY

The processor or central controlling element of a computer, when available in integrated circuit (IC) form is called a microprocessor.

Connecting memory and input/output ( I / O )

circuits to a microprocessor produces a computer.

When such a

completed digital system is in the smallest size range and slowest speed range when compared to all other digital systems, it is called a microcomputer.

1.1

BITS, BYTES, AND NIBBLES A "bit" is defined as a binary d i g g equal to either 0 or

1 , i.e. either

Off or on. In the

6502 and most microprocessors,

logic "1" is defined as a voltage level of + 2 . 4 logic " 0 " as 0 (ground) to +0.8VDc.

to +5VDc, and

3

N bits can be arranged into 2N different patterns.

I'

2 bits -->

2L = 4 patterns

4 bits --> Nibbl e

24 = 16 patterns

8 bits --> Byte

28 = 256 patterns

00, 01, 10, 11

*I

It

16 bits -->

216 = 65,536 patterns

The 6502 is an 8-bit microprocessor which means that the primary informational unit is the byte (8-bits). All transfers to and from the 6502 are done 8-bits at a time on an 8-line data _bus. _

A complete byte of information is shuttled to and from

memory locations, registers, 1/0 circuits (another memory location) and every external device.

The data bus is

bidirectional in nature. Every memory location accessed by the 6502 microprocessing unit ( M P U ) is capable of containing 8-bits (one byte) and is specified by a unique address.

Sixteen lines which are

address bus . are used to identify the 16-bit (two designated the byte) address of every location.

Since there are 216 unique

16-bit binary numbers, the 6502 -. can __ address 65,536 or 64K (1K=1024) memory locations.

The amount of actual memory depends

upon how many external memory chips are available to the 6502. Since one byte

=

8 bits and one memory location can contain

one byte, the information in one location can represent any one of 28 or 256 different things.

It can be:

4

( a ) a number. ( b ) a character. ( c ) a pattern.

An example illustrating t h e 3-bit case is depicted i n Fig. 1-1.

z3

Here, t h e 3 binary ( o n / o f f ) switches a r e used to generate

= 8 different light patterns.

+sv

Switches

s1

s2

s3

0

0

0

0 0

0 1 1 1 1

0 1

1 0 0 1 1

Lights R

G

1 0 1 0 1 0 1

z3 Fig. 1-1.

B

= 8 different patterns

Light Patterns generated by Three Binary Switches.

5

In the 6502 Microprocessor, the standard unit of information acted on and transmitted to all the components is the digital code called the byte (8 bits).

In all cases the

pattern of 0 ' s and 1's in this 8-bit number (or combinations thereof) mean certain things to certain subsystems.

It can

represent: 1. Instructions

2. Locations in Memory

3 . Locations of I/O Devices 4. Data 5. Character Representations

1.2

INSTRUCTIONS

.---_______

The microprocessor or microprocessing unit ( M P U ) acts on an instruction in the following manner as determined by the system clock (usually a crystal oscillator). 1. Locate (Address) instruction in memory 2. Read (Fetch) instruction from memory 3 . Interpret (Decode) instruction 4. Execute instruction

--1.3

LOCATIONS IN MEMORY Memory locations (or cells containing 8-bit numbers) are

indicated by Address Codes (16-bit numbers) which represent where in the computer that memory location can be found.

The

microprocessor can read a byte from or write a byte to a memory location.

6

Memory which can only be read from and not written to is called E M (Read Only Memory).

It is nonvolatile (remains on

when the power is off) and usually contains such functions as instructions, initialization routines, I / O routines, etc. Memory which can be both read from and written to is called RAM (Random Access Memory).

It should more appropriately be called

R/W (Read-Write) Memory since ROM is also randomly accessible (viz., the speed of transfer to and from a memory location does not depend on its address). The microprocessor reads from or writes to a particular memory location by sending out a specific 16-bit voltage pattern

of 0 ' s and 1 ' s on the 16-line address bus which locates that specific memory location and an appropriate control signal on the READ/WRITE line ( R / W ) .

Usually a binary "1" is sent for a

READ operation and a " 0 " for a WRITE operation.

-W indicates

that the WRITE operation is activated when this particular signal line is brought to a low voltage (1.e. ground).

Reading

an instruction from memory (ROM or RAM) is called "fetching" an instruction.

1.4

LOCATIONS OF 1/0 DEVICES In the 6 5 0 2 microprocessor, the instructions used to access

memory are the same instructions used to perform input (read) and output (write) operations on peripheral devices.

Unlike

many other microprocessors, no distinction is made between

7

memory and 1/0 devices. memory.

Every external device is treated as

This technique is called memory-mapped I/O.

The

complexities of having to pass all data handling/manipulation through a working register are eliminated.

1.5 DATA ______ Data in the 6 5 0 2 is an 8-bit number (byte) representing an instruction, an alphanumeric character, a control signal, or the on/off status of some subsystem of the computer.

It is

transferred by the microprocessor to and from memory on an 8-line, bidirectional data bus. to

An input device transfers data

the microprocessor and an output device receives data

from

the microprocessor.

~1.6

PROGRAMMING L A N G U A g In order for a computer to perform a useful function, it

must be instructed or programmed to do so.

The language that

the computer understands is a series of binary voltages represented by 0 ' s and 1's in a digital code called the machine code or machine language.

Specific bit patterns mean specific

things to the computer (instructions, addresses, data, 1/0 devices...).

Unfortunately, machine language is not very

meaningful to humans and programs are usually written in assembly language or higher-level languages.

Instructions

written in assembly language usually correspond on a one-to-one

8

basis with machine language instructions.

In a sense, assembly

language is one step removed from machine language.

Higher

level languages, on the other hand, contain statements that may be comprised of many machine-language instructions.

As a

result, these languages are several steps removed from machine language. The assembly language program (sometimes called a source code) is converted into a machine language program (sometimes

.

called an object code) by a special program called an Assembler. The reverse process (machine--> assembly language) is executed by a program called a Disassembler. Although assembly language is preferred to machine language programming, it does have one serious drawback.

It is dependent

upon the instruction set of the particular microprocessor in use at the time.

Program exchange between different microprocessors

is virtually nonexistent.

In order to overcome this and other

difficulties, higher level languages have been developed. Examples of these include BASIC, FORTRAN, COBOL as well as numerous others.

Programming efficiency is much greater with

higher level languages and program exchange is possible between different computer systems (within limits).

The drawbacks are

increased memory requirements and slower execution times although in many applications this does not present a problem. In some applications, however, slow execution speed is not only undesirable but unacceptable.

9

Higher level languages can generally be classified according to two types: Compilers and Interpreters. Compilers are similar to assemblers in the fact that they take the higher-level language '(source code) and convert (translate) it into an executable machine language program (object code).

They are special programs that translate the

entire high-level program into machine code for storage and later execution.

Once the object (machine) code is generated,

it can be executed independently from the source code or the compiler program.

That is to say, it does not need to be

co-resident in memory with the source code and/or Compiler. Interpreters are programs that not only translate higher-level languages into machine code but also execute the code, usually on a line-by-line basis.

Once a section of a

higher level program is translated and executed, it is scrapped and the Interpreter goes on to another section.

No object code

is generated and all executing is done by machine code programs

__within the Interpreter. They are simply called upon as needed. As

a result, the source code for the high-level program must be

co-resident in memory with the Interpreter for proper execution. Compilers and Interpreters have their advantages and disadvantages.

While Compilers produce object code which can be

executed at high speed, they tend to be less interactive than Interpreters.

If an error (bug) is discovered in a compiled

program, the source code must be edited and the entire program

10

re-compiled prior to execution.

Interpreters, on the other

hand, allow such changes to be easily made. paid for this capability is speed.

However, the price

Interpreters generally

execute programs 20-30 times slower than the machine language programs generated by Compilers.

This very fact is

experimentally demonstrated in the last Chapter. FORTRAN and COBOL are typical examples of compiled high-level languages while most microcomputers today employ BASIC Interpreters (Usually in system ROM).

BASIC Compilers do

exist, however, and are available for some computers where demanding applications require shorter, faster programs. Fig. 1-2 depicts the hierarchical order of compiled programming languages. Notwithstanding the utility and programming ease of higher-level languages, they do possess the singular drawback of removing the programmer increasingly further from the actual operations of the computer.

While this may not be much of a

concern in number-crunching or business (viz., word-processing) applications using a limited number of conventional 1/0 devices (keyboards, CRT’S, printers...), it is a problem in scientific and/or industrial process control schemes where nonstandard peripheral devices are used.

Furthermore, assembly language

provides the opportunity to execute a program as fast as possible, an important feature in high speed data acquisition and control systems.

11

-

...

Higher Level Languages (BASIC, FORTRAN )

Assembly Language (Source Code)

Machine Language (Object Code)

t1

Cross-Assembler Program

Assembly Language (in another computer)

-

Higher Level Languages (in another computer)

Fig. 1-2.

Hierarchy of Compiled Programming Languages.

12

1.7

AIM 65 MICROCOMPUTER The preceding principles and concepts are most clearly

demonstrated in the AIM 65 Microcomputer manufactured by Rockwell International Corporation.

Like the Apple II/IIe

(Apple Computer, Inc.), the Commodore 64/VIC-20/Pet 2001 (Commodore Business Machines) and the Atari computers (Warner Communications, Inc.), it is a machine based on a version of the 6502 microprocessor.

The AIM 65 was primarily designed as an

instructional tool for individuals interested in learning about microcomputers and their interfacing possibilities.

Its

advanced features also make it attractive as a low cost development system for laboratory/industrial applications. In the AIM 65 Microcomputing System, the 6502 MPU, operating at 1 MHz is capable of accessing 20K bytes of on-board ROM and 4K bytes of on-board RAM.

An Expansion Connector

extends the system busses (address, data and control) out to additional memory.

The Advanced Interactive Monitor is

allocated to 8K of ROM with the remainder (12K) available for various on-board PROM/ROM options (8K BASIC Interpreter, 4K two-pass Assembler, 8K FORTH Interpreter, 8K PL/65

... 1 .

Two 6522 Versatile Interface Adapters (VIA’S) provide 1/0

capability to the 6502.

One device supports the on-board

thermal printer and the TTY and dual audio cassette interfaces while the General Purpose 1/0 Ports of the other VIA are available to the user for a variety of interfacing

13

configurations.

Each VIA has two parallel and one serial 8-bit,

bidirectional 1/0 ports, two 2-bit peripheral handshake control lines (useful for interfacing displays, printers, A/D

&

D/A

Converters...) and two fully programmable 16-bit interval timer/event counters (used in timing and frequency measurement applications).

A 6532 RAM-Input/Output-Timer (RIOT) chip is

used by the AIM Monitor for scratchpad memory and keyboard operations.

Fig. 1-3.

Fig. 1-3 illustrates the overall system layout.

AIM 65 Block Diagram and Memory Map. (Courtesy of Rockwell International Corporation).