Computer Organisation
Computer Organisation
Introduction
A great majority of the computers of our daily use are known as general purpose
machines. These are machines that are built with no specific application in mind, but
rather are capable of performing computation needed by a diversity of applications.
These machines are to be distinguished from those built to serve (tailored to) specific
applications. The latter are known as special purpose machines.
Computer systems have conventionally been defined through their interfaces at a
number of layered abstraction levels, each providing functional support to its
predecessor. Included among the levels are the application programs, the high-level
languages, and the set of machine instructions. Based on the interface between different
levels of the system, a number of computer architectures can be defined.
The interface between the application programs and a high-level language is referred to
as language architecture. The instruction set architecture defines the interface between
the basic machine instruction set and the runtime and I/O control.
Note: That study have indicated that RISC architectures would indeed lead to faster
execution of programs.
Technological Development
Advances in technology have fueled the computer industry. The integration of numbers
of transistors (a transistor is a controlled on/off switch) into a single chip has increased
from a few hundred to millions. This impressive increase has been made possible by the
advances in the fabrication technology of transistors.
The scale of integration has grown from small-scale (SSI) to medium-scale (MSI) to
large-scale (LSI) to very large-scale integration (VLSI), and currently to waferscale
integration (WSI).
SSI, small-scale integration; MSI, medium-scale integration; LSI, large-scale integration; VLSI,
very large-scale integration; WSI, wafer-scale integration.
Note that continuous decrease in the minimum devices feature size has led to a
continuous increase in the number of devices per chip, which in turn has led to a
number of developments. Among these is the increase in the number of devices in
RAM memories, which in turn helps designers to trade off memory size for speed.
Performance measures
Consider: a user of a computer measures its performance based on the time taken to
execute a given job (program). On the other hand, a laboratory engineer measures the
performance of his system by the total amount of work done in a given time. While the
user considers the program execution time a measure for performance, the laboratory
engineer considers the throughput a more important measure for performance.
Note: A metric for assessing the performance of a computer helps comparing alternative
designs. Answers questions such as how fast can a program be executed using a given
computer. We need to determine the time taken by a computer to execute a given job.
Define the clock cycle time as the time between two consecutive rising (trailing) edges
of a periodic clock signal. Clock cycles allow counting unit computations, because the
storage of computation results is synchronized with rising (trailing) clock edges. The
time required to execute a job by a computer is often expressed in terms of clock cycles.
2. The address of the location into which the word is to be stored is loaded by the
CPU into a specified register, called the memory address register (MAR).
3. A signal, called write, is issued by the CPU indicating that the word stored in the
MDR is to be stored in the memory location whose address in loaded in the
MAR.
3. After some time, corresponding to the memory delay in reading the specified
word, the required word will be loaded by the memory into the MDR ready for
use by the CPU.
Addressing Modes
Information involved in any operation performed by the CPU needs to be addressed,
such information is called the operand. Any instruction issued by the processor must
carry at least two types of information i.e. operation to be performed, encoded in what
is called the op-code field, and the address information of the operand on which the
operation is to be performed, encoded in what is called the address field.
Instructions can be classified based on the number of operands as: three-address, two-
address, one-and-half-address, one-address, and zero-address.
A three-address instruction takes the form operation add-1, add-2, add-3.
In this form, each of add-1, add-2, and add-3 refers to a register or to a memory location.
Consider, for example, the instruction ADD R1,R2,R3.
This instruction indicates that the operation to be performed is addition. It also
indicates that the values to be added are those stored in registers R1 and R2 that the
results should be stored in register R3. E.g., ADD A,B,C.
The instruction adds the contents of memory location A to the contents of memory
location B and stores the result in memory location C.
Zero-address instructions: these are the instructions that use stack operation. A stack is
a data organization mechanism in which the last data item stored is the first data item
retrieved using push and the pop operations. A specific register, called the stack
pointer (SP), is used to indicate the stack location that can be addressed.
Def: The different ways in which operands can be addressed are called the addressing
modes.
The simplest addressing mode is to include the operand itself in the instruction, that
is, no address information is needed. This is called immediate addressing. A more
involved addressing mode is to compute the address of the operand by adding a
constant value to the content of a register. This is called indexed addressing. Absolute
addressing, Direct addressing, and Indirect addressing
Direct (Absolute) Mode: According to this addressing mode, the address of the
memory location that holds the operand is included in the instruction.
Consider, for example, the case of loading the value of the operand stored in memory
location 1000 into register Ri. This operation can be performed using an instruction such
as LOAD 1000, Ri. In this instruction, the source operand is the value stored in the
memory location whose address is 1000, and the destination is the register Ri. Note that
the value 1000 is not prefixed with any special characters, indicating that it is the (direct
or absolute) address of the source operand.
Indexed Mode: the address of the operand is obtained by adding a constant to the
content of a register, called the index register. Consider, for example, the instruction
LOAD X(Rind), Ri. This instruction loads register Ri with the contents of the memory
location whose address is the sum of the contents of register Rind and the value X.
Other modes: relative mode, autoincrement mode, autodecrement mode,
Instruction Types
Data movement instructions: are used to move data among the different units of the
machine.
Arithmetic and logical instructions: are those used to perform arithmetic and logical
manipulation of registers and memory contents. Examples of arithmetic instructions
include the ADD and SUBTRACT instructions
The CALL instructions are used to cause execution of the program to transfer to a
subroutine. A CALL instruction has the same effect as that of the JUMP in terms of
loading the PC with a new value from which the next instruction is to be executed.
However, with the CALL instruction the incremented value of the PC (to point to the
next instruction in sequence) is pushed onto the stack. Execution of a RETURN
instruction in the subroutine will load the PC with the popped value from the stack.
This has the effect of resuming program execution from the point where branching to
the subroutine has occurred.
Input/Output Instructions (I/O instructions): are used to transfer data between the
computer and peripheral devices. The two basic I/O instructions used are the INPUT
and OUTPUT instructions. The INPUT instruction is used to transfer data from an input
device to the processor. Examples of input devices include a keyboard or a mouse.
Input devices are interfaced with a computer through dedicated input ports. E.g.
Suppose that the input port through which a keyboard is connected to a computer
carries the unique address 1000. Therefore, execution of the instruction INPUT 1000 will
cause the data stored in a specific register in the interface between the keyboard and the
computer, call it the input data register, to be moved into a specific register. Similarly,
the execution of the instruction OUTPUT 2000 causes the data stored in the accumulator
to be moved to the data output register in the output device whose address is 2000.
Programming Examples
Example 1 In this example, we would like to show a program segment that can be used
to perform the task of adding 100 numbers stored at consecutive memory locations
starting at location 1000. The results should be stored in memory location 2000.
In this example, use has been made of immediate (MOVE #100, R1) and indexed (ADD
1000(R2), R0) addressing.
Although high-level languages and compiler technology have witnessed great advances
over the years, assembly language remains necessary in some cases. Programming in
assembly can result in machine code that is much smaller and much faster than that
generated by a compiler of a high-level language.
Small and fast code could be critical in some embedded and portable applications,
where resources may be very limited.
A computer program can be represented at different levels of abstraction. A program
could be written in a machine-independent, high-level language such as Java or C++.
A computer can execute programs only when they are represented in machine
language specific to its architecture. A machine language program for a given
architecture is a collection of machine instructions represented in binary form.
Programs written at any level higher than the machine language must be translated to
the binary representation before a computer can execute them. An assembly language
program is a symbolic representation of the machine language program.
Machine language is pure binary code, whereas assembly language is a direct mapping
of the binary code onto a symbolic form that is easier for humans to understand and
manage. Converting the symbolic representation into machine language is performed
by a special program called the assembler. An assembler is a program that accepts a
symbolic language program (source) and produces its machine language equivalent
(target). In translating a program into binary code, the assembler will replace symbolic
addresses by numeric addresses, replace symbolic operation codes by machine
operation codes, reserve storage for instructions and data, and translate constants into
machine representation.
A SIMPLE MACHINE: Consider accumulator-based processor, which has five 16-bit
registers
Program Counter (PC), Instruction Register (IR), Address Register (AR), Accumulator
(AC), and Data Register (DR). The PC contains the address of the next instruction to be
executed. The IR contains the operation code portion of the instruction being executed.
The AR contains the address portion (if any) of the instruction being executed. The AC
serves as the implicit source and destination of data. The DR is used to hold data.
INSTRUCTION MNEMONICS AND SYNTAX
Assembly language is the symbolic form of machine language. Assembly programs are
written with short abbreviations called mnemonics. A mnemonic is an abbreviation that
represents the actual machine instruction. Use of mnemonics is more meaningful than
that of hex or binary values, which would make programming at this low level easier
and more manageable.
The operation code (opcode) field contains the symbolic abbreviation of a given
operation. The operand field consists of additional information or data that the opcode
requires. The operand field may be used to specify constant, label, immediate data,
register, or an address.
Consider: START LD X \Copy the contents of location X into AC
Example:
Example 2:
In this example, we will write an assembly program to perform the multiplication
operation: Z X_Y, where X, Y, and Z are memory locations.
The assembly of the simple CPU does not have a multiplication operation. We will
compute the product by applying the add operation multiple times. In order to add Y to
itself X times, we will use N as a counter that is initialized to X and decremented by one
after each addition step. The BZ instruction will be used to test for the case when N
reaches 0. We will use a memory location to store N but it will need to be loaded into
AC before the BZ instruction is executed. We will also use a memory location ONE to
store the constant 1. Memory location Z will have the partial products and eventually
the final result.
ASSEMBLY AND EXECUTION OF PROGRAMS
A program written in assembly language needs to be translated into binary machine
language before it can be executed. The assembler reads the source program in
assembly language and generates the object program in binary form. The object
program is passed to the linker. The linker will check the object file for calls to
procedures in the link library. The linker will combine the required procedures from the
link library with the object program and produce the executable program. The loader
loads the executable program into memory and branches the CPU to the starting
address. The program begins execution.
Assemblers: Assemblers are programs that generate machine code instructions from a
source code program written in assembly language. The assembler will replace
symbolic addresses by numeric addresses, replace symbolic operation codes by
machine operation codes, reserve storage for instructions and data, and translate
constants into machine representation.
Linker and Loader: The linker is the entity that can combine object modules that may
have resulted from assembling multiple assembly modules separately. The loader is the
operating system utility that reads the executable into memory and start execution.
After assembly modules are translated into object modules, the functions of the linker
and loader prepare the program for execution.