Computer Architecture & Assembly language
UNIT-I: Basic Computer Organization
Basic computer organization and design, Instructions and instruction codes, Timing and control, Register types, Memory function, Bus, Data transfer instructions, Arithmetic logic micro-operations, Input/Output and interrupts, Memory interfacing, Cache memory.
UNIT-II: Central Processing Unit
General Register Organization, Stacks, Instruction formats, Addressing modes, Data transfer and manipulation, Program control, RISC/CISC pipeline, Vector processing, Arithmetic Algorithms: Integer multiplication, Booth’s algorithm, Integer division, Floating-point representations.
UNIT-III: Computer Arithmetic
Addition, subtraction, multiplication algorithms, divisor algorithms, Floating-point arithmetic operations, Decimal arithmetic operations.
UNIT-IV: Input-Output Organization
Peripheral devices, Input/output interface, ALU, Asynchronous Data transfer, Mode of transfer, Priority interrupts, Direct memory Access (DMA), Input/Output processor (IOP), Serial communication.
UNIT-V: Evaluation of Microprocessor
Overview of Intel 8085 to Intel Pentium processors, Basic microprocessors, Architecture and interface, Internal and external architecture, Memory and Input/Output interface.
UNIT-VI: Assembly Language
Assembly language, Assembler, Assembly level instructions, Macros, Use of macros in I/C instructions, Program loops, Programming arithmetic and logic subroutines, Input-Output programming.

UNIT-I: Basic Computer Organization and Design

1. Basic Computer Organization

In computer architecture, the organization of a computer system involves the structure and functionality of its components, such as the central processing unit (CPU), memory, and I/O devices. The main goal of computer organization is to execute instructions effectively.

Basic components of a computer system include:

2. Instructions and Instruction Codes

An instruction is a binary code that tells the computer what operation to perform. The instruction code consists of an operation code (opcode) and operands. The opcode specifies the operation, and operands are the data or addresses involved in the operation.

            Example: 
            Instruction: 10110001
            - Opcode: 1011 (Add)
            - Operand: 0001 (Address)
        

3. Timing and Control / Instruction Cycle

The instruction cycle is the sequence of steps a computer follows to fetch and execute an instruction. It consists of:

  1. Fetch: Retrieve the instruction from memory.
  2. Decode: Decode the instruction to determine the operation.
  3. Execute: Perform the operation as specified by the instruction.

4. Registers: Types and Functions

Registers are small, fast storage locations in the CPU that store data temporarily during execution. The types of registers include:

            Example: 
            Program Counter (PC) - Holds the address of the next instruction to be executed.
            Accumulator (AC) - Holds intermediate results of arithmetic operations.
        

5. Register Transfer and Micro-Operations

Register transfer is the process of moving data between registers. A micro-operation refers to the smallest operation that can be performed on data in the registers.

            Example:
            R1 ← R2 (Transfer contents of register R2 to R1)
            R3 ← R1 + R2 (Perform addition and store result in R3)
        

6. Memory and Memory Functions

Memory in a computer is used to store instructions and data. The two main types of memory are:

Memory functions include reading data from and writing data to memory.

7. Bus/Data Transfer Instructions

A bus is a collection of parallel lines used for transferring data between various components of a computer. Data transfer instructions are used to move data between registers and memory locations.

            Example:
            MOV A, B   ; Move data from register B to A
            ADD A, C   ; Add contents of register C to A
        

8. Arithmetic and Logic Micro-Operations

Arithmetic micro-operations include basic operations such as addition and subtraction, while logic micro-operations include operations such as AND, OR, and NOT.

            Example:
            ADD:  R1 ← R1 + R2
            AND:  R1 ← R1 AND R2
        

9. Input/Output and Interrupts

Input/Output operations involve communication between the computer and external devices. Interrupts allow devices to send signals to the CPU to indicate an event, prompting the CPU to interrupt its current task and handle the event.

            Example:
            - Interrupt Request (IRQ) for an I/O device.
            - Interrupt Service Routine (ISR) handles the request.
        

10. Memory Reference Instructions

Memory reference instructions are used to move data between memory and registers or perform operations on memory data.

            Example:
            LOAD A, M     ; Load data from memory location M into register A
            STORE A, M    ; Store data from register A into memory location M
        

11. Memory Interfacing and Cache Memory

Memory interfacing involves connecting the memory to the CPU using buses. Cache memory is a small, high-speed memory that stores frequently accessed data to speed up processing.

Cache Memory: A small but fast memory located between the CPU and RAM. It stores frequently used instructions and data to reduce access time.

