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

Computer Organzation notes

Uploaded by

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

Computer Organzation notes

Uploaded by

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

Chapter # 9

Components of computer organization

 Processor (CPU) -> Executes instructions and processes data. Includes

smaller components like ALU, Control unit and registers

 I/O devices ->Input devices sends data to the computer and output devices

receive data from the computer

 Memory and storage ->Memory stores data temporarily for quick access e.g

RAM

Storage (data is stored permanently for later use) e.g Hard disk, SSD

Interconnection:

These components are connected using Buses:

Data Bus: Transfers data between CPU, memory, and I/O devices.

Address Bus: Transfers the location of the data in memory.

Control Bus: Sends signals to coordinate operations (e.g., "Read" or "Write").

Processor (CPU) Structure

Subcomponents:

Datapath: Responsible for moving and processing data.

Arithmetic Logic Unit (ALU):

 Performs arithmetic operations (e.g., addition, subtraction).


 Performs logical operations (e.g., AND, OR).

Registers:

 Temporary storage inside the CPU.

 Faster than RAM, stores frequently used data.

Control Unit (CU):

 Manages and coordinates all activities of the CPU.

 Issues control signals to ensure instructions are executed in the correct

sequence.

3. Timing and Clock

Definitions:

1. Clock:

o Synchronizes all operations in the CPU.

o Measures time in "cycles," called clock cycles.

2. Clock Period:

o Time taken to complete one clock cycle.

o Formula: Clock Period = 1 / Clock Rate.

3. Clock Rate (Frequency):

o Number of cycles completed per second.


o Measured in Hertz (Hz):

 1 Hz = 1 cycle per second.

 1 GHz = 1 billion cycles per second.

Example:

 A 2 GHz CPU has a cycle time = 1 / (2 × 10⁹) = 0.5 nanoseconds.

4. IA-32 Registers

Types:

1. General-Purpose Registers:(32 bit registers)

o Used for arithmetic, data storage, and memory access.

EAX, EBX, ECX, EDX, ESP, EBP, EDI, ESI

 EAX (Accumulator Register): Primarily used for arithmetic operations

and storing function return values.

 EBX (Base Register): Often used as a base pointer for memory

access in data segments.

 ECX (Counter Register): Acts as a loop counter for iterative

instructions like LOOP and REP.

 EDX (Data Register): Used for I/O operations and to store values for

extended arithmetic operations.


 ESP (Stack Pointer): Points to the top of the stack, tracking the stack's

current position.

 EBP (Base Pointer): Points to the base of the stack frame for

accessing function parameters and local variables.

 EDI (Destination Index): Used as the destination address in string and

memory manipulation operations.

 ESI (Source Index): Used as the source address in string and memory

manipulation operations.

2. Special Registers:

o EIP (Extended Instruction Pointer):

 Holds the address of the next instruction to execute.

o EFLAGS:

 Stores binary flags to indicate CPU status or control behavior.

 Examples:

1. Carry Flag (CF)

 Definition: The Carry Flag indicates if an arithmetic operation generates a

carry (extra bit) beyond the size of the destination register in unsigned

operations.

 High (Set to 1): When the result is too large for the register (e.g., adding 8-bit

numbers results in a 9-bit value).


 Low (Set to 0): When the result fits within the register size.

 Example:

o Adding 255 (8-bit max: 11111111) + 1 → Result is 256 (100000000, 9

bits).

o CF = 1 because the result exceeded the 8-bit limit.

2. Overflow Flag (OF)

 Definition: The Overflow Flag indicates if an arithmetic operation causes an

overflow in signed operations (i.e., the result is outside the valid range of

signed numbers).

 High (Set to 1): When the result is too large for the signed range.

 Low (Set to 0): When the result is within the signed range.

 Example:

o Adding +120 and +10 in 8-bit signed numbers (valid range: -128 to

+127).

o Result is +130, which exceeds the maximum of +127.

o OF = 1 because the result is out of the signed range.

3. Sign Flag (SF)


 Definition: The Sign Flag indicates whether the result of an operation is

negative by copying the most significant bit (MSB), which represents the sign.

 High (Set to 1): When the result is negative (MSB = 1).

 Low (Set to 0): When the result is positive or zero (MSB = 0).

 Example:

o Subtracting 3 - 5 → Result is -2.

o Binary representation of -2 is 11111110 (MSB = 1).

o SF = 1 because the result is negative.

4. Zero Flag (ZF)

 Definition: The Zero Flag indicates whether the result of an operation is zero.

 High (Set to 1): When the result is exactly zero.

 Low (Set to 0): When the result is non-zero.

 Example:

o Subtracting 4 - 4 → Result is 0.

