Computer Architecture & Assembly Language
UNIT-I: Basic Computer Organization and Design
Basic Computer Organization and Design: Instructions and Instruction Codes, Timing and Control/Instruction Cycle, Registers (Types of Registers, General Purpose & Special Purpose Registers, Index Registers), Register Transfer and Micro Operations, Memory and Memory Function, Bus/Data Transfer Instructions, Arithmetic Logic Micro-operations, Shift Micro-operations, Input/Output and Interrupts, Memory Reference Instructions, Memory Interfacing Memory, Cache Memory.
UNIT-II: Central Processing Unit
Central Processing Unit: General Register Organization, Stack Organizations, Instruction Formats, Addressing Modes, Data Transfer and Manipulation, Program Control, Reduced Instruction Set Computer (RISC) and Complex Instruction Set Computer (CISC) Pipeline, Vector Processing, Array Processing. Arithmetic Algorithms: Integer Multiplication Using Shift and Add, Booth’s Algorithm, Integer Division, Floating-point Representations.
UNIT-III: Computer Arithmetic
Computer Arithmetic: Addition, Subtraction, and Multiplication Algorithms, Divisor Algorithms, Floating Point Arithmetic Operations, Decimal Arithmetic Operations.
UNIT-IV: Input – Output Organization
Input – Output Organization: Peripheral Devices, Input/Output Interface, ALU Asynchronous Data Transfer, Modes of Transfer, Priority Interrupts, Direct Memory Access (DMA), Input/Output Processor (IOP), Serial Communication.
UNIT-V: Evaluation of Microprocessor
Evaluation of Microprocessor: Overview of Intel 8085 to Intel Pentium Processors, Basic Microprocessors, Architecture and Interface, Internal Architecture, External Architecture, Memory, and Input/Output Interface.
UNIT-VI: Assembly Language
Assembly Language: Assembler, Assembly Level Instructions, Macro, Use of Macros in I/O Instructions, Program Loops, Programming Arithmetic and Logic Subroutines, Input-Output Programming.

UNIT-I: Basic Computer Organization and Design

1. Basic Computer Organization and Design

Computer organization refers to the operational units and their interconnections that realize the architectural specifications. It focuses on the hardware components and their arrangement to execute instructions.

2. Instructions and Instruction Codes

Instructions are commands given to a computer to perform specific tasks. Instruction codes are binary representations of these instructions.

    Example:
    Instruction Format:
    Opcode (Operation Code) | Operand(s)
    ADD R1, R2 (Adds contents of R1 and R2)
    Binary Code: 0001 | 0010 | 0011
        

3. Timing and Control / Instruction Cycle

The instruction cycle consists of a series of steps performed to execute an instruction. The main phases are:

    Example:
    Instruction: ADD R1, R2
    Cycle:
    1. Fetch: Retrieve ADD R1, R2
    2. Decode: Identify as addition
    3. Execute: Add contents of R1 and R2
    4. Write Back: Store result in R1
        

4. Registers

Registers are small, high-speed storage locations within the CPU used to store intermediate data and instructions.

5. Register Transfer and Micro Operations

Register transfer involves moving data from one register to another. Micro-operations are low-level operations performed on data stored in registers.

    Example:
    Transfer: R1 ← R2 (Copy content of R2 into R1)
    Micro-Operation: Add R1 + R2 → Result in R3
        

6. Memory and Memory Function

Memory stores data and instructions for processing. It can be classified into primary memory (RAM, ROM) and secondary memory (hard drives, SSDs).

    Example:
    Memory Read: Fetch data from memory.
    Memory Write: Store data into memory.
        

7. Bus and Data Transfer Instructions

A bus is a communication system that transfers data between components of a computer. Data transfer instructions include commands like MOV, LOAD, and STORE.

    Example:
    MOV R1, 1000 (Move data from address 1000 to register R1)
        

8. Arithmetic and Logic Micro-Operations

Arithmetic Micro-Operations: Perform operations like addition, subtraction, multiplication.
Logic Micro-Operations: Perform bitwise operations like AND, OR, NOT.

    Example:
    Arithmetic: R3 ← R1 + R2
    Logic: R1 ← R1 AND R2
        

9. Input/Output and Interrupts

I/O: Facilitates communication between the CPU and external devices.
Interrupts: Signals that divert the CPU to execute an urgent task.

    Example:
    Interrupt Handling: Save current state → Process interrupt → Restore state.
        

10. Memory Reference Instructions

These instructions involve accessing memory locations to fetch or store data.

    Example:
    LDA 2000 (Load data from memory address 2000 into accumulator)
        

11. Memory Interfacing and Cache Memory

Memory Interfacing: Involves connecting memory units to the CPU.
Cache Memory: A high-speed memory that stores frequently accessed data for quick retrieval.

    Example:
    Cache Hit: Data found in cache.
    Cache Miss: Data not in cache, fetched from main memory.
        

UNIT-II: Central Processing Unit

1. General Register Organization

