Assembly Language Fundamentals: Registers, Operands, and Data Types
Assembly Language Fundamentals: Key Concepts and Definitions
1. Clock Frequency and Cycle Time
A clock that oscillates 1 million times per second (1 MHz) produces a clock cycle duration of $10^{-6}$ seconds (1 microsecond).
2. General-Purpose Registers (8-bit, 16-bit, and 32-bit Access)
The general-purpose registers that can be accessed in 8 bits, 16 bits, and 32 bits are: EAX, EBX, ECX, and EDX.
3. Purpose of EAX and ECX Registers
These registers serve specific roles in CPU operations:
- EAX – Accumulator: Automatically used by multiplication and division instructions. It is often referred to as the extended accumulator register.
- ECX – Loop Counter: The CPU automatically uses ECX as a counter for loop instructions.
4. Reserved Words and Identifiers in Assembly
Examples illustrating the difference between reserved keywords and user-defined identifiers:
- Reserved Words:
MOV,ADD, andMUL(Instructions defined by the language). - Identifiers:
lineCount,firstValue(User-defined variables or labels).
5. Examples of Instructions by Operand Count
Assembly instructions can be classified based on the number of operands they require:
- No Operand: The
STCinstruction, for example, has no operands:stc ; set Carry flag - One Operand: The
INCinstruction has one operand:inc eax ; add 1 to EAX - Two Operands: The
MOVinstruction has two operands (destination, source):mov count, ebx ; move EBX (source operand) to count (destination operand)
6. Comparing Array Elements
Do the following two arrays contain the same elements?
list1 BYTE 10, 22, 41h, 00000010b
list2 BYTE 0Ah, 20h, 'A', 22hNo. The arrays do not contain the same elements. A comparison of the byte values shows:
| Index | list1 Value (Decimal) | list2 Value (Decimal) |
|---|---|---|
| 1 | 10 (0Ah) | 10 (0Ah) |
| 2 | 22 (16h) | 32 (20h) |
| 3 | 65 (41h) | 65 ('A' = 41h) |
| 4 | 2 (00000010b) | 34 (22h) |
7. Correcting an Assembly Program for 32-bit Addition
The following program adds two 32-bit integers (5 and 6) using the EAX register and ensures a clean exit. The structure below represents the standard corrected format for this task:
.386
.model flat, stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.code
main PROC
mov eax, 5 ; Load the first 32-bit integer into EAX
add eax, 6 ; Add the second 32-bit integer to EAX
INVOKE ExitProcess, 0 ; Terminate the program successfully
main ENDP
END main8. Converting Decimal to IEEE Single Precision Floating Point
Conversion of $(13.25)_{10}$
The process involves converting the number to binary, normalizing it, determining the biased exponent, and assembling the 32-bit representation (Sign, Exponent, Mantissa).
The final IEEE Single Precision floating-point binary number is:
0 10000010 10101000000000000000000- Sign Bit (S): 0 (Positive)
- Exponent (E): 10000010 (Biased exponent)
- Mantissa (M): 10101000000000000000000
9. Calculating Array Size Using the Current Location Counter ($)
To calculate the size of the list array, which contains 32-bit double words (DWORDs), the Current Location Counter ($) is used to find the address difference, which is then divided by the size of the element (4 bytes).
list DWORD 10000000h, 20000000h, 30000000h, 40000000h
ListSize = ($ - list) / 410. Ranges of Unsigned and Signed Words
The following table details the storage ranges for signed and unsigned byte and word data types:
| Storage Type | Range (Low–High) | Number of Bits | Powers of 2 Representation |
|---|---|---|---|
| Signed Byte | -128 to +127 | 8 | $-2^7$ to $(2^7 - 1)$ |
| Signed Word | -32,768 to +32,767 | 16 | $-2^{15}$ to $(2^{15} - 1)$ |
| Unsigned Byte | 0 – 255 | 8 | 0 to $(2^8 - 1)$ |
| Unsigned Word | 0 – 65,535 | 16 | 0 to $(2^{16} - 1)$ |
English with a size of 4.73 KB