Lecture 2 - Computer Hardware and Language

Download Report

Transcript Lecture 2 - Computer Hardware and Language

Class Agenda
 What does a computer consist of?
 Basic design of a PC
 The CPU
 How a CPU stores instructions
 How are Program Instructions Processed?
 How is memory organized?
 Why is different hardware used to store the
same type of information?
 Computer Languages
 Key Definitions you need to know
Basic design of a PC
 If you were to design a computer what would
you pick as its major components?
 -- a memory, a central processing unit, a clock
and a set of ports:
the memory stores the information used by the
system
the central processing unit (CPU) processes the
raw data
the clock controls the rate at which the CPU works
the ports connect the CPU to external devices
(such as a keyboard, a mouse, a hard disk, a CDROM, a floppy, a printer, a joystick and speakers)
The CPU
 The CPU includes a control unit and an
arithmetic/logic unit.
 The control unit fetches instructions from
memory, decodes them and executes them.
 The arithmetic/logic unit (ALU) performs all
arithmetic operations and logical comparisons.
 The CPU also contains registers where data is
stored. The ALU cannot work directly on data in
memory. Data needs to be copied into the
registers before the ALU can use it.
How a CPU stores instructions
 In a modern computer - that is, a
stored program machine - the
CPU retrieves instructions and
data from memory, processes the
instructions and returns the
coherent data to memory.
 The control unit includes a
program counter. This counter
holds the address of the next
instruction to be executed.
How is memory organized?
 Computer memory is organized as a linear collection of
bytes. Typically, each byte consists of 8 bits. A bit is a single binary
digit, which holds the smallest unit of information. Each byte has a
unique address. The addressing is sequential, starts at zero and
ends at the size of memory less 1. Note that each byte and not
each bit has its own address.
 For example, 128 bytes of memory consists of 1024 (= 128 * 8) bits
where information can be stored, starts at address 0, and ends at
address 127.
 The maximum size of usable memory depends upon the number of
bits in the smallest address register in the CPU: in a 32-bit CPU,
addresses can range from 0 to 232-1, which is 0 to 4,294,967,295 or
4 Giga. So, the maximum size of usable memory for a 32-bit CPU is
4 Gb (Gigabytes). The size qualifiers are
 Kilo or k (=1024): 1 Kilobyte = 1024 bytes
 Mega or M (=1024k): 1 Megabyte = 1024 * 1024 bytes
 Giga or G (=1024M): 1 Gigabyte = 1024 * 1024 * 1024 bytes
 Petabytes (=1024G): 1 Petabyte =
Why is different hardware used to store
the same type of information?
 Data can be stored in the CPU registers, the internal cache (L1), the
external cache (L2) and RAM (Random Access Memory). The closer the
data is to the CPU, the higher the transfer rate. The rate at which
information is transferred where the information is stored.
 In a relative sense,
 CPU registers process data at less than 10 nanoseconds
 internal cache can hold 4-16kb data and transfer at less than 10
nanoseconds
 external cache can hold 128-512kb data and transfer at about 20
nanoseconds
 RAM can hold 32-128Mb and transfer at 60 nanoseconds
 a hard disk can hold 1-20Gb data and transfer at 12,000,000
nanoseconds
 (A nanosecond is 1 * 10-9 seconds.) The ratio of the time it takes a CPU to
process data to the time it takes a hard disk to store it is the same as the
ratio of the time it takes me to cross this room to the time it takes me to walk
around the earth once at the same pace.
 Fast memory is expensive. Slow memory is inexpensive. The most
expensive storage is reserved for the CPU itself while the least expensive is
limited to the peripheral devices.
Computer Languages – First Generation
 Each machine instruction is a binary number. Even for a
popular CPU, machine language is extremely awkward
to write.
 Machine Languages are First Generation or low-level
languages.
 Machine Language is a series of codes, represented by
binary numbers, used to communicate directly with the
internal instructions of the PC’s microprocessor.
 Deciphering Machine Language code or writing it is a
complex task
 However, programs called interpreters and compilers
translate commands written in higher-level languages
into machine language.
Computer Languages – Second
Generation
 The first step towards readability came with Assembly
Language in 1951 (or just Assembly).
 An assembly language instruction might look like
MOV 10000001, BX
; move the contents of
10000001 into register BX
 where MOV is the operation code,
 10000001 and BX are the memory address and register
fields,
 ; marks the end of the assembly language statement and
 move the contents of 10000001 into register BX is
commentary for programmer reference.
Computer Languages –Second
Generation (cont.)
 In assembly languages, the operation codes are written as simple command
words to supply step-by-step instructions for the processor to carry out.
 Assembly Languages directly manipulates the values contained in those
memory scratch pads in the microprocessor called registers.
 Although more intelligible to human than machine language codes,
assembly is still more difficult to use that higher-level languages.
 However, Assembly remains popular among programmers because it