The general register organization refers to the use of multiple registers for efficient data storage and processing within the CPU.

    Example:
    Registers: R1, R2, R3
    Operation: ADD R1, R2 → Store result in R3
        

2. Instruction Formats

Instruction formats define how instructions are represented in memory, including the opcode and operand fields.

    Example:
    Three Address Format:
    ADD R1, R2, R3 → R3 = R1 + R2
        

3. Addressing Modes

Addressing Modes determine how the operand of an instruction is accessed.

    Example:
    Indexed Addressing:
    Instruction: MOV A, [1000 + R1]
    Operand Address: 1000 + Value in R1
        

4. Data Transfer and Manipulation

Data Transfer Instructions: Move data between registers, memory, and I/O devices.
Manipulation Instructions: Perform arithmetic and logic operations.

    Example:
    Data Transfer: MOV R1, R2
    Data Manipulation: ADD R1, R2 → Store result in R1
        

5. Program Control

Program control instructions direct the CPU's operation flow:

6. Reduced Instruction Set Computing (RISC) and Complex Instruction Set Computing (CISC)

RISC: Focuses on simple instructions executed in one clock cycle.
CISC: Includes complex instructions that may take multiple cycles.

    Example:
    RISC: ADD R1, R2
    CISC: ADD R1, [MEM]
        

7. Arithmetic Algorithms

Integer Multiplication: Uses shift-and-add method.
Booth’s Algorithm: Efficient binary multiplication algorithm.
Integer Division: Repeated subtraction or binary division.
Floating-Point Representation: Represents real numbers with a mantissa and exponent.

    Example: Booth’s Algorithm
    Multiplicand: 5 (0101)
    Multiplier: 3 (0011)
    Result: 15
        

8. Pipeline and Vector Processing

Pipeline: Divides instruction execution into stages for parallelism.
Vector Processing: Performs operations on entire data vectors simultaneously.

9. Array Processing

Array processing uses multiple processing units to execute operations on arrays concurrently, enhancing performance for scientific computations.

UNIT-III: Computer Arithmetic

1. Addition Algorithms

Addition algorithms perform binary addition of two numbers. The process involves bitwise addition, handling carry bits as required.

    Example: Binary Addition
    A = 1010 (10 in decimal)
    B = 1101 (13 in decimal)
    Result: 1010 + 1101 = 10111 (23 in decimal)
        

2. Subtraction Algorithms

Subtraction in binary is performed using the concept of two's complement. The complement of the subtrahend is added to the minuend.

    Example: Binary Subtraction
    A = 1010 (10 in decimal)
    B = 0111 (7 in decimal)
    Two's Complement of B = 1001
    Result: 1010 + 1001 = 10011 (Ignore the carry) → 0011 (3 in decimal)
        

3. Multiplication Algorithms

Multiplication algorithms use techniques like shift-and-add to multiply binary numbers. Booth’s algorithm is a popular method for signed binary multiplication.

    Example: Multiplication
    Multiplicand: 5 (0101)
    Multiplier: 3 (0011)
    Result: Shift and Add → 000111 (15 in decimal)
        

4. Division Algorithms

Division algorithms divide one binary number by another using repeated subtraction or long division methods. Restoring and non-restoring division are common approaches.

    Example: Binary Division
    Dividend: 15 (1111)
    Divisor: 3 (0011)
    Quotient: 5 (0101)
    Remainder: 0
        

5. Floating-Point Arithmetic Operations

Floating-point arithmetic represents real numbers using a mantissa and an exponent. Operations include addition, subtraction, multiplication, and division, requiring normalization and alignment of exponents.

    Example:
    Numbers: 1.25 (1.25 × 10^0) and 0.75 (7.5 × 10^-1)
    Align Exponents: 1.25 × 10^0 + 0.075 × 10^0 = 1.325 × 10^0
        

6. Decimal Arithmetic Operations

Decimal arithmetic operations deal with numbers in base-10. They are performed in hardware using Binary Coded Decimal (BCD) representation.

    Example:
    Addition in BCD:
    A = 9 (1001 in BCD)
    B = 8 (1000 in BCD)
    Result: Add → 1001 + 1000 = 10001 (Adjust to valid BCD → 0001 0111, which equals 17 in decimal)
        

UNIT-IV: Input – Output Organization

1. Peripheral Devices

Peripheral devices are external devices connected to a computer for input, output, or storage purposes. Examples include keyboards, printers, monitors, and external drives.

    Examples:
    Input Devices: Keyboard, Mouse, Scanner
    Output Devices: Monitor, Printer, Speaker
    Storage Devices: External Hard Drive, USB Stick
        

2. Input/Output Interface

The input/output interface manages communication between the CPU and peripheral devices. It includes hardware and software components like device controllers and drivers.

    Example:
    CPU ↔ Interface ↔ Peripheral Device
    Data transferred using Input/Output instructions.
        

3. Asynchronous Data Transfer

Asynchronous data transfer occurs when the sending and receiving devices operate independently without a common clock signal. Handshaking signals are often used to synchronize the transfer.

    Example:
    Sender: Sends data and "Data Ready" signal.
    Receiver: Acknowledges with "Data Received" signal.
        

