Sunteți pe pagina 1din 7

Computer organization Basic Machine Cycle

It refers to the operational units and their interconnections that


realize the architectural specifications. Examples of organizational
attributes include those hardware details transparent to the
programmer, such as control signals, interfaces between the
computer and peripherals, and the memory technology used.
Components of a Computer
1. A processor to interpret and execute program
2. A memory to store both data and programs
3. A mechanism for transferring data to and from the outside
world Basic Machine Cycle
HISTORICAL DEVELOPMENTS OF COMPUTER SYSTEM -A machine instruction is a pattern of bits that corresponds to a
1ST Generation: Vacuum Tube Computer fundamental operation of the processor such as adding two 32-bit
Konrad Zuse(1930) integers together or testing if a value is zero. The details of the
ZI,Z2 and Z3- used electromechanical relays machine cycle differ between processor families. The machine
instead and is programmable cycle of most processor chips looks like the following:
Had the following component: -Fetch the Instruction. The instruction is fetched from memory.
Memory The program counter (PC) is part of the processor. It shows where
Arithmetic unit the instruction is located in memory.
Control unit -Increment the Program Counter. The program counter now
John Atanasoff(1904-1995) points to the next instruction.
Atanasoff Berry Computer( ABC) was a binary -Execute the Instruction. The operation asked for by the current
machine built from vacuum tubes machine instruction is performed.
John Mauchly(1907-1980) and J. Presper Eckert(1929- -Emulator - A program that implements a processor's architecture
1995) is the logical equivalent of an implementation in silicon
ENIAC (Electronic Numerical Integrator and Von Neumann Model
Computer) 3 Hardware Systems:
First all-electronic, general-purpose digital 1. Central Processing Unit (CPU)
computer Arithmetic logic unit (ALU)
Used 17,468 vacuum tubes Registers
Occupied 1,800 square feet of floor space Program counter
Has weight of 30 tons each 2. Main- Memory System
Consumes 174 kilowatts of power 3. I/O System
Memory:1000 information bits
Used punched card to store data
2nd Generation: Transistorized Computers (1954-1965)
John Bardeen, Walter Bratain and William Shockley-
invented transistor
Computer Makers:
IBM
Digital Equipment Corporation (DEC)
Univac (UniSys)
3rd Generation: Integrated Circuit Computers(1965-1980)
Jack Kilby- invented the integrated circuit(IC) or
microchip, made of germanium
Robert Noyce invented similar device using silicon Fetch-Decode-Execute Cycle
4th Generation: VLSI Computers (1980-present) 1. The control unit FETCHES the next program
Multiple transistors were integrated into ONE CHIP instruction from the memory , using the
Various level of Integration: program counter to determine where the
1. SSI(small scale integration)-10 to 100 components per instruction is located
chip 2. The instruction is DECODED into a language
2. MSI(medium scale integration)-100 to 1000 components the ALU can understand. Any data operands
per chip required to execute the instruction are
3. LSI(large scale integration) 1000 to 10000 components fetched from memory and placed into the
per chip registers within the CPU
4. VLSI(very large scale integration)- more than 10000 3. The ALU will EXECUTES the instructions and
components per chip places the results in registers or memory.
Basic Computer Organization Modified Von Neumann Model
Four classic component
Input devices keyboard, mouse
Output devices printer , monitor
Storage devices Secondary memory, Primary memory
Processor -
1. Control Unit
2. Arithmetic Logic Unit
Assembly-, Machine-, and High-Level Languages The set of all instructions (in binary form) makes up the
Computer Level Hierarchy computer's machine language. This is also referred to
as the instruction set.
Instruction Fields
Machine language instructions usually are made up of several
fields. Each field specifies different information for the
computer. The major two fields are:
Opcode field which stands for operation code and it specifies
the particular operation that is to be performed.
-Each operation has its unique opcode.
Operands fields which specify where to get the source and
destination operands for the operation specified by the opcode.
-The source/destination of operands can be a constant, the
Application Programs (Level 5) memory or one of the general-purpose registers.
Written in high-level programming languages------Such
as Java, C++, Pascal, Visual Basic ---Programs compile Assembly vs. Machine Code
into assembly language level (Level 4)
Assembly Language (Level 4)
Instruction mnemonics are used--Have one-to-one
correspondence to machine language--Calls functions
written at the operating system level (Level 3)
Programs are translated into machine language (Level 2)
Operating System (Level 3)
Provides services to level 4 and 5 programs
Translated to run at the machine instruction level (Level
2)
Instruction Set Architecture (Level 2)
Specifies how a processor functions
Machine instructions, registers, and memory are
exposed
Machine language is executed by Level 1
(microarchitecture)
Microarchitecture (Level 1)
Controls the execution of machine instructions (Level 2)
Implemented by digital logic (Level 0)
Digital Logic (Level 0)
Implements the microarchitecture
Uses digital logic gates
Logic gates are implemented using transistors