creates compact, fast code.
High Level Languages
 The third generation of programming languages broke the relation to
machine language. In high-level languages, the instructions are
English-like as opposed to machine-like.
 Languages such as C and Java allow programmers to write in terms
and words that more closely parallel English
 Java is the current rising star in language since a program written in
Java will run on any computer no matter what operating system it is
using.
 However - the only language that a computer can interpret is its
native machine language. To convert a program written in a highlevel language to machine language, pass the high-level source
through a separate program called a compiler.
Some of the Languages Developed since
1950
 Over the development history of programming languages, the first three
generations were procedural. These languages execute instructions
sequentially. The fourth generation languages are non-procedural.
Key Definitions
 BIOS (basic input / output system)
A collection of software codes built into a PC that
handle some of the fundamental tasks of sending
data from one part of the computer to another
 Boot or boot-up
The process that takes place when a PC is turned
on and performs the routines necessary to get all
the components functioning properly and the
operating system loaded. The term comes from
lifting yourself by your bootstraps
Key Definitions (continued)
 Clock
 A microchip that regulates the timing and speed of all of the
computers functions. The chip includes a crystal that vibrates at
a certain frequency when electricity is applied to it.
 The shortest length of time in which a computer can perform
some operation is one clock, or one vibration of the clock chip.
 The speed of clocks – and therefore computers themselves –
have been expressed in megahertz (MHz). One megahertz is 1
million cycles, or vibrations, a second. Newer computers are
measured in gigaherz
 Thus, a PC can be described as having a 1.5 GHz processor,
which means that the processor has been designed to work with
a clock chip running at that speed. Current home computer
speeds are above 3.0 GHz
Key Definitions (continued)
 CMOS
An acronym for complementary metal-oxide
semiconductor – a term that describes how a CMOS
microchip is manufactured. Powered by a small battery,
the CMOS chip retains crucial information about what
hardware a PC is comprised of even when the power is
turned off.
 CPU
An acronym for central processing unit, it is used to
mean the microprocessor – also, processor - which is
the microchip that processes the information and the
code (instructions) used by a computer. The ‘brains’ of a
computer.
Key Definitions (continued)
 Expansion slot
Most PCs have unused slots into which the owner
can plug circuit boards and hardware to add to the
computers capabilities. Most slots today are
personal computer interface (PCI).
One other slot, the accelerated graphics port
(AGP), accepts a video card designed to move
images out of memory quickly.
 Motherboard
Main circuit board into which has connections for
most of the components of the computer including a
variety of add-in boards which may easily be
purchased (e.g., sound card, wireless network)
Key Definitions (continued)
 Operating System
 Software that exists to control the operations of
hardware.
 Essentially, the operating system directs any
operations, such as writing data to memory or to
disk, and regulates the use of hardware among
several application programs that are running at
the same time. This frees program developers
from having to write their own code for these
most basic operations.
 Microsoft Windows XP and Linux are
operating systems which available on the
computers in our lab
Key Definitions (continued)
 ROM and RAM
 Acronyms for Read Only Memory and Random Access Memory.
 ROM is memory chips or data stored on disks that can be read
by the computer’s processor. The PC cannot write new data to
those chips or disk drives.
 RAM is memory or disks that can be both read and written to.
 NOTE: RAM is really a misnomer because even ROM can be
accessed randomly. The term originally was used to distinguish
RAM from data and software that was stored on magnetic tape,
and which could be accessed only sequentially. That is, to get
the last chunk of data or code on a tape, a computer must read
through all the information contained in the tape until it finds the
location where it stored the data code or code for which it is
looking. In contrast, a computer can jump directly to any
information stored in random locations in RAM chips or on a
disk.
Key Definitions (continued)
 System Files
 Small files that contain software code that are the first files a
computer reads from a disk when it is booted.
 On DOS (disk operating system) and Windows systems, the files
are named IO.SYS and MSDOS.SYS and are hidden so that
ordinarily you cannot see them in a listing of files on a disk. The
systems files contain the information needed, following the initial
hardware boot, to load the rest of an operating system. In DOS, one
other system file is COMMAND.COM, which contains the operating
system’s basic functions, such as displaying a list of files (a
directory).
 A boot disk must contain all three files for a PC to start up.
 System files can also include CONFIG.SYS, which makes some
initial setting of hardware, and AUOTEXEC.BAT, a collection of
commands that are executed when all other boot functions are
finished. Windows 95 and up have the Registry – consisting of two
hidden files USER.DAT and SYSTEM DAT – is also necessary for
Windows to run and can be considered a system file.
Key Definitions (continued)
WRITE and READ
Writing is the process by which a computer
stores data in either RAM chips or on a disk
drive.
Reading is the process by which a computer
transfers data or software code from a drive to
RAM or from RAM to the microprocessor.
SCSI HardDisk