
Computer Architecture - The Basics
15 November, 2022
0
0
0
Contributors
Computer Architecture - The Basics
•
•
The CPU
•
•
•
•
•
Program Counter
instruction decoder
.Instruction Decoder
addition, subtraction, multiplication, data movement, etc
and also the memory addresses associated with the particular instruction.
For example, if the instruction says ADD a,b
- The instruction decoder figures out that the Addition
operation needs to take place on two numbers which are located at the locations a,b
in the memory.Data Bus
Registers
ADD a,b
- The CPU retrives the values stored at memory locations a and b
, stores them in the general-purpose registers and performs the ADD
operation.
There are two types of registers,•
•
Arithmetic and Logical Unit
The Memory
fixed-size
storage locations.
For example, if you have a memory of 256 Megabytes, it means that you have 256 million (mega = 1 million) fixed-size storage locations. Each storage location can store a byte (8 bits) of information.
Each byte (fixed-size storage location) in the memory has its own address so that the CPU can access it when it wants to. We call this a memory address
.A byte can hold a number between 0 and 255
A-Z
are represented by the decimal numbers 65-90
.Storing numbers larger than 255?
Each byte can only hold a number up to 255, but that doesn't mean computers cannot store and process numbers higher than 255. Bytes can be combined together to represent larger numbers.
For example, a number like 551
can be represented in binary as 1000100111
(using 10 bits), hence this number can be represented using two bytes 22 7
Word Size
32 bits (4 bytes)
, which means a register in such computers can hold values upto 4 bytes. Similarly, the word size of 64-bit computers is 64 bits (8 bytes)
which means a register in this computer can hold values upto 8 bytes.
The size of memory addresses is the same as the word size of the computer, i.e., in a 32-bit computer the addresses are 4 bytes long and in a 64-bit computer, the addresses are 8 bytes long.Computers cannot tell if a value is an address, a number, or an instruction. A programmer gets to decide how to treat specific numbers/values located in the memory. For example, we can treat a value as either an ASCII number or a memory address.
A clarification: Memory addresses are only stored in registers and not in RAM, whereas values that are parameters for operations are stored in the RAM and are later moved into a register where they are stored temporarily until the operation is finished.
Pointers
pointers
. They point to the other locations in the memory where the actual data required for the operations are stored.2^32 = 4294967296 bytes
from the RAM and 64-bit computers can access 2^64 = 18446744073709551616 bytes
from the RAM.122036470
in decimal which is 00000111010001100010000011110110
in binary and 74 62 0F 6
in hexadecimal. Each bit (0 or 1) in this memory address can reference an individual byte in the actual memory. Therefore, total number of bytes it can potentially reference is 2^32.Interpreting Memory
•
•
•
•
Implementation 1
1001
in this case) and add 100 to it, which gives 1101
. So we can simply get the value located at the address 1101
and it is the age of the customer.Implementation 2
1001
in this case) and add 8 to it, which gives 1009
, now we get the value at this address which gives us the pointer which is pointing to the age of the customer.Data Accessing Methods
•
•
•
•
•
•
Immediate mode
ADD 2,3
. It directly specifies the numbers (2 and 3) to add in the instruction itself.Register addressing mode
ADD %eax, %ebx
. It specifies the registers (eax and ebx) from where the data is to be extracted from to perform the operation.Direct addressing mode
ADD 1001h, 1005h
. It specifies the memory addresses (1001 and 1005) from where the values are to be extracted to perform the addition operation.Indexed addressing mode
ADD 1001h+%si, 1003h+%di
. It contains the memory addresses (1001 and 1003) and also the index registers (si and di) to offset the address.Indirect addressing mode
eax
, the pointer in this register is retrieved and then value pointed by the pointer is extracted to perform the action.Base pointer addressing mode
References
computer
science
architecture