0% found this document useful (0 votes)
20 views

Comp 321 Lecture Slide Chapter 4 (Basic Computer Organization and Design)

The document discusses the basic computer organization and design. It covers instruction set architecture, the organization of a computer defined by its internal registers, timing and control structure, and instruction set. The document also discusses instruction codes, instruction formats, instruction processing via fetch-decode-execute cycle, interrupts, input/output configuration, and assemblers.

Uploaded by

dokumbaro30
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Comp 321 Lecture Slide Chapter 4 (Basic Computer Organization and Design)

The document discusses the basic computer organization and design. It covers instruction set architecture, the organization of a computer defined by its internal registers, timing and control structure, and instruction set. The document also discusses instruction codes, instruction formats, instruction processing via fetch-decode-execute cycle, interrupts, input/output configuration, and assemblers.

Uploaded by

dokumbaro30
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 28

Chapter 4

Basic Computer Organization and Design

1
Instruction set architecture

Computer’s instruction set architecture (ISA) specifies the


format of its instructions and the primitive operations that the
machine can perform.
•The ISA is an interface between a computer’s hardware and
its software.
•Some ISAs include hundreds of different instructions for
processing data and controlling program execution.

2
Cont….

• The organization of a computer is defined by its internal


register, the timing, and control structure, and the set of
instructions.
 The user of a computer can control the process by means of a
program.
What is program ?
 A program is a set of instructions that specify the
operations, operands, and the sequence by which
processing has to occur.
 A Computer instruction is a binary code that specifies a
sequence of micro-operations for the computer.

3
Instruction Codes
 Instruction codes together with data are stored in
memory(=Stored Program Concept)
 The computer reads each instruction from memory and places it

in a control register. The control then interprets the binary code


of the instruction and proceeds to execute it by issuing a
sequence of microoperations. Instruction
 Instruction Code :
Cycle

• A group of bits that instruct the computer to perform a


specific operation.
• It is usually divided into two parts.
Instruction Format
15 12 11 0
Op. Code Address

4
Cont….

• Opcode-specifies the instruction to be executed (which allows


for a total of 16 instructions).
• The most basic part of an instruction code
• A group of bits that define such operations as add,
subtract, multiply, shift, and complement(bit 12-15 : 24
= 16 distinct operations)
• The least significant 12 bits, bits 0–11, form an address, which
allows for a maximum memory size of 212–1.
• It specifies the address of an operand

5
Cont….

• The fundamental MARIE instructions are:

6
Cont….

• This is a bit pattern for a LOAD instruction as it would


appear in the IR:

• We see that the opcode is 1 and the address from which to


load the data is 3.

7
Computer Instructions
The basic computer has three instruction code formats. The Operation code (opcode) part of the
instruction contains 3 bits and remaining 13 bits depends upon the operation code encountered.
There are three types of formats:
1. Memory Reference Instruction
It uses 12 bits to specify the address and 1 bit to specify the addressing mode (I). I is equal to 0 for
direct address and 1 for indirect address.
e.g. ADD,LDA,STA…
2. Register Reference Instruction
These instructions are recognized by the opcode 111 with a 0 in the left most bit of instruction. The
other 12 bits specify the operation to be executed.
e.g. CLA(7800) , INC (7020) ,HLT (7001)…..
3. Input-Output Instruction
These instructions are recognized by the operation code 111 with a 1 in the left most bit of
instruction. The remaining 12 bits are used to specify the input-output operation.
8
e.g. INP (F800), OUT (F400)…….
Cont….

Fig. Basic computer instruction formats.


9
Timing and control
• A master clock generator controls the timing for all registers in
the basic computer
• The clock pulses are applied to all flip-flops and registers in
system.
• The clock pulses do not change the state of a register unless the
register is enabled by a control signal
• The control signals are generated in the control unit.
• The function of control unit is to generate relevant timing and
control signals to all operations in the computer.
• The control unit co-ordinates activities of the other two
units(ALU and main memory) as well as all peripherals and
auxiliary storage devices linked to the computer.
10
Instruction Processing
• The fetch-decode-execute cycle is the series of steps that a
computer carries out when it runs a program.
• We first have to fetch an instruction from memory, and
place it into the IR.
• Once in the IR, it is decoded to determine what needs to be
done next.
• If a memory value (operand) is involved in the operation, it
is retrieved and placed into the MBR.
• With everything in place, the instruction is executed.

The next slide shows a flowchart of this process.


Cont….

12
A Simple Program

• Consider the simple MARIE program given below. We


