1.
Number Systems
In computing, data is represented and processed using different number systems. The
most common ones are Binary, Octal, Decimal, and Hexadecimal.
1.1. Binary Number System (Base-2)
The binary system is the fundamental number system for computers, using only two
digits: 0 and 1. Each position in a binary number represents a power of 2.
Examples:
* 10101₂ = 1 × 2⁴ + 0 × 2³ + 1 × 2² + 0 × 2¹ + 1 × 2⁰ = 16 + 0 + 4 + 0 + 1 = 21₁₀
* 111001₂ = 1 × 2⁵ + 1 × 2⁴ + 1 × 2³ + 0 × 2² + 0 × 2¹ + 1 × 2⁰ = 32 + 16 + 8 + 0 + 0 + 1 =
57₁₀
1.2. Octal Number System (Base-8)
The octal system uses eight digits: 0, 1, 2, 3, 4, 5, 6, and 7. It is often used as a more
compact representation of binary numbers because three binary digits can be
represented by a single octal digit.
Examples:
* 27₈ = 2 × 8¹ + 7 × 8⁰ = 16 + 7 = 23₁₀ *
30₈ = 3 × 8¹ + 0 × 8⁰ = 24 + 0 = 24₁₀
1.3. Hexadecimal Number System (Base-16)
The hexadecimal system uses sixteen symbols: 0-9 for values zero to nine, and A, B, C,
D, E, F for values ten to fifteen. It's widely used in computing because four binary digits
can be represented by a single hexadecimal digit, making large binary strings more
readable.
Examples:
* 2A₁₆ = 2 × 16¹ + 10 × 16⁰ = 32 + 10 = 42₁₀
* FF₁₆ = 15 × 16¹ + 15 × 16⁰ = 240 + 15 = 255₁₀
*A comparison of Binary, Octal, Decimal, and Hexadecimal values.
2. Binary Number Representation
Computers use various methods to represent signed (positive and negative) binary
numbers.
2.1. Sign-Magnitude Representation
In sign-magnitude representation, the leftmost bit (Most Significant Bit - MSB) indicates
the sign of the number: 0 for positive and 1 for negative. The remaining bits represent
the magnitude of the number.
Example (using 8 bits):
* +5 = 00000101
* -5 = 10000101
Limitations: It has two representations for zero (+0 and -0), and arithmetic operations
are complex.
2.2. 1's Complement Representation
To find the 1's complement of a binary number, all bits are flipped (0s become 1s, and
1s become 0s). For negative numbers, the 1's complement of its positive counterpart is
taken.
Example (using 8 bits): *
+5 = 00000101
* To represent -5:
1. Start with +5: 00000101
2. Flip all bits (1's complement): 11111010 So, -5 in 1's complement
is 11111010.
Limitations: Still has two representations for zero (+0 and -0), which complicates
arithmetic.
2.3. 2's Complement Representation
The 2's complement is the most common method for representing signed integers in
computers because it simplifies arithmetic operations and has only one representation
for zero. To find the 2's complement of a binary number, you first find its 1's complement
and then add 1 to the result.
Example (using 8 bits): *
+5 = 00000101
* To represent -5:
1. Start with +5: 00000101
2. Find 1's complement: 11111010
3. Add 1 to the 1's complement: 11111010 + 1 = 11111011 So, -5 in 2's complement is
11111011.
*Comparison of Sign-Magnitude, 1's Complement, and 2's Complement
representations.
3. Logic Gates
Logic gates are the basic building blocks of any digital circuit. They are electronic
circuits that perform logical operations on one or more binary inputs and produce a
single binary output.
3.1. AND Gate
• Symbol: A D-shaped symbol with two or more inputs and one output.
• Operation: Output is 1 (TRUE) only if all inputs are 1 (TRUE). Otherwise, the
output is 0 (FALSE).
• Truth Table:
Input A Input B Output (A AND B)
0 0 0
Input A Input B Output (A AND B)
0 1 0
1 0 0
1 1 1
3.2. OR Gate
• Symbol: A curved symbol resembling a crescent moon with two or more inputs
and one output.
• Operation: Output is 1 (TRUE) if at least one input is 1 (TRUE). Output is 0
(FALSE) only if all inputs are 0 (FALSE).
• Truth Table:
Input A Input B Output (A OR B)
0 0 0
0 1 1
1 0 1
1 1 1
3.3. NOT Gate (Inverter)
• Symbol: A triangle with a circle (inversion bubble) at the output. Has one input
and one output.
• Operation: Inverts the input. If the input is 1, the output is 0; if the input is 0, the
output is 1.
• Truth Table:
Input A Output (NOT A)
0 1
1 0
3.4. NAND Gate
• Symbol: An AND gate symbol followed by an inversion bubble.
• Operation: Output is 0 (FALSE) only if all inputs are 1 (TRUE). It is the inversion
of an AND gate.
• Truth Table:
Input A Input B Output (A NAND B)
0 0 1
0 1 1
1 0 1
1 1 0
3.5. NOR Gate
• Symbol: An OR gate symbol followed by an inversion bubble.
• Operation: Output is 1 (TRUE) only if all inputs are 0 (FALSE). It is the inversion
of an OR gate.
• Truth Table:
Input A Input B Output (A NOR B)
0 0 1
0 1 0
1 0 0
1 1 0
3.6. EX-OR (Exclusive OR) Gate
• Symbol: An OR gate symbol with an additional curved line at the input.
• Operation: Output is 1 (TRUE) if inputs are different. Output is 0 (FALSE) if
inputs are the same.
• Truth Table:
Input A Input B Output (A XOR B)
0 0 0
0 1 1
1 0 1
1 1 0
*Symbols and Truth Tables for Basic Logic Gates.
4. Basic Organization of Computer: Von
Neumann Model
The Von Neumann architecture, named after mathematician and computer scientist
John von Neumann, is a design model for an electronic digital computer with a stored
program concept. Most modern computers are based on this architecture.
4.1. Key Components
The Von Neumann model consists of four main components:
1. Central Processing Unit (CPU): The "brain" of the computer, responsible for
executing instructions and processing data. It comprises:
– Arithmetic Logic Unit (ALU): Performs arithmetic operations (addition,
subtraction, etc.) and logical operations (AND, OR, NOT).
– Control Unit (CU): Directs and coordinates most of the operations in the
computer. It fetches instructions from memory, decodes them, and then
directs the ALU, memory, and I/O devices to execute them.
– Registers: Small, high-speed storage locations within the CPU used to
temporarily hold data and instructions during processing. Examples
include the Program Counter (PC), Instruction Register (IR), Memory
Address Register (MAR), and Memory Data Register (MDR).
2. Main Memory: Stores both data and program instructions in the same address
space. This is a key feature of the Von Neumann architecture, allowing the
computer to easily switch between fetching instructions and fetching data. It is
typically RAM (Random Access Memory).
3. Input/Output (I/O) Devices: Allow the computer to interact with the outside
world.
– Input Devices: (e.g., keyboard, mouse, scanner) send data into the
computer.
– Output Devices: (e.g., monitor, printer, speakers) display or send data
from the computer.
4. Buses: A collection of wires or communication lines that provide a path for data,
addresses, and control signals between the CPU, memory, and I/O devices.
– Data Bus: Carries data between components.
– Address Bus: Carries memory addresses from the CPU to memory or I/O
devices.
– Control Bus: Carries control signals to coordinate activities between
components.
4.2. Stored-Program Concept
A cornerstone of the Von Neumann architecture is the stored-program concept. This
means that both the program instructions and the data that the program operates on are
stored in the same memory unit. This allows for:
* Flexibility: The computer can be reprogrammed by simply loading a new set of
instructions into memory, rather than having to rewire the machine.
* Self-modifying code (though rarely used in modern programming): A
program can modify its own instructions, although this is generally discouraged due to
complexity and security risks.
4.3. The Fetch-Decode-Execute Cycle
The CPU continuously performs the fetch-decode-execute cycle (also known as the
instruction cycle) to process instructions:
1. Fetch: The Control Unit fetches the next instruction from the main memory, using
the address stored in the Program Counter (PC). The instruction is then loaded
into the Instruction Register (IR).
2. Decode: The Control Unit interprets (decodes) the instruction. It determines what
operation needs to be performed and identifies the operands required for the
operation.
3. Execute: The Control Unit signals the relevant components (e.g., ALU, memory,
I/O devices) to perform the operation specified by the instruction. This might
involve retrieving data from memory, performing calculations in the ALU, or
sending data to an output device. The results are often stored in registers or back
in memory.
After execution, the Program Counter is updated to point to the next instruction, and the
cycle repeats.
*Basic Structure of the Von Neumann Architecture.