UNIT-II: Central Processing Unit and Arithmetic Algorithms

1. Central Processing Unit (CPU)

The Central Processing Unit (CPU) is the heart of a computer system. It is responsible for executing instructions and performing operations on data. The CPU is composed of various units that work together to execute programs.

2. General Register Organization

The general register organization of a CPU involves a set of registers that can be used for storing data during execution. These registers can be used for various operations, such as storing intermediate results, addressing memory, and controlling the flow of execution.

            Example: 
            - R1, R2, R3 are general purpose registers in the CPU.
            - R1 ← R2 + R3 (Addition operation between R2 and R3, storing the result in R1).
        

3. Stack Organization

Stack organization refers to the use of a stack data structure to manage data in a last-in-first-out (LIFO) order. It is commonly used for function calls, interrupt handling, and storing return addresses.

            Example:
            PUSH A    ; Push the value of register A onto the stack.
            POP B     ; Pop the top value from the stack and store it in register B.
        

4. Instruction Formats

Instruction formats define the layout of bits in an instruction. They typically include fields for the opcode (operation code), operands, and sometimes additional fields for addressing modes or control information.

            Example:
            Instruction Format: [Opcode | Operand 1 | Operand 2]
            - Opcode: 0001 (Addition)
            - Operand 1: R1 (First operand)
            - Operand 2: R2 (Second operand)
        

5. Addressing Modes

Addressing modes define how the operand of an instruction is located in memory. Common addressing modes include:

6. Data Transfer and Manipulation

Data transfer and manipulation involve moving data between registers, memory, and I/O devices, and performing operations like addition, subtraction, etc., on the data. Examples include:

            MOV A, B   ; Transfer data from register B to register A.
            ADD A, C   ; Add contents of register C to register A.
        

7. Program Control

Program control refers to mechanisms that control the execution flow of a program. This includes branching instructions (such as jumps, calls, and returns) and conditional statements.

            Example:
            JUMP 1000   ; Jump to memory address 1000.
            CALL FUNC   ; Call function FUNC.
            RETURN      ; Return from function.
        

8. Reduced Computer: RISC and CISC

RISC (Reduced Instruction Set Computer) and CISC (Complex Instruction Set Computer) are two types of CPU architectures. RISC processors have a smaller set of simple instructions, while CISC processors have a larger, more complex set of instructions.

9. Pipeline Processing

Pipeline processing allows for overlapping instruction execution by breaking down the execution process into stages. This helps improve the throughput of the CPU by enabling multiple instructions to be processed simultaneously.

            Example: 
            - Stage 1: Fetch instruction
            - Stage 2: Decode instruction
            - Stage 3: Execute instruction
            - Stage 4: Write back result
        

10. Vector Processing and Array Processing

Vector processing involves the simultaneous processing of multiple data elements, often used in scientific computations. Array processing refers to operations on arrays of data elements in parallel.

            Example: 
            - Vector addition: A[i] = B[i] + C[i] (Perform addition on multiple elements of arrays simultaneously).
        

11. Arithmetic Algorithms

Arithmetic algorithms are essential for performing mathematical operations like multiplication, division, and handling floating-point numbers. Key algorithms include:

UNIT-III: Computer Arithmetic

1. Computer Arithmetic

Computer arithmetic involves algorithms and techniques for performing arithmetic operations on binary numbers. These operations include addition, subtraction, multiplication, division, and floating-point operations. Efficient algorithms are designed to perform these operations quickly and accurately on a computer system.

2. Addition Algorithm

In binary arithmetic, addition is performed using a carry bit. The algorithm adds corresponding bits of two numbers, taking into account the carry from previous additions.

            Example:
            Binary Addition of 1101 and 1011:
            1101
          + 1011
            -----
            11000
        

3. Subtraction Algorithm

Binary subtraction can be performed using two's complement. The algorithm involves inverting the bits of the subtrahend and adding one, followed by performing binary addition.

            Example:
            Binary Subtraction of 1101 and 1011:
            1101
          - 1011
            -----
            0010 (Using Two’s complement)
        

4. Multiplication Algorithm

Binary multiplication uses the shift-and-add method, where one number is shifted and added depending on the bits of the other number. The algorithm can be optimized using methods like Booth's algorithm.

            Example:
            Binary Multiplication of 101 (5) and 11 (3):
            101
          x  11
            -----
            101
          +1010
            -----
            1111 (5 * 3 = 15)
        

5. Divisor Algorithms