Assembly and Machine Language


Machine language
-Native to a processor: executed directly by hardware
Mapping Between Assembly Language and HLL
-Instructions consist of binary code: 1s and 0s
Translating HLL programs to machine language programs is not a
Assembly language
one-to-one mapping
-A programming language that uses symbolic names to represent
A HLL instruction (usually called a statement) will be translated
operations, registers and memory locations.
to one or more machine language instructions
-Slightly higher-level language
-Readability of instructions is better than machine language
-One-to-one correspondence with machine language instructions
Assemblers translate assembly to machine code
Compilers translate high-level programs to machine code
-Either directly, or
-Indirectly via an assembler
Advantages of High-Level Languages
Compiler and Assembler Program development is faster
High-level statements: fewer instructions to
code
Program maintenance is easier
For the same above reasons
Programs are portable
Contain few machine-dependent details
Instructions and Machine Language Can be used with little or no
Each command of a program is called an instruction (it modifications on different machines
instructs the computer what to do). Compiler translates to the target machine
Computers only deal with binary data, hence the language
instructions must be in binary format (0s and 1s) . However, Assembly language programs are
not portable
Why Learn Assembly Language? Editor
Accessibility to system hardware Allows you to create assembly language source files
Assembly Language is useful for Some editors provide syntax highlighting features and can be
implementing system software customized as a programming environment
Also useful for small embedded system
applications
Space and Time efficiency
Understanding sources of program
inefficiency
Tuning program performance
Writing compact code
Writing assembly programs gives the computer
designer the needed deep understanding of the
instruction set and how to design one
To be able to write compilers for HLLs, we need to be
expert with the machine language. Assembly
programming provides this experience LESSON 2
Binary
Assembly Language Programming Tools -Binary means "two states." The two states are sometimes called
Assembler "1" and "0", or called "true" and "false", or called "on" and "off", (or
Software tools are needed for editing, assembling, other names.) The essential characteristic is that a single binary
linking, and debugging assembly language programs device can be in just one of two possible states.
An assembler is a program that converts source-code Why Computers use Binary?
programs written in assembly language into object files Four (somewhat overlapping) important reasons for using binary:
in machine language -Simple; easy to build.
Popular assemblers have emerged over the years for -Unambiguous signals (hence noise immunity).
the Intel family of processors. These include -Flawless copies can be made.
TASM (Turbo Assembler from Borland) -Anything that can be represented with some sort of pattern can
NASM (Netwide Assembler for both Windows be represented with patterns of bits
and Linux), and Bit Patterns
GNU assembler distributed by the free
software foundation
Linker and Link Libraries
You need a linker program to produce executable files
It combines your program's object file created by the
assembler with other object files and link libraries, and
produces a single executable program
LINK32.EXE is the linker program provided with the
MASM distribution for linking 32-bit programs Introduction
We will also use a link library for input and output A bit is the most basic unit of information in a computer
Called Irvine32.lib developed by Kip Irvine A byte is a group of eight bits, the smallest possible
Works in Win32 console mode under MS- addressable unit of computer storage.
Windows A word is a contiguous group of bytes.
Assemble and Link Process Word sizes of 16, 32, or 64 bits are most
common.
A group of four bits is called a nibble (or nybble).
Nibbles
Ex.
Binary: 0010100010101010
Nibble: 0010 1000 1010 1010

Debugger
Allows you to trace the execution of a program
Allows you to view code, memory, registers, etc.
Example: 32-bit Windows debugger Positional Numbering System
-Any integer quantity can be represented exactly using any base
(radix).
-The binary system is called the base-2 system.
-Our decimal system is the base-10 system. It uses powers of 10
for each position in a number.
-The base is denoted by a subscript.
Example:
Base 10 to base 2 up to base n Conversion Base 10 to base 2 Conversion
2 methods for radix conversion:
the subtraction method
division remainder method
Base 10 to base 2 Conversion

