Module 2 Coa
Module 2 Coa
COMPUTER ORGANIZATION&ARCHITECHTURE
Module -2
⚫ Register set
⚫ Control unit
➢Register set – The register set stores intermediate data used during used during the
execution of the instructions
➢ALU – performs the required micro operations for executing the instructions.
➢Control unit – Supervises the transfer of information among the registers and instructs the
ALU as to which operation to perform.
Page 1
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
The control unit that operates the CPU bus system directs the information flow
through the registers and ALU by selecting the various components in the system.
example: R1R2+R3
4. Decoder destination selector(SELD): to transfer the content of the output bus into R1.
This four control selection variables are generated in the control unit and must be available at
the beginning of a clock cycle.
Control word
There are 14 binary selection inputs in the unit, and their combined value specifies a control
word.
Three fields contains 3-bits each and one field have five bits.
3 3 3 5
Control word
Page 2
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
Stack Organization
A useful feature that is included in the CPU of the most computers is stack or last in
first out (LIFO) list. A stack is a storage device that stores information in such a manner that
the item stored. Last is the first item retrieved.
The register that holds the address for the Stack is called Stack pointer (SP), because its value
always points at the top item in the stack.
The two operations of the stack are the insertion and the deletion of items. The
operation of insertion is called push. The operation of deletion is called pop.
Page 3
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
Register Stack
A stack can be placed in the portion of a large memory or it can be organized as the
collection of a finite no. of words or registers. The stack pointer register SP contains a binary
number whose value is equal to the address of the word that is currently on top of stack.
In a 64-bit word stack, the stack pointer contains six bits because 26 = 64 since SP has
only six bits, it cannot exceed a number greater than 63.
Page 4
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
Memory Stack
The implementation of stack in the CPU is done by assigning a portion of memory to a stack
operation and using a processor register as a stack pointer.
⚫Program
⚫Data
⚫Stack
The program counter pc points at the address of the next instruction in the program. The
address register AR points at an array of data. The stack pointer points at the top of the stack.
The three registers are connected to common address bus, and either one can provide an
address for the memory. PC is used during the fetch phase to read an instruction .AR is used
during the execute phase to read an operand. SP is used to push or pop items into or from the
stack.
Eg : A*B+C*D
Page 5
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
Addressing modes
The operation field of an instruction specifies the operation to be performed. The
operation must be executed on some data stored in computer registers or memory words. The
way the operands are chosen during program execution is dependent on the addressing
modeof the instruction. The addressing mode specifies a rule for interpreting or modifying
the address field of the instruction before the operand is actually referenced.
Computer use addressing mode techniques for the purpose of accommodating one or both of
the following.
The operation code specifies the operation to be performed. The mode field is used to
locate the operands needed for the operation. If there is an address field in the instruction, it
may designate a memory address or processor register.
➢Although most addressing modes modify the address field of the instruction, there are two
modes that needs no address field at all.
Implied Mode
In this mode the operands are specified implicity in the definition of the instruction.
Eg : complement accumulator is an implied mode instruction. Because the operand in the
accumulator register is implied in the definition of instruction.
Immediate mode
In this mode the operand is specified in the instruction itself. An immediate mode
instruction has an operand field rather than address field. The operand field contains the
actual operand to be used in the conjunction with the operation specified in the instruction.
Page 6
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
Register mode
In this mode the operands are in registers that reside within the CPU. The particular
register is selected from a register field in the instruction. Register contains the address of the
operand rather that operand itself.
Page 7
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
Instruction Classification
1. Data Transfer Instruction
Page 8
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
The load instruction has been used mostly to designate a transfer from memory to
processor register, usually an accumulator. The store instruction designate a transfer from
processor register to memory. The move instruction has been used in computers with multiple
CPU registers to designate a transfer between one register to another. The exchange
instruction swaps information between two registers or a register and a memory word. The
input and output instructions transfer data among processor registers and Input or Output
terminals. The push and pop instructions transfer data between processor register and a
memory stack.
⚫ Arithmetic Instructions
⚫ Shift Instruction
Arithmetic Instructions
The four basic arithmetic operations are addition, subtraction, multiplication and
division. Most computers provide instructions for all four operations. The instruction adds 1
to the value stored in a register or a memory word. The decrement instruction subtracts
1from the value stored in a register or a memory word.
• Increment INC
• Decrement DEC
• Add ADD
• Subtract SUB
• Multiply MUL
• Divide DIV
• Add with Carry ADDC
• Subtract with borrow SUBB
• Negate(2’s Compliment) NEG
Page 9
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
• Clear CLR
• Compliment COM
• AND AND
• OR OR
• Exclusive-or XOR
• Clear Carry CLRC
• Set Carry SETC
• Complement Carry COMC
• Enable Interrupt EI
• Disable Interrupt DI
Shift Instructions
Instructions to shift the content of an operand are quite useful and are often provided
in several variations. Shifts are operations in which the bits of a word are moved to left or
right. The bit shifted in at the end of the word determines the type of shift used. Shift
instructions may specify either logical shifts, arithmetic shifts or rotate type operations. In
either case the shift may be right or to left.
Page 10
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
Program Control
Instructions are always stored in successive memory locations. When processed in the CPU,
the instructions are fetched from consecutive memory locations and executed. Each time an
instruction is fetched from memory the program counter is incremented so that it contains
the address of the next instruction in sequence. The branch and jump instructions are used
interchangeably to mean the same thing but sometimes they are used to denote different
addressing modes.
• Branch BR
• Jump JMP
• Skip SKP
• Call CALL
• Return RET
• Compare(by subtraction) CMP
• Test (by adding) TST
The skip instruction does not need an address field and is therefore a zero-address
instruction. A conditional skip instruction will skip the next instruction if the condition is
met.
Page 11
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
2. Bit S (sign) is set to 1 if the highest order bit F7 is 1. It is set to 0 if the bit is 0.
3. Bit Z (zero) is set to 1 if the output of ALU contains all 0’s. It is cleared to 0 otherwise.
4. Bit V (overflow) is set to 1 if the exclusive OR of the last two carries is equal to 1.
The instruction that transfers program control to a subroutine is known by different names.
The most common names used are call subroutine, jump to subroutine, branch to subroutine
or branch and save address. The instruction is executed by performing two operations.
1. The address of the next instruction available in the program counter is stored in a
temporary location
Program Interrupt
The concept of program interrupt is used to handle a variety of problems that arise out of
normal program sequence. Program interrupt refers to transfer of program control from a
currently running program to another service program as a result of an external or internal
Page 12
ST.ANTONY’S COLLEGE PERUVANTHANAM DEPT OF COMPUTER SCIENCE COA[SEMII]
generated request, control returns to the original program after the service program is
executed.
1. The interrupt is usually initiated by an internal or external signal rather than from the
execution of an instruction.
2. The address of the interrupt service program is determined by the between rather than
from the address field of an instruction.
The state of the CPU at the end of the execute cycle is determined from
Type of Interrupts
1. External interrupts: Come from Input-output devices from a timing device, from a circuit
monitoring the power supply or from other external source.
2. Internal Interrupts: arise from illegal or erroneous use of an instruction or data. Internal
interrupts are also called traps
Page 13