2 Module 1
2 Module 1
1
Registers
• Categories of registers:
• User-visible registers – Can be referenced by means of the machine language
that the processor executes; used to enable the programmer to minimize main
memory references by optimizing use of registers. (General Purpose registers)
• Control and status registers – Used by the control unit to control the operation
of the processor and by privileged, operating system programs to control the
execution of programs
Note: There is not a clean separation of registers into these two categories. For example, on some machines the
program counter is user visible (e.g., x86), but on many it is not.
2
User-Visible Registers
• General purpose registers –
• The 8085 has six general-purpose registers to store 8-bit data; these are
identified as- B, C, D, E, H, and L.
• These can be combined as register pairs – BC, DE, and HL, to perform some
16-bit operation.
• These registers are used to store or copy temporary data, by using instructions,
during the execution of the program.
• can be used for a variety of functions; Can used to store instruction or data.
• can contain the operand for any instruction
• Accumulator – The accumulator is an 8-bit register (can store 8-bit data) that is
the part of the arithmetic and logical unit (ALU). After performing arithmetical or
logical operations, the result is stored in accumulator.
3
User-Visible Registers
• Data registers – Can be used only to hold data and cannot be involved in the calculation of addresses
• Ex: MDR-Memory Data Registers
• Address registers – Employed in the calculation of addresses Ex: MAR
• Count register- These registers store the loop count in iterative operations.
• Limit Register - The limit register contains the number of bytes in the allocation
Pointer Registers
• Base & Index Registers - The base register contains the lowest address allocated.
• The base register often holds the beginning location of a memory array, while the index register holds the relative
position of an element in the array.
• There are two sets of index pointers −
• Source Index (SI) − It is used as source index for string operations.
• Destination Index (DI) − It is used as destination index for string operations.
• Stack pointers- A stack is a specialized buffer that is used by a program's functions to store data such as
parameters, local variables and other function-related information.
• It is the collection of Memory word or registers. The Stack Pointer (SP) register is used to indicate the location
of the last item put onto the stack. Push and Pop are the major functions.
4
Status Registers
• A status register, flag register, or condition code register (CCR) is a collection
of status flag bits for a processor.
• Condition codes – bits set by the processor hardware as the result of operations;
partially visible to the user
5
Status Registers
• Many processor designs include a register or set of registers, often known as the
program status word (PSW), that contain condition codes plus other status
information.
• Common fields or flags:
• Sign: Contains the sign bit of the result of the last arithmetic operation.
• Zero: Set when the result is 0.
• Carry: Set if an operation resulted in a carry (addition) into or borrow
(subtraction) out of a high-order bit.
• Auxiliary Carry: Set if there is a carry from the lower four bits to the upper four
bits
• Parity: Set if the parity is even (i.e. if the number of set bits in the result of an
arithmetic operation is even)
• Equal: Set if a logical compare result is equality.
6
7
Status Registers
• Common fields or flags (contd.):
• Overflow: It indicates the overflow of a high-order bit (leftmost bit) of data after a signed arithmetic
operation. Used to indicate arithmetic overflow.
• Direction: Used to determine the direction for moving string data. It determines left or right
direction for moving or comparing string data. When the DF value is 0, the string operation takes
left-to-right direction and when the value is set to 1, the string operation takes right-to-left direction.
• Interrupt Enable/Disable: Used to enable or disable interrupts. It determines whether the external
interrupts like keyboard entry, etc., are to be ignored or processed. It disables the external interrupt
when the value is 0 and enables interrupts when set to 1.
• Supervisor: Indicates whether the processor is executing in supervisor or user mode. Certain
privileged instructions can be executed only in supervisor mode, and certain areas of memory can
be accessed only in supervisor mode.
• Trap Flag (TF) − It allows setting the operation of the processor in single-step mode. The DEBUG
program we used sets the trap flag, so we could step through the execution one instruction at a time.
• Shift Registers
8
Status Register – Shift Register
• A Shift Register is a kind of sequential logic circuit that have ability of both storing and transferring data, made up
of flip-flops and connected in such manner that the output of one flip-flop will work as the input of other flip-flop
(depending upon which type of shift register is used)
• There are six types of shift register which are as follows −
• Serial in - Serial out Shift Register − It streams-in data serially one after the other and streams-out in similar
manner.
• Serial in - Parallel Out Shift Register − It converts the data in serial manner and out the data in parallel manner
• Parallel in - Serial Out Shift Register − It takes data in parallel and streamsout in serial manner (one after other).
• Parallel in - Parallel Out Shift Register − Input data fed-in parallel and output data is streams-out simultaneously
parallel.
• Bidirectional Shift Register − This shift register can perform either right or left data shift or could perform in both
directions.
• Counters − It feedbacks their output into the device as input in such a manner that creates a particular pattern or
sequence.
9
Control Registers
• Control register is called a processor register that changes or controls the general
behaviour of a CPU or other services in the system.
• One of the control registers for a von-Neumann machine is the Program Counter
(PC).
• Common tasks performed by control registers include
• interrupt control,
• switching the addressing mode,
• Paging control and
• coprocessor control.
10
Segment Registers
• Four special segment registers: cs, ds, es, and ss.
• These stand for Code Segment, Data Segment, Extra Segment, and Stack Segment,
respectively.
• These registers are all 16 bits wide. They deal with selecting blocks (segments) of main
memory.
• The Code segment register (e.g., cs) points at the beginning of a segment in memory.
• The data segment register, ds, generally points at global variables for the program
• The extra segment register, es - programs often use this segment register to gain access
to segments when it is difficult or impossible to modify the other segment registers.
• The ss register - stores machine state information, subroutine return addresses,
procedure parameters, and local variables.
12
These registers are used for the movement of data between the processor and memory.
13
Typical operating steps with registers
• Programs reside in the memory and usually get there through the input unit.
• Execution of the program starts when the PC is set to point to the first instruction of the
program.
• The contents of the PC are transferred to the MAR and a Read control signal is sent to the
memory.
• After the time required to access the memory elapses, the addressed word is read out of the
memory and loaded into MDR.
• Next the contents of MDR are transferred to the IR. At this point, the instruction is ready to
be decoded and executed.
• If the instruction involves an operation to be performed by the ALU, it is necessary to obtain the
required operands.
• If an operand resides in the memory, it has to be fetched by sending its address to the MAR and
initiating a Read cycle.
14
Typical operating steps with registers
• When the operand has been read from the memory into the MDR, it is transferred from
the MDR to the ALU.
• After one or more operands are fetched in this way, the ALU can perform the desired
operation.
• If the result of this operation is to be stored in the memory, then the result is sent to
the MDR.
• The address of the location where is result is to be stored is sent tot MAR and write
cycle is initiated.
• Then contents of PC are incremented so that the PC points to the next instruction to
be executed.
• As soon as the execution of the current instruction is completed, a new instruction fetch
may be started.
15
Summary
Example Processor Register Organization
16
Register Files
• Registers are temporary storage locations inside the CPU that hold data and
addresses.
• A register file is an array of processor registers in a central processing
unit (CPU).
• Register banking is the method of using a single name to access multiple different
physical registers depending on the operating mode.
• The register file is the component that contains all the general purpose registers of
the microprocessor.
• A few CPUs also place special registers such as the PC and the status register in
the register file.
17
To perform this operation C = A+ B, we want to read two values from the register
file, A and B. We also have one result that we want to write back to the register
file when the operation has completed. For cases where we do not want to write
any value to the register file, we add a control signal called Read/Write. When the
control signal is high, the data is written to a register, and when the control signal
is low, no new values are written
18
Interconnection of Components
• A group of lines that serves as a connecting path for several devices is called a
bus.
• The simplest way to interconnect functional units is to use a single bus.
19
Internal buses
• The internal bus, also known as internal data bus, memory bus, system bus or
front-side bus
• connects all the internal components of a computer, such as CPU and memory, to
the motherboard.
• Internal data buses are also referred to as local buses.
• This bus is typically rather quick and is independent of the rest of the computer
operations.
20
BUS INTERCONNECTION
21
22
• Three types of bus lines are used.
• Address bus - carries memory addresses from the processor to other components
such as primary storage and input/output devices. The address bus
is unidirectional.
• Data bus - carries the data between the processor and other components. The data
bus is bidirectional.
• Control bus - carries control signals from the processor to other components. The
control bus also carries the clock's pulses. The control bus is unidirectional.
23
External Bus
• The external bus, or expansion bus, is made up of the electronic pathways that
connect the different external devices, such as printer etc., to the computer
24