SUBTRACTION METHOD
Base 10 to base 2 Conversion Example 1:
SUBTRACTION METHOD Convert 0.34375 base 10 to base 2 with 4-bits to the
Example 1: right of the radix point using subtraction method
Convert 147-base 10 to base 2 using subtraction NOTE: Reading from TOP to BOTTOM
NOTE: Reading from TOP to BOTTOM

MULTIPLICATION METHOD
Example 2:
Convert 0.34375 base 10 to base 2 with 4-bits to the
right of the radix point using multiplication
NOTE: Reading from TOP to BOTTOM

Base 10 to base 3 Conversion


SUBTRACTION METHOD
Example 2:
Convert 104-base 10 to base 3 using subtraction
NOTE: Reading from TOP to BOTTOM

Base 10 to base 2 Conversion


DIVISION-REMAINDER METHOD
Example 1 cont.
NOTE: Reading from BOTTOM to TOP Base 2 to other radices Conversion
Hexadecimal=16=24 , a group of 4 bits (hextet)
Octal=8=23 , a group of 3 bits (octet)
Example: (binary to hexadecimal)
Convert 110010011101 base-2 to base 16

Base 10 to base 3 Conversion


Example: (binary to octal)
DIVISION-REMAINDER METHOD
Convert 110010011101 base-2 to base-8
Example 2 cont.
NOTE: Reading from BOTTOM to TOP

Base 10 to base 2 up to base n Conversion


Fractions in any base system can be approximated in nay
other base system using negative powers of a radix.
Fractional decimal values have nonzero digits to the
right of the decimal point.
Fractional values of other radix systems have nonzero
digits to the right of the radix point.
2 methods for radix conversion:
subtraction method
multiplication method
Activity For these reasons (among others) computers systems
employ Complement systems for numeric value
representation.
Diminished Radix Complement
-taking the nines complement of the subtrahend
-Complement systems are useful because they eliminate the need
Signed Integer Representation for subtraction
To represent negative values, computer systems allocate Example:
the high-order bit to indicate the sign of a value. 167-52 => take difference of 52 to 999 which is 947 then add
The high-order bit is the leftmost bit in a byte. it to the minuend
It is also called the MSB. Thus,
A 1 in the high-order bit indicates a negative 167+947=114 add the carry from the addition process it
number becomes 115
A 0 in the high-order bit indicates a positive
number Ones Complement
Example: In an 8-bit word, -Switching all of the 1s with 0s and vice versa.
-1 => 10000001 EXAMPLE 1:
+1 => 00000001 Using ones complement binary arithmetic, find the sum of 48 and
19 in an 8 bit storage
Computer System that uses signed-magnitude Note:
representations can represents 48 is 00110000
-2^(N-1) -1 => smallest integer 19 is 00010011
2^(N-1) -1 => largest integer
Example:
A computer system that has 8 bits to store integer has:
a. -2^(8-1)-1 = -127 smallest integer
b. 2^(8-1)-1=127 largest integer Twos Complement
To express a value in twos complement:
ADDITION If the number is positive, just convert it to
binary and youre done.
If the number is negative, find the ones
complement of the number and then add 1.
With twos complement arithmetic, all we do is add our
two binary numbers. Just discard any carries emitting
Signed Integer Representation
from the high order bit.
Example One
Using Twos complement binary arithmetic,
find the sum of 48 and - 19.
48 is 00110000
-19 is -00010011
-19 in ones complement is 11101100
-19 in twos complement is 11101101

Floating-point are expressed in scientific notation.


For example:
0.125 = 1.25 10-1
5,000,000 = 5.0 106
Numbers written in scientific notation have three
components

Computer representation of a floating-point number


consists of three fixed-size fields
Advantage
easy for people to understand.
Disadvantage of signed magnitude
It allows 2 different representations for zero:
positive zero and negative zero. The one-bit sign field is the sign of the stored value
It requires complicated computer hardware The size of the exponent field, determines the range of
values that can be represented
The size of the significand determines the precision of
the representation.

Express 3210 in the simplified 14-bit floating-point


model.
We know that 32 is 25.
So in (binary) scientific notation 32= 0.1 x 26.

