Binary Code
What is Binary Code?
Binary code is the basic language of computers.
It uses only two digits: 0 and 1.
0 = OFF (No signal)
1 = ON (Signal)
Every piece of data (numbers, letters, images, videos, etc.) is represented using binary
code.
Binary System
Number system with only 0 and 1.
Also called the Base-2 number system.
Bit
Bit (Binary Digit) is the smallest unit of data.
It can have only 0 or 1.
Byte
1 Byte = 8 Bits
Example:
o Letter A = 01000001 (ASCII Code)
Why Do Computers Use Binary?
Electronic circuits have only two states:
o ON (1)
o OFF (0)
Binary matches these two states, making computers fast and reliable.
Applications of Binary Code
1. Computers and Digital Devices
Stores and processes all data.
Used in computers, laptops, mobiles, tablets, and smart TVs.
Example: Opening a Word document.
2. Communication Systems
Sends data through the Internet, Wi-Fi, fiber optics, and cables.
Example: Sending a Whats App message.
3. Digital Security (Encryption)
Protects passwords and online transactions.
Used in banking and online shopping.
Example: Secure UPI payment.
4. Digital Image Processing
Images are stored using binary values.
Each pixel is represented in binary.
Example: Mobile phone photos.
5. Digital Audio Processing
Audio is converted into binary before storage and playback.
Example: MP3 songs and voice recordings.
6. Computer Networking
Internet data travels as binary packets.
Example: Watching YouTube videos.
7. Microcontrollers and Embedded Systems
Used in electronic devices that work automatically.
Examples:
Microwave oven
Washing machine
Smart TV
Traffic signal
Elevator
Key Components Using Binary
Transistors
Work like electronic switches.
States:
o ON = 1
o OFF = 0
Logic Gates
Perform logical operations using binary values.
Common gates:
AND
OR
NOT
NAND
NOR
XOR
XNOR
CPU (Microprocessor)
Executes binary instructions.
Performs arithmetic and logical operations.
RAM and ROM
RAM: Temporary memory.
ROM: Permanent memory containing startup instructions.
Storage Devices
Binary data is stored in:
Hard Disk (HDD)
SSD
Pen Drive
Memory Card
What Does Binary Code Do?
Represents Data
Stores:
Letters
Numbers
Symbols
Example:
A = 01000001
Stores Information
Photos, videos, documents, and files are stored in binary form.
Executes Instructions
The CPU follows binary instructions to perform tasks.
Transfers Data
Emails, videos, and messages are sent as binary data.
CPU Registers
What are CPU Registers?
CPU registers are small, high-speed memory locations inside the CPU.
They store data, instructions, and memory addresses temporarily.
Registers are the fastest memory in a computer.
They help the CPU execute instructions quickly.
Registers reduce the need to access RAM repeatedly, improving performance.
Types of CPU Registers
1. Accumulator (AC)
Stores data and intermediate results of arithmetic and logical operations.
Frequently used by the ALU.
Speeds up calculations.
Example: Adding two numbers (20 + 30 = 50).
2. Memory Address Register (MAR)
Stores the address of the memory location to be accessed.
Works with the MDR during memory operations.
Specifies where data is to be read or written.
Example: Accessing data stored at memory address 1000.
3. Memory Data Register (MDR)
Stores the data being transferred to or from memory.
Holds data temporarily during read/write operations.
Example: Reading a student's marks from RAM.
4. General Purpose Registers (GPR)
Named as R0, R1, R2, … Rn.
Store temporary data during program execution.
Used for arithmetic, logical, and data transfer operations.
Example: Storing variables in a program.
5. Program Counter (PC)
Stores the address of the next instruction to be executed.
Automatically updates after each instruction.
Controls the sequence of program execution.
Example: After executing instruction at address 200, the PC moves to address 204 (in a 32-bit
system).
6. Instruction Register (IR)
Holds the current instruction being executed.
Receives the instruction fetched from memory.
Sends the instruction to the CPU for execution.
Example: Stores the instruction ADD R1, R2 before execution.
7. Stack Pointer (SP)
Points to the top of the stack in memory.
Used during function calls, recursion, and interrupts.
Helps store return addresses and local variables.
Example: Saving the return address during a function call.
8. Flag Register (Status Register)
Stores the status of arithmetic and logical operations.
Indicates whether the result is zero, negative, overflow, etc.
Used for decision-making in programs.
Common Flags
Zero Flag (Z): Result is zero.
Carry Flag (C): Carry generated during addition or borrow during subtraction.
Sign Flag (S/N): Result is negative.
Overflow Flag (V): Arithmetic overflow occurs.
Parity Flag (P): Number of 1's is even.
Auxiliary Carry (AC): Carry from lower nibble.
Interrupt Enable Flag (IF): Enables or disables interrupts.
Example: If 5 − 5 = 0, the Zero Flag is set.
9. Condition Code Register (CCR)
Contains status flags after an operation.
Used for conditional branching and decision-making.
Flags in CCR
Carry (C): Set when carry or borrow occurs.
Overflow (V): Set when signed overflow occurs.
Zero (Z): Set when the result is zero.
Negative (N): Set when the result is negative.
Extend (X): Used for multiple-precision arithmetic.
Summary Table
Register Function Example
Accumulator (AC) Stores arithmetic/logic results 20 + 30 = 50
MAR Stores memory address Address 1000
MDR Stores data transferred to/from memory Reading marks from RAM
GPR Stores temporary data Variables in a program
PC Holds address of next instruction Next instruction at 204
IR Holds current instruction ADD R1, R2
SP Points to top of stack Function calls
Flag Register Stores operation status Zero, Carry, Overflow
CCR Contains condition flags Used in conditional branching
Key Points for Exams
Registers are high-speed memory units inside the CPU.
They provide faster access than RAM.
PC stores the next instruction address.
IR stores the current instruction.
MAR stores the memory address.
MDR stores data transferred to/from memory.
Accumulator stores intermediate arithmetic and logical results.
Stack Pointer manages function calls and the stack.
Flag Register/CCR stores status flags used for program control and decision-making.