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

Comp Arch Lect3

Uploaded by

stsam467
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Comp Arch Lect3

Uploaded by

stsam467
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

CMP 303: Registers

Definition
• Register is a very fast computer memory, used
to store data/instruction in-execution.
• A Register is a group of flip-flops with each flip-
flop capable of storing one bit of information.
• An n-bit register has a group of n flip-flops and
can store binary information of n-bits.
• Register consists of a group of flip-flops and
gates.
• The flip-flops hold the binary information and
gates control when and how new information is
Types of Registers
• Accumulator: This is the most common register, used to store
data taken out from the memory.
• General Purpose Registers: This is used to store data
intermediate results during program execution. It can be accessed
via assembly programming.
• Special Purpose Registers: Users do not access these registers.
These registers are for Computer system,
• Memory Address Register (MAR): Memory Address Register
are those registers that holds the address for memory unit.
• Memory Buffer Register (MBR): Memory Buffer Register stores
instruction and data received from the memory and sent from the
memory.
• Program Counter (PC): Program Counter points to the next
instruction to be executed.
• Instruction Register (IR): Instruction Register holds the
Register Transfer
• The term register transfer means the
availability of hardware logic circuits that can
perform a stated micro-operation and transfer
the result of the operation to the same or
another register.
• The transfer of new information into a register
is referred to as loading the register.
• If all the bits of register are loaded
simultaneously with a common clock pulse
than the loading is said to be done in parallel.
Register
• The symbol Transfer
or notation used toLanguage
describe the micro-
operation transfers amongst registers is called Register
transfer language.
• Information transferred from one register to another is
designated in symbolic form by means of replacement
operator. R2 ← R1
• This denotes the transfer of the data from register R1
into R2.
• Normally we want the transfer to occur only in
predetermined control condition.
• A control function is a Boolean variable that is equal to
1 or 0. The control function is shown as: P: R2 ← R1
• The control condition is terminated with a colon. It
shows that transfer operation can be executed only if
Register Micro Operations
• The operations executed on data
stored in registers are called micro-
operations.
• A micro-operation is an elementary
operation performed on the
information stored in one or more
registers.
• Example: Shift, count, clear and load.
Types of Micro Operations
• Register transfer micro-operations
transfer binary information from one register
to another.
• Arithmetic micro-operations perform
arithmetic operations on numeric data stored
in registers.
• Logic micro-operations perform bit
manipulation operation on non-numeric data
stored in registers.
• Shift micro-operations perform shift micro-
operations performed on data.
Arithmetic Micro Operations
• Some of the basic micro-operations are addition, subtraction,
increment and decrement.
• Add Micro-Operation: It is defined by the following
statement: R3 → R1 + R2
• The above statement instructs the data or contents of register
R1 to be added to data or content of register R2 and the sum
should be transferred to register R3.
• Subtract Micro-Operation: Let us again take an example:
R3 → R1 + R2' + 1
• In subtract micro-operation, instead of using minus operator we
take 1's compliment and add 1 to the register which gets
subtracted, i.e R1 - R2 is equivalent to R3 → R1 + R2' + 1
• Increment/Decrement Micro-Operation: Increment and
decrement micro-operations are generally performed by adding
and subtracting 1 to and from the register respectively. R1 →
Arithmetic Micro Operations
Symbolic Designation Description
R3 ← R1 + R2 Contents of R1+R2
transferred to R3.
R3 ← R1 - R2 Contents of R1-R2
transferred to R3.
R2 ← (R2)’ Compliment the contents of
R2.
R2 ← (R2)' + 1 2's compliment the contents
of R2.
R3 ← R1 + (R2)' + 1 R1 + the 2's compliment of
R2 (subtraction).
R1 ← R1 + 1 Increment the contents
of R1 by 1.
R1 ← R1 - 1 Decrement the contents of
Logic Micro Operations
• These are binary micro-operations performed
on the bits stored in the registers.
• These operations consider each bit separately
and treat them as binary variables.
• Let us consider the X-OR micro-operation with
the contents of two registers R1 and R2.
P: R1 ← R1 X-OR R2
• In the above statement we have also included
a Control Function. Assume that each register
has 3 bits.
Shift Micro Operations
• These are used for serial transfer of data. That means we can shift the
contents of the register to the left or right.
• In the shift left operation the serial input transfers a bit to the right most
position and in shift right operation the serial input transfers a bit to the left
most position. There are three types of shifts as follows:
• Logical Shift: It transfers 0 through the serial input. The symbol "shl" is
used for logical shift left and "shr" is used for logical shift right.
R1 ← shl R1
R1 ← shr R1
• Circular Shift: This circulates or rotates the bits of register around the two
ends without any loss of data or contents. In this, the serial output of the
shift register is connected to its serial input. "cil" and "cir" is used for
circular shift left and right respectively.
• Arithmetic Shift: This shifts a signed binary number to left or right. An
arithmetic shift left multiplies a signed binary number by 2 and shift right
divides the number by 2. Arithmetic shift micro-operation leaves the sign bit
unchanged because the signed number remains same when it is multiplied
or divided by 2.
Computer Instructions
• The basic computer instruction code has 16 bits. 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 Instruction code:
• 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.
• 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.
• 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
Instruction Format
• The layout of bits of an instruction is called instruction format.
The format of an instruction is depicted in a rectangular box
symbolizing the bits of an instruction. An instruction format
contains 3 basic fields:
• An operation code field that specifies the operation to be
performed.
• An address field that designates the memory address or
register. This field indicates where register or memory address
is located. These are referred to as the operands or data that
will be operated on or manipulated.
• A mode field that specifies the way the operand of effective
address is determined.
• Computers may have instructions of different lengths
containing varying number of addresses. The number of
address field in the instruction format depends upon the
internal organization of its registers.
Addressing Modes
• The operation field of an instruction specifies the
operation to be performed.
• This operation will be executed on some data
which is stored in computer registers or the main
memory.
• The way any operand is selected during the
program execution is dependent on the addressing
mode of the instruction.
• The purpose of using addressing modes is as
follows:
• To give the programming versatility to the user.
• To reduce the number of bits in addressing field of
Types of Addressing Modes
• 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.
Register Mode
• Advantages
• Shorter instructions and faster instruction fetch.
• Faster memory access to the operand(s)
• Disadvantages
• Very limited address space.
• Using multiple registers helps performance but it complicates
the instructions.
• Register Indirect Mode: In this mode, the instruction
specifies the register whose contents give us the address of
operand which is in memory. Thus, the register contains the
address of operand rather than the operand itself.
• Auto Increment/Decrement Mode: In this the register is
incremented or decremented after or before its value is used.
Types of Addressing Modes

