1.0 Foundational Concepts of Assembly Language
1.1 Definition and Role
Assembly language is a low-level programming language designed for a specific family of processors. It acts as a more understandable bridge between high-level languages and the raw binary machine code that a processor directly executes.
- Machine Language: Processors understand only machine language, which consists of strings of 1s and 0s. This format is too obscure and complex for direct software development.
- Assembly Language: Represents machine language instructions using symbolic codes (mnemonics) and a more readable syntax, making it possible to program at the hardware level with greater clarity.
1.2 Key Advantages
Utilizing assembly language provides several distinct advantages, particularly in performance-critical and hardware-centric applications.
- System Awareness: It fosters a deep understanding of how programs interface with the Operating System (OS), processor, and BIOS; how the processor accesses and executes instructions; and how a program interacts with external devices.
- Performance: Assembly programs require less memory and have a shorter execution time compared to those written in high-level languages.
- Hardware Control: It allows for direct and precise manipulation of hardware, making it suitable for hardware-specific, time-critical tasks, interrupt service routines, and memory-resident programs.
1.3 Core PC Hardware and Data Representation
Effective assembly programming is built upon an understanding of the primary internal hardware and how data is represented.
- Core Components: The main hardware of a PC consists of the processor, memory, and registers (internal processor components for holding data and addresses). A program is copied from an external device to internal memory to be executed by the processor.
- Fundamental Unit: The bit is the basic unit of storage (ON/1 or OFF/0). A group of 8 bits forms a byte.
- Data Sizes: The processor supports various data sizes: | Name | Size | | :— | :— | | Word | 2 bytes (16 bits) | | Doubleword | 4 bytes (32 bits) | | Quadword | 8 bytes (64 bits) | | Paragraph | 16 bytes (128 bits)| | Kilobyte | 1,024 bytes | | Megabyte | 1,048,576 bytes |
- Byte Ordering: The processor stores data in a reverse-byte sequence (little-endian), where the low-order byte is stored at a low memory address and the high-order byte at a high memory address.
1.4 Number Systems and Arithmetic
- Binary System: A base-2 system using positional notation. The value of an 8-bit number with all bits set to 1 is 255 (2⁸ – 1).
- Hexadecimal System: A base-16 system used to abbreviate long binary representations. Digits are 0-9 and A-F. Each hexadecimal digit corresponds to a 4-bit binary sequence.
- Binary Arithmetic: Negative binary numbers are expressed using two’s complement notation. To get the negative value of a number, its bits are reversed and 1 is added. Subtraction is performed by converting the subtrahend to its two’s complement form and then adding it to the minuend.