Introduction to Microprocessor and Assembly Language Programming

 Introduction to Microprocessor:

A microprocessor is a central processing unit (CPU) fabricated on a single integrated circuit (IC)

or chip. It serves as the brain of a computer system, executing instructions and performing

arithmetic and logical operations on data. Microprocessors are essential components in various

electronic devices, including computers, smartphones, embedded systems, and control systems.


Key components of a microprocessor include:

• Control Unit (CU): Manages the execution of instructions, fetches instructions from

memory, decodes them, and coordinates data movement within the processor.

Arithmetic Logic Unit (ALU): Performs arithmetic and logical operations such as

addition, subtraction, AND, OR, and NOT.

Registers: Small, high-speed storage locations within the processor used to store data

temporarily during processing. Examples include the accumulator, general-purpose

registers, and program counter.

Instruction Set Architecture (ISA): Defines the set of instructions a microprocessor can

execute and the format in which they are encoded.

• Clock: Provides timing signals to synchronize the operations of the microprocessor.


Assembly Language Programming:

Assembly language is a low-level programming language that closely corresponds to the machine

language instructions of a specific processor architecture. Each instruction in assembly language

directly corresponds to one machine language instruction. Unlike high-level languages such as

C++ or Java, assembly language is not portable across different processor architectures.

Benefits of assembly language programming include:

• Efficiency: Assembly language allows programmers to write code that directly

manipulates hardware resources, leading to highly optimized and efficient programs.

• Low-Level Control: Programmers have precise control over memory usage, register

allocation, and instruction execution, making it suitable for writing device drivers,

operating system kernels (An operating system is a complete software package that

includes a kernel and other system-level components such as device drivers, system

libraries, and utilities. The kernel, on the other hand, is the core of the operating system

that manages system resources, such as the CPU, memory, and I/O devices), and embedded

systems.

• Understanding of Computer Architecture: Writing programs in assembly language

provides insights into the internal workings of a microprocessor and helps in understanding

computer architecture concepts.


• Real-Time Systems: Assembly language is often used in real-time systems where precise

timing and low-level control are crucial.


However, assembly language programming also has drawbacks, including:

• Complexity: Assembly language programming is more complex and error-prone

compared to high-level languages due to the need to manage low-level details.

• Platform Dependency: Programs written in assembly language are specific to a particular

processor architecture and may not be portable across different platforms.

• Development Time: Writing programs in assembly language typically requires more

development time and effort compared to high-level languages.

Overall, assembly language programming is a powerful tool for developers who require maximum

control over hardware resources and performance optimizations but may not be suitable for

general-purpose application development due to its complexity and platform dependency.


8086 microprocessor Block diagram

The 8086 microprocessor is a 16-bit microprocessor designed by Intel in the late 1970s. Here's a

simplified internal block diagram of the 8086 microprocessors:

1. Bus Interface Unit (BIU):

• Address Bus (16 bits): Used to address memory and I/O devices.

• Data Bus (16 bits): Used to transfer data between the microprocessor and memory or

I/O devices.

• Control Bus: Signals for control purposes, such as read, write, interrupt, and status

signals.

2. Execution Unit (EU):

• Instruction Queue: Holds instructions fetched from memory by the BIU.

• Instruction Decoder: Decodes the instructions fetched from memory and generates the

appropriate control signals.

• Arithmetic Logic Unit (ALU): Performs arithmetic and logical operations on data.

• General-Purpose Registers: Accumulator (AX), Base (BX), Counter (CX), Data

(DX), Stack Pointer (SP), and Base Pointer (BP).

• Index Registers: Source Index (SI) and Destination Index (DI).

• Segment Registers: Code Segment (CS), Data Segment (DS), Extra Segment (ES),

and Stack Segment (SS).

• Instruction Pointer (IP): Points to the memory location of the next instruction to be

executed.

3. Segmentation Unit:

• Performs segmentation of memory addresses to access different segments such as

code, data, stack, and extra data segments.


4. Control Unit:

• Controls the operation of the microprocessor by generating control signals based on

the instruction being executed.

• Controls the flow of data and instructions between different units of the

microprocessor.

5. Clock Generator:

• Generates clock signals to synchronize the operation of different units of the

microprocessor.

6. Address Generation Unit (AGU):

• Calculates effective addresses for memory operands during the execution of

instructions.

7. Interrupt Controller:

• Manages interrupts from external devices and prioritizes them for processing by the

microprocessor.


This block diagram provides a simplified overview of the internal structure of the 8086

microprocessors. In reality, the microprocessor contains many more components and registers

that contribute to its functionality and performance.






Figure. Block Diagram of 8086 microprocessor.


Note: All registers are of size 16-bits


Different registers and their operations are listed below:

Register Uses/Operations

AX As accumulator in Word multiply & Word divide operations, Word I/O


operations


AL As accumulator in Byte Multiply, Byte Divide, Byte I/O, translate,


Decimal Arithmetic.

AH Byte Multiply, Byte Divide


BX As Base register to hold the address of memory

CX String Operations, as counter in Loops

CL As counter in Variable Shift and Rotate operations

DX Word Multiply, word Divide, Indirect I/O



Execution of Instructions in 8086:

The microprocessor sends OUT a 20-bit physical address to the memory and fetches the first

instruction of a program from the memory. Subsequent addresses are sent OUT and the queue is

filled up to 6 bytes. The instructions are decoded and further data (if necessary) are fetched from

memory. After the execution of the instruction, the results may go back to memory or to the output

peripheral devices as the case may be.



Programming Models:
Depending on the size of the memory the user program occupies, different types of assembly
language models are defined.
TINY: All data and code in one segment
SMALL: one data segment and one code segment
MEDIUM: one data segment and two or more code segments
COMPACT: one code segment and two or more data segments
LARGE: any number of data and code segments
To designate a model, we use “.MODEL” directive.




The MODEL directive selects a standard memory model for the assembly language program.
A memory model may be thought of a standard blue print or configuration, which determines the
way segments are linked together. Each memory model has a different set of restrictions as to the
maximum space available for code and data. But the most important thing to know about model is
that they affect the way that subroutines and data may be reached by program.
This table summarizes the different types of models.
Model Description (Memory Size)
Tiny Code and Data combined

must be <=64K

Small Code <=64K; Data<=64K
Medium Data<=64K; Code any size
Compact Code<=64K; Data any size
Large Both code and data may

be>64K

Huge

same as the large model,
except those arrays
may be Large than 64k

A program running under DOS is divided into 3 primary segments (point to by CS) contains
program code; the data segment (pointed to by DS) contains the program variables, the stack
segment (pointed to by SS) contains the program stack.
" .DATA" directive (line 2) indicates the start of the data segment. It contains the program
variables.
" .CODE" directive (line k) indicates the start of the code segment. The end directive
(line n) indicates the end of the program file.


Post a Comment

0 Comments