4. Modes of Transfer

Data can be transferred between devices in different modes:

5. Priority Interrupts

Priority interrupts manage multiple interrupt requests by assigning priority levels. Higher-priority interrupts are serviced first.

    Example:
    Interrupt Levels:
    1. Keyboard Input
    2. Printer Error
    3. Timer Overflow
    Priority: 3 > 2 > 1
        

6. Direct Memory Access (DMA)

DMA allows peripherals to transfer data directly to or from memory without CPU involvement, improving efficiency for large data transfers.

    Example:
    Step 1: CPU initiates DMA.
    Step 2: DMA controller handles data transfer.
    Step 3: CPU resumes operation after completion.
        

7. Input/Output Processor (IOP)

An Input/Output Processor (IOP) is a dedicated processor that manages I/O operations, freeing the CPU for other tasks.

    Example:
    CPU ↔ IOP ↔ Peripheral Devices
    IOP independently handles I/O instructions and transfers.
        

8. Serial Communication

Serial communication transfers data one bit at a time over a single communication line. It is commonly used for long-distance communication.

    Example:
    Protocols: RS-232, USB
    Data Flow: Bit-by-bit transfer (e.g., 10101010)
        

UNIT-V: Evaluation of Microprocessor

1. Overview of Intel 8085 to Intel Pentium Processors

The evolution of Intel microprocessors shows advancements in processing power, architecture, and capabilities, starting from the basic 8-bit Intel 8085 to the highly advanced Intel Pentium series.

2. Basic Microprocessors

A microprocessor is a central processing unit (CPU) on a single chip. It performs arithmetic, logic, control, and data processing tasks.

    Example:
    Intel 8085 Features:
    - 8-bit data bus
    - 16-bit address bus
    - 74 instructions
    - Clock speed: 3 MHz
        

3. Microprocessor Architecture and Interface

Microprocessor architecture includes the internal and external design that defines how components interact with each other and with peripherals.

    Example:
    Components of 8086:
    - ALU: Performs arithmetic and logic operations.
    - Registers: General purpose (AX, BX, CX, DX), segment registers (CS, DS, SS, ES).
    - Buses: Address bus, data bus, control bus.
        

4. Internal Architecture

The internal architecture of a microprocessor includes:

5. External Architecture

The external architecture defines how the processor interfaces with memory and I/O devices using buses:

6. Memory and Input/Output Interface

The memory interface connects the microprocessor to RAM/ROM, while the I/O interface connects it to peripheral devices.

    Example:
    - Memory: Address bus for memory location, data bus for data transfer.
    - I/O Interface: Ports for communication (e.g., serial or parallel ports).
        

UNIT-VI: Assembly Language and Programming

1. Assembly Language

Assembly language is a low-level programming language that provides direct control over hardware. It uses mnemonics for instructions and symbolic names for memory locations.

    Example:
    MOV AX, 05H ; Move 5 into register AX
    ADD AX, 03H ; Add 3 to AX
    Result: AX = 08H
        

2. Assembler

An assembler translates assembly language programs into machine code that can be executed by the CPU. It also generates an object file and resolves symbolic references.

    Example:
    Source Code: MOV AX, 5
    Assembler Output: 10111000 00000101 (Binary machine code)
        

3. Assembly Level Instructions

Assembly instructions include:

    Example:
    Instruction: ADD AX, BX
    Operation: Adds contents of BX to AX
        

4. Macros

A macro is a sequence of assembly instructions that can be reused in a program by defining it once and calling it multiple times.

    Example:
    Macro Definition:
    SUM MACRO A, B
        MOV AX, A
        ADD AX, B
    ENDM
    Calling the Macro: SUM 5, 10
        

5. Use of Macros in I/O Instructions

Macros simplify input/output programming by encapsulating repetitive instructions for I/O operations.

    Example:
    Macro Definition:
    PRINT MACRO MESSAGE
        MOV DX, OFFSET MESSAGE
        MOV AH, 09H
        INT 21H
    ENDM
    Usage: PRINT "Hello, World!"
        

6. Program Loops

Loops in assembly language are used for repetitive tasks. Conditional and unconditional jumps control the loop execution.

    Example:
    Loop:
    MOV CX, 5     ; Counter
    Label: DEC CX ; Decrement counter
    JNZ Label     ; Jump if not zero
        

7. Programming Arithmetic and Logic Subroutines

Subroutines encapsulate arithmetic or logic tasks that can be reused. They are called using the CALL instruction and return to the caller with RET.

    Example:
    Subroutine:
    ADD_SUB:
        ADD AX, BX
        SUB AX, CX
        RET
    Main Program:
        CALL ADD_SUB
        

8. Input-Output Programming

I/O programming in assembly involves interfacing with hardware using specific instructions like IN and OUT.

    Example:
    IN AL, DX ; Read input from port DX
    OUT DX, AL ; Send output to port DX