o ZF = 1 because the result is zero.

o Subtracting 4 - 3 → Result is 1, so ZF = 0.

5. Auxiliary Carry Flag (AF)


 Definition: The Auxiliary Carry Flag indicates a carry from the 4th bit (bit 3) to

the 5th bit (bit 4), used for BCD (Binary-Coded Decimal) operations.

 High (Set to 1): When there’s a carry from bit 3 to bit 4.

 Low (Set to 0): When no carry occurs between these bits.

 Example:

o Adding 9 (1001) + 7 (0111) → Result is 16 (00010000).

o Carry occurred between bit 3 and bit 4, so AF = 1.

6. Parity Flag (PF)

 Definition: The Parity Flag indicates whether the number of 1 bits in the

binary representation of the result is even or odd.

 High (Set to 1): When the number of 1 bits is even (even parity).

 Low (Set to 0): When the number of 1 bits is odd (odd parity).

 Example:

o Result: 10101100 (binary).

o It has 4 1 bits (even).

o PF = 1 because the parity is even.

o If the result were 10101101 (5 1 bits), PF = 0.

3. Segment Registers:

o Support segmented memory (e.g., Code, Data, Stack).

o Segments are regions of memory used for specific purposes.


CS, SS, DS, ES, FS, GS

 CS (Code Segment): Holds the base address of the code segment,

which contains the executable instructions of a program.

 SS (Stack Segment): Holds the base address of the stack segment,

which is used for function calls, local variables, and managing the stack.

 DS (Data Segment): Holds the base address of the data segment,

which stores initialized global and static variables.

 ES (Extra Segment): Provides an additional data segment for

operations like string manipulation and memory copying.

 FS (General-Purpose Segment): Typically used for thread-local

storage or special purposes defined by the operating system.

 GS (General-Purpose Segment): Similar to FS, often used for system-

specific purposes such as thread data or kernel data.

5. Memory Management

Memory Addressing:

1. Byte Addressable Memory:

o Each byte in memory has a unique address.


o Example: Address 0x0001 points to the second byte in memory.

2. Physical Address Space:

o Determined by the width of the Address Bus.

o Example:

 32-bit Address Bus → 2³² = 4 GB addressable memory.

Endianness:

1. Little Endian:

o Stores the least significant byte first.

o Example: Number 0x12345678 stored as 78 56 34 12.

2. Big Endian:

o Stores the most significant byte first.

o Example: 0x12345678 stored as 12 34 56 78.

6. Memory Types

Volatile Memory:

1. RAM (Random Access Memory):

o Temporary storage, cleared when power is off.


o Types:

 DRAM (Dynamic RAM): Slower, requires refreshing.

 SRAM (Static RAM): Faster, does not need refreshing.

2. Cache Memory:

o High-speed SRAM used for frequently accessed data.

o Found in multiple levels (L1, L2, L3).

Non-Volatile Memory:

1. ROM (Read-Only Memory):

o Permanent storage for system startup instructions.

o Types: EPROM, EEPROM, FLASH.

7. I/O Operations

Interaction with the CPU:

 I/O devices communicate via an I/O Controller.

o Example: Disk controller manages data transfer between disk and

memory.

Steps in Read/Write Operations:

1. Read Cycle:
o CPU places address on Address Bus.

o CPU asserts "Read" on Control Bus.

o Memory places data on Data Bus.

o CPU reads the data.

2. Write Cycle:

o CPU places address and data on respective buses.

o CPU asserts "Write" on Control Bus.

o Memory writes data to the specified location.

8. Instruction Execution Cycle

1. Fetch:

o CPU retrieves the next instruction from memory using the EIP.

2. Decode:

o Instruction is interpreted and control signals are prepared.

3. Execute:

o ALU or other CPU components perform the operation.

4. Write Back:
o Results are stored in memory or registers.

Practice Questions

1. What are the three main components of a computer?

2. Define the function of the ALU and Control Unit.

3. What is the formula for calculating clock period?

4. Explain the purpose of the EIP and EFLAGS registers.

5. What is Little Endian memory storage?

6. Differentiate between DRAM and SRAM.

7. List the steps in the Read Cycle.

Chapter #10 & 11

Why do we need to declare variable?

 To make identifiers for specific address in the memory

 To reserve memory to access and store data in the memory

Syntax:

Identifier - data type - value

Variable declaration

Bytes (0_2^8-1 -2^7 -_2^7-1)


Word (0_2^16-1 -2^15 _ 2^15-1)

Double (0_2^32-1 -2^31 _ 2^32-1)

Quard (0_2^364-1 -2^63 _ 2^63-1)

You might also like