• Direct Addressing Mode: In this mode, effective address of


operand is present in instruction itself.
• Single memory reference to access data. No additional
calculations to find the effective address of the operand.
• For Example: ADD R1, 4000 - In this the 4000 is effective
address of operand. NOTE: Effective Address is the location
where operand is present.
Types of Addressing Modes
• Indirect Addressing Mode: In this, the address field of
instruction gives the address where the effective address is
stored in memory. This slows down the execution, as this
includes multiple memory lookups to find the operand.
Types of Addressing Modes

• Displacement Addressing Mode: In this the contents of the


indexed register is added to the Address part of the instruction,
to obtain the effective address of operand. EA = A + (R), In this
the address field holds two values, A (which is the base value)
and R(that holds the displacement), or vice versa.
Types of Addressing Modes
• Displacement Addressing Mode: In this the contents of the
indexed register is added to the Address part of the instruction,
to obtain the effective address of operand. EA = A + (R), In this
the address field holds two values, A (which is the base value)
and R(that holds the displacement), or vice versa. Two Types:
• Relative Addressing Mode and Base Register Addressing Mode
Types of Addressing Modes

• Stack Addressing Mode: In this mode,


operand is at the top of the stack. For example:
ADD, this instruction will POP top two items
from the stack, add them, and will then PUSH
the result to the top of the stack.

You might also like