Uploaded by dawsonakyan

1 - ALU, CU, registers and buses

advertisement
1 - ALU, CU, registers and buses
Arithmetic Logic Unit (ALU)
●
Performs arithmetic and logical operations on data.
●
Arithmetic operations on fixed and floating point numbers:
○
ADD
○
SUBTRACT
○
MULTIPLY
○
DIVIDE
●
Bitwise shift operations left and right
●
Boolean logic operations:
●
○
Comparison
○
AND
○
OR
○
NOT
○
XOR
Often uses general-purpose registers to temporarily hold the results of calculations such as the
accumulator.
Control Unit
●
Coordinates all activities of the CPU.
●
Directs flow of data between the CPU and other devices.
●
Accepts the next instruction, decodes it, handles its execution, and stores the resulting data back in
memory or registers.
●
Sends memory read and write requests to main memory on the control bus, as well as other command
and control signals such as bus requests, bus grants, interrupt requests, etc.
●
Makes extensive use of the status registers and clock.
●
Coordinates and communicates with all parts of the CPU.
Registers
Program Counter (PC)
●
Holds the address of the next instruction to be executed.
●
This could be:
●
○
the next instruction in a sequence of instructions;
○
or the address to jump to if the current instruction is a command to jump or branch - this would be
copied from the current instruction register.
Has a very close relationship with the memory address register. At the start of every
fetch-decode-execute cycle, the address held in the PC is copied to the MAR.
1 - ALU, CU, registers and buses
Accumulator (ACC)
●
One of a number of general-purpose registers that modern CPUs have.
●
Data or control information is often stored in them.
●
A CPU might have many general-purpose registers for storing temporary data while instructions or
calculations are being carried out.
●
Typically, the more-general purpose registers a processor has, the faster it may operate.
●
The results of calculations carried out by the ALU can be temporarily stored here.
Memory Address Register (MAR)
●
This holds the address of the memory location from which:
○
data; or
○
an instruction
is to be fetched or to which data is to be written.
●
Sends these addresses to memory down the address bus.
Memory Data Register (MDR)
●
Used to temporarily store the data which is:
○
read from; or
○
written to memory.
●
Sometimes known as the memory buffer register (MBR) and often nicknamed the “gateway to the
processor”.
●
All data to and from memory must travel down the data bus and pass through the MDR.
Current Instruction Register (CIR)
●
Holds the current instruction being executed.
●
The contents of the MDR are copied to the CIR if it is an instruction.
●
Contains the opcode and operand(s) of the current instruction.
●
Instruction = opcode + operand(s).
●
For example, a machine language instruction to load the contents of location 1000 into the ALU might
look something like:
○
LDA 1000
Busses
Address bus: Carries memory addresses that identify where the data is being read from or written to
(unidirectional).
1 - ALU, CU, registers and buses
Data bus: Carries the binary 1s and 0s that make up the actual information being transmitted around the
CPU/computer (bidirectional).
Control bus: Carries command and control signals to and from every other component of the CPU/computer
(bidirectional).
How this all relates to assembly language programs
●
Although computers only deal in binary 1s and 0s, as humans, we
prefer to deal in more abstract languages that we can understand.
●
We can see here that instruction 0101 means to load.
●
At a low level, computers use assembly code, a language that has a
direct one-to-one relationship with the processor architecture.
●
The assembly instruction for load would be “LDA”. In assembly
language, this is known as a mnemonic.
Assembly Code Mnemonics
●
ADD: Add
●
SUB: Subtract
●
STA: Store
●
LDA: Load
●
BRA: Branch always
●
BRZ: branch if zero
●
BRP: Branch if positive
●
INP: Input
●
OUT: Output
●
HLT: End program
●
DAT: Data location
Which registers hold and transfer data or instructions? Which registers hold and transfer the memory
addresses of data or instructions?
The MDR and the CIR hold and transfer data and instructions;
The PC and MAR hold and transfer addresses of data and instructions;
The accumulator holds and transfers data.
Download