0% found this document useful (0 votes)
8 views

Assignment Assembly Language

Assignment

Uploaded by

Amina Arshad
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Assignment Assembly Language

Assignment

Uploaded by

Amina Arshad
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Overview of Assembly Language

What is Assembly Language?


 A low-level programming language that translates directly into
machine code.
 Provides control over hardware, often used in system programming,
device drivers, and embedded systems.

Key Features
 Mnemonics: Human-readable instructions like MOV, ADD, and SUB.
 Registers: Small, fast storage locations directly accessed by the CPU.
 Platform-Specific: Each processor family (x86, ARM, etc.) has its own
assembly language.

Advantages.
 Fine-grained control over hardware.
 High performance.
 Compact code.

Disadvantages
 Steep learning curve.
 Prone to errors.
 Not portable between processor architectures.

Basic Components
1. Instructions: Perform operations (e.g., ADD, SUB).
2. Registers: Temporarily store data (e.g., AX, BX for x86).
3. Memory Addresses: Locations in RAM to store/retrieve data.
Assembly Language Basics
Structure of an Assembly Program
1. Data Section: Declare variables.
2. Text Section: Write instructions.
.text BSS Section: Define uninitialized variables.

Common Instructions
Instructio
n Description

MOV Transfers data between registers

ADD Adds two values

Subtracts one value from


SUB another

CMP Compares two values

JMP Jumps to a specific instruction

Registers (x86 Example)


Register Purpose

AX Accumulator for arithmetic ops

BX Base register

CX Counter for loops

DX Data register
Sample Code and Explanation
Hello, World Program (x86 Assembly)
Explanation
1. Data Section:
 msg db 'Hello, World!', 0 : Defines the message.
2. Text Section:
 Sets up the system call to print the message.
 Uses int 0x80 to invoke the kernel for system calls.
3. Registers:
 edx: Length of the message.
 ecx: Address of the message.

Advanced Topics and Applications


Macros and Procedures
 Macros: Reusable code blocks.
 Procedures: Functions in assembly.

Applications
1. Operating Systems: Writing kernels.
2. Embedded Systems: Interfacing directly with hardware.
3. Performance Optimization: Critical sections of code.

Debugging and Tools


 Debuggers: Tools like GDB and ndisasm.
 Assemblers: Convert assembly code into machine code (e.g., NASM,
MASM).

You might also like