BCD
BCD(Binary-Coded Decimal) encodes
each digit of a decimal number to a
4-bit binary form.
When stored in an 8-bit byte, the
upper nibble is called the zone and
the lower part is called the digit.

Represent -1265 in 3 bytes using packed BCD


The zoned-decimal coding for 1265 is:
1111 0001 1111 0010 1111 0110 1111 0101
After packing, this string becomes:
0001 0010 0110 0101 LESSON 3
Adding the sign after the low-order digit and padding A Simple Computer
the high-order digit with ones in 3 bytes we have:
Outline
CPU
EBCDIC Memory
Extended Binary Coded Decimal Interchange I/O
Code (EBCDIC) Bus
Characters are represented by appending digit A primitive instruction set (MARIE)
bits to zone bits. The CPU
The central processing unit (or processor)
Is the brain of the computer
It does all the processing
the CPU into two areas
Datapath registers and ALU (the
execution unit)
Control unit circuits in charge of
performing the fetch-execute cycle
The CPU is in charge of executing the current program
Each program is stored in memory along with data
The CPU is in charge of retrieving the next instruction
from memory (fetch), decoding and executing it
Execution usually requires the use of ALU and temporary
storage in registers
Some instructions cause data movement (memory
accesses, input, output) and some instructions change
what the next instruction is (branches)
The Registers
User registers
These store data and addresses
These are manipulated by your program
instructions
Example: Add R1, R2, R3
R1 R2 + R3
Control registers
ASCII
Registers that store information used by the control
American Standard Code for Information Interchange
unit to perform the fetch-execute cycle
(ASCII)
PC the memory location of the next
ASCII defines codes the following:
instruction
1. 32 control characters
IR the current instruction being executed
2. 10 digits
Status flags information about the results of
3. 52 letters (upper- and lowercase)
the last instruction executed (was there an
4. 32 special characters (such as $ and #)
5. space character.
overflow, was the result positive, zero or The Bus
negative?)
Registers are used in computer systems as places to
store a wide variety of data.
A register is a hardware device that stores binary data.

The ALU
Consists of circuits to perform arithmetic and logic
operations
Adder
Multiplier
Shifter The bus carries three types of information
Comparator The address from the CPU of the intended
Operations in the ALU set status flags (carry, item to be accessed
overflow, positive, zero, negative) The control information (read versus write, or
Also, possibly, temporary registers before moving results status information like are you available?)
back to register or memory The data, either being sent to the device, or
The Control Unit from the device to CPU
In charge of managing the fetch-execute cycle Processor-memory buses -are short, high-speed buses
It sends out control signals to all other devices that are closely matched to the memory system on the
A control signal indicates that the device machine to maximize the bandwidth
should activate or perform its function I/O buses -are typically longer than processor-memory
The Bus buses and allow for many types of devices with varying
A bus is a collection of wires that allow current to flow bandwidths.
over them which is the current is the information being Memory Organization and Addressing
passed between components Memory is organized into byte or word-sized blocks
There are 3 parts to a bus - Each block has a unique address
data bus -for data and program instructions
control bus -control signals from the CU to the
devices, and feedback lines for ack that they
are ready or for interrupting the CPU
address bus -the address of the memory
location or I/O device that is to perform the Byte-addressable
given operation which means that each individual byte has a
Buses connect two types of devices unique address.
Masters If an architecture is byte-addressable, and the
Devices that can initiate requests instruction set architecture word is larger with
CPU a byte
some I/O devices Word-addressable
Slaves which means each word (not necessarily each
Devices that only respond to byte) has its own address
requests from masters Memory is often referred to using the notation LxW
Memory (length x width).
some I/O devices EXAMPLE :
Some buses are dedicated How many bits would you need to address a 2M X 32 memory if
The bus directly connects two devices (point- a. The memory is byte-addressable?
to-point bus) b. The memory is word-addressable?
Most buses connect multiple components ANSWER:
multipoint a. There are 2M x 4 bytes which equals 2 x 2^20 x 2^2 = 2 ^23
total bytes, so 23 bits are needed for an address
b. There are 2M words which equals 2 X 2^20 = 2^21, so 21 bits
are required for an address
How many bits are required to address a 1M x 8 main
memory if
a. Main memory is byte-addressable?
b. Main memory is word-addressable?