CA_Unit_1
CA_Unit_1
CA_Unit_1
UNIT-I
Syllabus:
Basic Structure of Computers,
Functional units,
Performance issues software,
Machine instructions and programs,
Types of instructions,
Instruction sets: Instruction formats,
Assembly language,
Stacks,
Ques,
Subroutines.
Introduction:
What are Digital Computers?
The digital computer is a digital system that performs various computational tasks. Digital computers
use the binary number system, which has two digits: 0 and 1. A binary digit is called a bit. Information
is represented in digital computers in groups of bits. By using various coding techniques, groups of bits
can be made to represent not only binary numbers but also other discrete symbols, such as decimal
digits or letters of the alphabet.
Computer architecture
Computer architecture refers to those attributes of a system visible to a programmer or, put another
way, those attributes that have a direct impact on the logical execution of a program [1].
Computer Organization
Computer organization refers to the operational units and their interconnections that realize the
architectural specifications. Examples of architectural attributes include the instruction set, the number
of bits used to represent various data types (e.g., numbers, characters), I/O mechanisms, and interfaces
between the computer and peripherals; and the memory technology used [1].
The internal structure of the computer itself, which is shown in Figure 2.There are four main structural
components:
Central processing unit (CPU): Controls the operation of the computer and performs its data
processing functions; often simply referred to as processor.
Main memory: Stores data.
I/O: Moves data between the computer and its external environment.
System interconnection: Some mechanism that provides for communication among CPU,
main memory, and I/O. A common example of system interconnection is by means of a system
bus, consisting of a number of conducting wires to which all the other components attach.
It is also essential that a computer store data. Even if the computer is processing data, the
computer must temporarily store at least those pieces of data that are being worked on at any
given moment. Files of data are stored on the computer for subsequent retrieval and update.
The computer must be able to move data between itself and the outside world. When data are
received from or delivered to a device that is directly connected to the computer, the process is
known as input–output (I/O), and the device is referred to as a peripheral.
When data are moved over longer distances, to or from a remote device, the process is known
as data communications.
Finally, there must be control of these three functions. Ultimately, this control is exercised by
the individual(s) who provides the computer with instructions.
1. ALU: The Arithmetic-Logic unit that performs the computer's computational and logical functions.
Unit-1: Page | 4 Dr S K Singh
2. RAM: Memory; more specifically, the computer's main, or fast, memory, also known as Random
Access Memory(RAM).
3. Control Unit: This is a component that directs other components of the computer to perform certain
actions, such as directing the fetching of data or instructions from memory to be processed by the
ALU; and
4. Man-machine interfaces; i.e. input and output devices, such as keyboard for input and display
monitor for output.
An example of computer architecture base on the von Neumann architecture is the desktop personal
computer.
2. Harvard architecture
The Harvard architecture uses physically separate storage and signal pathways for their instructions
and data[4].
Types of instructions
Zero-address instruction
One-address instruction
Two-address instruction
Three-address instruction
Zero-address instruction
For example, PUSH: store operands in a structure called a pushdown stack
One-address instruction
Instruction form: Operation Destination
For example, Add A: add the contents of memory location A to the contents of the accumulator
register and place the sum back into the accumulator
As another example, Load A: copies the contents of memory location A into the accumulator
One-address instructions:
Two-address instructions:
Three-address instructions:
Immediate Mode
In this mode, the operand is specified in the instruction itself. An immediate mode instruction has an
operand field rather than the address field.
For example: ADD 7, which says Add 7 to contents of accumulator. 7 is the operand here.
Register Mode
In this mode the operand is stored in the register and this register is present in CPU. The instruction has
the address of the Register where the operand is stored.
Disadvantages
For Example: ADD R1, 4000 - In this the 4000 is effective address of operand.
NOTE: Effective Address is the location where operand is present.
The operand is A cells away from the current cell(the one pointed to by PC)
(b) Base Register Addressing Mode
It is again a version of Displacement addressing mode. This can be defined as EA = A + (R),
where A is displacement and R holds pointer to base address.
Instruction Format
Instruction format defines the layout of the bits of an instruction, in terms of its component
fields [1].
An instruction format must include an opcode and implicitly or explicitly, zero or more
operands.
Each explicit operand is referenced using one of the addressing modes.
Instruction format is affected by, memory size, memory organization, bus structure, processor
complexity, and processor speed.
For example: The PDP-10 has a 36-bit word length and a 36-bit instruction length. The fixed
instruction format is shown in figure below.
The opcode occupies 9 bits, allowing up to 512 operations (i.e. 2 9). In fact, a total of 365
different instructions are defined.
Register occupies 4 bits, one of which is one of 16 general-purpose registers.
Index register occupies 4 bits, one of which is one of 16 addressing modes
The other operand reference starts with an 18-bit memory address field. This can be used as an
immediate operand or a memory address (218). In the latter usage, both indexing and indirect
addressing are allowed.
The same general-purpose registers are also used as index registers.
Example: Design a variable-length opcode to allow all of the following to be encoded in a 36-bit
instruction:
a) Instructions with two 15-bit addresses and one 3-bit register number
b) Instructions with one 15-bit address and one 3-bit register number
For example, consider the execution of a program which results in the execution of 2 million
instructions on a 400-MHz processor. The program consists of four major types of instructions. The
instruction mix and the CPI for each instruction type are given below based on the result of a program
trace experiment:
The average CPI when the program is executed on a uniprocessor with the above trace results is
Assembly Language
A complete set of symbolic names and rules for their use constitute a programming language,
generally referred to as an assembly language.
Programs written in an assembly language can be automatically translated into a sequence of
machine instructions by a program called an assembler.
When the assembler program is executed, it reads the user program, analyzes it, and then
generates the desired machine language program.
The user program in its original alphanumeric text format is called a source program, and the
assembled machine language program is called an object program.
Answer:
Expression Evaluation[1]
Mathematical formulas are usually expressed in infix notation. In this form, a binary operator appears
between the operands (e.g., A + B ). Generally, multiplication takes precedence over addition, so that a
+ b x c is equivalent a + (b x c).
An alternative technique is known as reverse Polish, or postfix, notation. In this notation, the operator
follows its two operands. For example,
Note that, no parentheses are required when using reverse Polish. The advantage of postfix notation is
that an expression in this form is easily evaluated using a stack.
An expression in postfix notation is scanned from left to right. For each element of the expression, the
following rules are applied:
1. If the element is a variable or constant, push it onto the stack.
2. If the element is an operator, pop the top two items of the stack, perform the operation, and push the
result.
After the entire expression has been scanned, the result is on the top of the stack.
Example: Use of Stack to Compute f = (a - b) / [(d * e) + c]
The location where the calling program resumes execution is the location pointed by the
updated PC while the Call instruction is being executed. Hence the contents of the PC must be
saved by the Call instruction to enable correct return to the calling program
Subroutine Nesting
A common programming practice, called subroutine nesting, is to have one subroutine call
another.
Subroutine nesting call be carried out to any depth. Eventually, the last subroutine called
completes its computations and returns to the subroutine that called it.
The return address needed for this first returns is the last one generated in the nested call
sequence. That is, return addresses are generated and used in a last-in-first-out order.
Many processors do this by using a stack pointer and the stack pointer points to a stack called
the processor stack.
References:
1. Computer Organization and Architecture: Designing for Performance, 8th Edition, Authors: William
Stallings Publisher: Prentice-Hall India.
2. https://nptel.ac.in/courses/106/103/106103068/
3. https://en.wikipedia.org/wiki/Von_Neumann_architecture
4. https://en.wikipedia.org/wiki/Harvard_architecture
5. http://www.ee.ncu.edu.tw/~jfli/computer/lecture/ch03.pdf
--------------------------------End of Unit-1-----------------------------------