show a set of mnemonic instructions stored at addresses
100 - 106 (hex):

13
Cont….

• Let’s look at what happens inside the computer when our


program runs.
• This is the LOAD 104 instruction:

14
Cont….

• Our second instruction is ADD 105:

15
Cont….

16
Interrupt

•All computers provide a way of interrupting the fetch-decode-


execute cycle.
•Interrupt is a signal to the processor generated by the
software/hardware indicating an immediate attention needed by
an event.
•Typically, the input or output device sends an interrupt by using
a special register, the status or flag register.
•A special bit is set to indicate an interrupt has occurred. For
example, as soon as input is entered from the keyboard, this bit is
set. The CPU checks this bit at the beginning of every machine
cycle.
17
Cont….

When it is set, the CPU processes an interrupt. When it is not set,


the CPU performs a normal fetch-decode-execute cycle, processing
instructions in the program it is currently executing.
•Interrupts can be : hardware interrupts and software interrupts.
Hardware interrupts: are used by devices to communicate that they
require attention from the operating system.
software interrupt is caused either by an exceptional condition in
the processor itself, or a special instruction in the instruction set
which causes an interrupt when it is executed.
occurs when an application software terminates or when it requests the
operating system for some service.
e.g. divide-by-zero exception
18
Software interrupts are also called traps.
Cont….

• Interrupt processing involves adding another step to the


fetch-decode-execute cycle as shown below.

19
Cont….

• For general-purpose systems, it is common to disable all


interrupts during the time in which an interrupt is being
processed.
– Typically, this is achieved by setting a bit in the flags
register.
• Interrupts that are ignored in this case are called
maskable.
• Nonmaskable interrupts are those interrupts that must be
processed in order to keep the system in a stable
condition.(e.g. types of internal system chipset errors,
memory corruption problems, parity errors)
20
Cont….

• Interrupts are very useful in processing I/O.


• MARIE, being the simplest of simple systems, uses a modified form of
programmed I/O.
• All output is placed in an output register, OutREG, and the CPU polls the input
register, InREG, until input is sensed, at which time the value is copied into the
accumulator.

21
Fig: Input/output configuration.
A Discussion on Assemblers

• Mnemonic instructions, such as LOAD 104, are easy for


humans to write and understand.
• They are impossible for computers to understand.
• Assemblers translate instructions that are comprehensible to
humans into the machine language that is comprehensible to
computers
– We note the distinction between an assembler and a
compiler: In assembly language, there is a one-to-one
correspondence between a mnemonic instruction and its
machine code. With compilers, this is not usually the case.

22
Cont….

•An assembler is a program that accepts a symbolic language


program and produces its binary machine language equivalent.
The input symbolic program is called the source program and
the resulting binary program is called the object program .
•Assemblers create an object program file (the machine code)
from mnemonic source code(assembly program) in two passes.
•The translation of the symbolic program into an equivalent binary
code may be done by scanning the program and replacing the
symbols by their machine code binary equivalent.

23
Cont….

• No translation is done during the first scan. we will assign a


memory location to each machine instruction and operand.
The location assignment will define the address value of
labels and facilitate the translation process during the second
scan.
• During the first pass, the assembler assembles as much of
the program is it can, while it builds a symbol table that
contains memory references for all symbols in the program.
• During the second pass, the instructions are completed using
the values from the symbol table.

24
Cont….

• Consider our example program


(top).
– Note that we have included two
directives HEX and DEC that
specify the radix of the constants.
• During the first pass, we have a
symbol table and the partial
instructions shown at the
bottom.

25
Cont….

• After the second pass, the


assembly is complete.

26
Why Learn Assembly Language?

 Assembly language puts the programmer closer to the


architecture.(Better Understanding of Architecture Issues)
• As a programmer, the closest you can come to the processor of a
machine is by using assembly language. Here, you can write code
to access the registers and even deal with memory addresses
directly for retrieving values and pointers.
 Allows direct access to hardware.
Some application of assembly languages are:
 Real time system. E.g Traffic control system
 embedded systems - systems in which the computer is integrated
into a device that is typically not a computer.
• These systems are designed to perform either a single instruction
or a very specific set of instructions. (cameras, medical 27
instruments (such as heart monitors))
• Popular assemblers have emerged over the years for the
Intel family of processors. These include:
 TASM (Turbo Assembler from Borland)
 NASM (Netwide Assembler for both Windows and
Linux), and
 MASM (Macro Assembler from Microsoft)

28

You might also like