Micro Operations and Macro Operations
Micro-operations are the fundamental, low-level actions a CPU performs on data, like moving bits between registers
or performing an arithmetic operation:
Basic, individual actions performed on data in registers.
Examples:
o Register transfer
o Incrementing a register
o Clearing a register
o Arithmetic and logic operations like addition or subtraction
Execution: Often executed in a single clock cycle.
Access: Cannot be directly accessed by the user-level programmer; they are the building blocks of the CPU's
hardware control.
Macro-operations are the complex machine instructions that are broken down into a sequence of micro-operations
for execution.
A macro-operation is a single instruction that a programmer writes, but it requires a series of micro-operations to
complete, which is managed by the CPU's control unit.
Examples:
Fetching, decoding, and executing an ADD instruction.
A memory read operation.
Execution: Requires multiple clock cycles to complete the entire sequence of micro operations.
Access: The user-level programmer interacts with macro operations (e.g., writing an ADD R1,
R2 instruction). The CPU breaks this macro operation down into micro operations for execution.
Difference between Microoperations & Macrooperations
Micro-operations Macro-operations
Hardware-level, elementary High-level, machine instruction
A single, basic operation on data in registers A complete instruction that requires multiple
micro-operations
Example ADD R1, R2 (adding the contents of register R2
Incrementing a register, a register-to-register to register R1), which involves fetching,
move, or an addition operation decoding, adding, and storing the result
Executed with one control signal or function Executed with a sequence of control signals for
each micro-operation in its series
A single step in a processor's pipeline A complete instruction that is broken down into
micro-operations
Types of Registers
CPU registers are high-speed memory units essential for efficient program execution, enabling quick access
to frequently used values involved in processing. They play a crucial role in data manipulation, memory
addressing, and tracking processor status. While accessing instructions from RAM is faster than from a hard
drive, it's still not quick enough for the CPU, so registers are used to store and retrieve data faster. They
work in coordination with the CPU's memory to optimize processing. Each class of CPU registers, from
general-purpose to status and control registers, supports specific tasks to ensure smooth and rapid
execution of operations.
Different Types Of CPU Registers
There are several types of registers available in the CPU for different purposes:
Accumulator : This is the most frequently used register used to store data taken from memory. It is
indifferent numbers in different microprocessors.
Memory Address Registers (MAR) : It holds the address of the location to be accessed from
memory. MAR and MDR (Memory Data Register) together facilitate the communication of the CPU
and the main memory.
Memory Data Registers (MDR) : It contains data to be written into or to be read out from the
addressed location.
General Purpose Registers : These are numbered as R0, R1, R2....Rn-1, and used to store temporary
data during any ongoing operation. Its content can be accessed by assembly programming. Modern
CPU architectures tend to use more GPR so that register-to-register addressing can be used more,
which is comparatively faster than other addressing modes.
Program Counter (PC) : Program Counter (PC) is used to keep the track of the execution of the
program. It contains the memory address of the next instruction to be fetched. PC points to the
address of the next instruction to be fetched from the main memory when the previous instruction
has been successfully completed. Program Counter (PC) also functions to count the number of
instructions. The incrementation of PCs depends on the type of architecture being used. If we are
using a 32-bit architecture, the PC gets incremented by 4 every time to fetch the next instruction.
Instruction Register (IR): The IR holds the instruction which is just about to be executed. The
instruction from the PC is fetched and stored in IR. As soon as the instruction is placed in IR, the CPU
starts executing the instruction, and the PC points to the next instruction to be executed.
Stack Pointer (SP): The stack PCs pointer points to the top of the stack, which is a part of the
memory used to store function calls and other operations.
Flag Register: A flag register , also known as a status register or condition code register, is a special
type of register in a computer's central processing unit (CPU) used to indicate the status of the CPU
or the outcome of various operations such as Zero Flag, Carry flag, Sign Flag, Overflow Flag, Parity
Flag, Auxiliary Carry Flag, and Interrupt Enable Flag.
Condition code register ( CCR ): Condition code registers contain different flags that indicate the
status of any operation. For instance, let's suppose an operation caused the creation of a negative
result or zero, then these flags are set high accordingly. and the flags are
1. Carry C: Set to 1 if an add operation produces a carry or a subtract operation produces a borrow;
otherwise cleared to 0.
2. Overflow V: Useful only during operations on signed integers.
3. Zero Z: Set to 1 if the result is 0, otherwise cleared to 0.
4. Negate N: Meaningful only in signed number operations. Set to 1 if a negative result is produced.
5. Extend X: Functions as a carry for multiple precision arithmetic operations.
These are generally decided by ALU.
Size of CPU Register
The number and size of the register in the CPU depend on the processor design and can have an important
impact on its performance and capabilities on the CPU
8-bit registers: These can store 8 bits of data, which is the same as 1 byte. They are used for simple
arithmetic and data manipulation.
16-bit registers: These hold 16 bits of data, or 2 bytes. These registers are found in older processors
or certain systems that need 16-bit operations.
32-bit registers: These can store 32 bits of data or 4 bytes. They are common in many processors
and can handle larger data sizes and more complex calculations than 8-bit or 16-bit registers.
64-bit registers: These hold 64 bits of data, or 8 bytes. Modern processors often use these,
providing more computational power and better memory-addressing capabilities.
The Role of Registers in the CPU
Registers play a pivotal role in the CPU's operation by:
Holding Instructions: The CPU fetches instructions from memory and stores them in
registers before decoding and executing them.
Storing Data: Intermediate data resulting from computations are temporarily held in
registers.
Managing Addresses: Registers hold memory addresses, facilitating the retrieval and storage
of data from RAM.
Controlling Operations: Special-purpose registers manage the execution flow, such as the
program counter and status registers.