Division algorithms are designed to divide one binary number by another. Division is often more complex than multiplication, and algorithms like restoring division or non-restoring division are used to efficiently handle division of binary numbers.

            Example:
            Restoring Division:
            1101 ÷ 101 = 11 (quotient), 00 (remainder)
        

6. Floating Point Arithmetic Operations

Floating-point arithmetic operations are used to perform calculations with real numbers. A floating-point number is represented in scientific notation, consisting of a sign bit, exponent, and mantissa. Operations like addition, subtraction, multiplication, and division follow specific algorithms to handle precision and rounding issues.

IEEE 754 is a widely accepted standard for representing floating-point numbers, which defines formats like single precision (32-bit) and double precision (64-bit).

            Example:
            Floating-point Addition of 1.5 and 2.75:
            1.5 = 1.1 * 2^0 (Binary representation)
            2.75 = 1.11 * 2^1
            The addition involves aligning the exponents and adding the mantissas.
        

7. Decimal Arithmetic Operations

Decimal arithmetic operations involve performing arithmetic operations on decimal numbers (base 10) rather than binary numbers. The algorithms used for decimal arithmetic are similar to those used for binary arithmetic, but they work in base 10.

            Example:
            Decimal Addition of 25 and 37:
            25
          + 37
            -----
            62
        

8. Decimal Arithmetic Algorithms

Decimal arithmetic can be performed using similar algorithms as binary arithmetic. However, in decimal arithmetic, the carry in addition and the borrow in subtraction are based on base 10, not base 2.

            Example:
            Decimal Subtraction of 45 from 90:
            90
          - 45
            -----
            45
        

UNIT-IV: Input – Output Organization

1. Peripheral Devices

Peripheral devices are external devices connected to the computer system to provide input or output functions. These include input devices like keyboards, mice, and scanners, and output devices like monitors and printers.

There are two main types of peripheral devices:

2. Input/Output Interface

The input/output interface is a communication link between the computer’s processor and peripheral devices. It manages data transfer, timing, and protocols to ensure that data is sent and received correctly from peripherals.

Common I/O interfaces include:

3. ALU Asynchronous Data Transfer

Asynchronous data transfer occurs when data is transferred without synchronization between the sender and receiver. The sending device transmits data whenever it’s ready, and the receiving device checks for data at its convenience.

This can lead to data transfer issues like data loss or overflow, which are mitigated through mechanisms like buffering and error handling protocols.

4. Modes of Transfer

There are several modes of data transfer between the processor and peripheral devices:

5. Priority Interrupts

Interrupts are signals sent by hardware or software to get the CPU’s attention. Priority interrupts are used when multiple devices request CPU attention simultaneously. Devices with higher priority interrupts are serviced first.

Priority schemes include:

Priority interrupts ensure that critical tasks are handled first, improving the efficiency of multi-device systems.

6. Direct Memory Access (DMA)

DMA is a method used to transfer data directly between a peripheral device and system memory, bypassing the CPU. This improves data transfer efficiency and reduces CPU load.

The basic steps involved in DMA are:

  1. The CPU initiates the DMA operation by setting up the DMA controller.
  2. The peripheral device sends the data directly to the memory, with no CPU intervention.
  3. The CPU is notified when the transfer is complete and can process the data.

7. Input/Output Processor (IOP)

The I/O Processor (IOP) is a dedicated processor designed to handle I/O operations, offloading work from the main CPU. The IOP manages the communication between the computer system and its peripherals, improving the efficiency of I/O operations.

Some key functions of the IOP include:

8. Serial Communication

Serial communication refers to the transmission of data one bit at a time over a single communication line. It is commonly used for long-distance communication and requires less hardware than parallel communication.

Serial communication standards include:

UNIT-V: Evaluation of Microprocessor

1. Overview of Intel 8085 to Intel Pentium Processors

Microprocessors are the heart of any computer system, and the evolution of these processors has significantly improved computing power. Let's look at the evolution from Intel 8085 to Intel Pentium processors:

2. Basic Microprocessors

A microprocessor is a central processing unit (CPU) integrated onto a single chip. The basic functions of a microprocessor include fetching, decoding, and executing instructions. It performs arithmetic and logic operations, controls data transfer, and manages input/output operations. Microprocessors can be categorized as:

3. Architecture and Interface

The architecture of microprocessors refers to the internal design and components that allow the processor to perform operations. Here's a brief overview of the architecture for early microprocessors like Intel 8085 and Intel Pentium:

Intel 8085 Architecture:

Intel Pentium Architecture:

4. Internal Architecture

Internal architecture refers to the design of the microprocessor's internal components. This includes the ALU, registers, buses, and control units that perform data processing and memory management.

Intel 8085 Internal Architecture:

Intel Pentium Internal Architecture:

5. External Architecture

External architecture refers to how the microprocessor interfaces with external devices, including memory, I/O devices, and buses.

Intel 8085 External Architecture:

Intel Pentium External Architecture:

6. Memory and Input/Output Interface

The interface between the microprocessor and memory, along with the I/O system, determines the efficiency of data transfers and system performance. For Intel 8085, this involved a simple I/O and memory interfacing using basic control signals, while Intel Pentium has more advanced I/O and memory control mechanisms.

UNIT-VI: Assembly Language & Assembly Level Programming

1. Assembly Language

Assembly language is a low-level programming language that is designed to interact directly with the hardware. It provides a way to write instructions that the microprocessor can understand using human-readable mnemonics. Unlike high-level languages like C or Python, assembly language works closely with the underlying hardware architecture, giving programmers precise control over system resources.

Assembly language consists of basic instructions and operations that the microprocessor executes. Each instruction in assembly corresponds directly to a machine code instruction.

2. Assembler

An assembler is a software tool that converts assembly language programs into machine code (binary code) that the processor can execute. It translates each assembly instruction into an equivalent machine instruction based on the processor's instruction set architecture (ISA).

Assemblers can be categorized into:

In addition to converting assembly code to machine code, assemblers can perform optimizations such as removing redundant instructions and improving performance.

3. Assembly Level Instructions

Assembly level instructions are the commands in assembly language that correspond directly to machine operations. These instructions operate on registers, memory, and the arithmetic logic unit (ALU). Common types of assembly instructions include:

4. Macros

A macro is a sequence of instructions that can be defined and reused in assembly programs. Macros help in reducing the length of the program, improving code readability, and making maintenance easier. Instead of writing the same instructions repeatedly, a macro is defined once and invoked multiple times.

Macros are typically used to encapsulate frequently used code segments, such as loops or arithmetic operations. They are expanded at assembly time into the actual machine instructions.

Example of defining a macro:

MACRO ADDITION ADD A, B MOV C, A ENDM

In this example, the macro

ADDITION
adds the values in registers A and B and stores the result in register C. The macro can be invoked anywhere in the program by simply writing
ADDITION
.

5. Use of Macros in I/O Instructions

Macros can be especially useful in handling I/O instructions. For example, when performing I/O operations such as reading from or writing to a port, macros can abstract the details of the operation, making the program easier to read and maintain.

Example macro for reading from an input port:

MACRO READ_PORT IN 0x00 ; Read from port 0x00 MOV A, L ; Store the value in register L ENDM

This macro reads from a specified port address and stores the result in register L. The macro can be reused throughout the program whenever this operation is required.

6. Program Loops

Loops are essential for repetitive tasks in assembly language. A loop allows a set of instructions to be executed repeatedly until a specific condition is met. Commonly used loop structures include

FOR
,
WHILE
, and
DO-WHILE
.

Example of a simple loop in assembly language that adds numbers:

MOV CX, 10 ; Set the loop counter to 10 MOV AX, 0 ; Clear AX register to accumulate sum LOOP_START: ADD AX, BX ; Add BX to AX DEC CX ; Decrement loop counter JNZ LOOP_START ; Jump if CX is not zero

In this example, the loop will execute 10 times, adding the value in register BX to AX, and the loop counter (CX) is decremented each time.

7. Programming Arithmetic and Logic Subroutines

Subroutines are reusable blocks of code that perform specific tasks, such as arithmetic or logical operations. Subroutines allow for better code organization and reusability.

Example of an addition subroutine:

ADDITION_SUBROUTINE: ADD A, B ; Add A and B RET ; Return from the subroutine

This subroutine adds the values of registers A and B and then returns to the calling point.

8. Input/Output Programming

In assembly language, input/output programming is essential for interacting with external devices like keyboards, monitors, and sensors. I/O instructions allow a program to read data from input devices or send data to output devices.

Example of reading input from the keyboard and printing it to the screen:

MOV AH, 1 ; BIOS function to read a character from the keyboard INT 21h ; Interrupt to execute the function MOV DL, AL ; Move the character to DL for display MOV AH, 2 ; BIOS function to display a character INT 21h ; Interrupt to execute the function

This example demonstrates how to use the BIOS interrupt

INT 21h
to read a character from the keyboard and display it on the screen.