Chapter 4: Addressing Modes
### 4.1 Introduction
Addressing modes in assembly language define how operands are specified in instructions. They play a pivotal role in determining the effective address used to access data in memory. This chapter explores various addressing modes, providing insights into their types and applications.
### 4.2 Immediate Addressing Mode
#### 4.2.1 Definition
- **Immediate Addressing:**
- Operand is a constant value specified in the instruction.
#### 4.2.2 Example
```assembly
mov eax, 42 ; Move the immediate value 42 into register eax
```
### 4.3 Register Addressing Mode
#### 4.3.1 Definition
- **Register Addressing:**
- Operand is located in a register.
#### 4.3.2 Example
```assembly
mov ebx, eax ; Move the value in register eax to register ebx
```
### 4.4 Direct Addressing Mode
#### 4.4.1 Definition
- **Direct Addressing:**
- Operand is located at a specific memory address.
#### 4.4.2 Example
```assembly
mov eax, [variable] ; Move the value stored at the memory address 'variable' into register eax
```
### 4.5 Indirect Addressing Mode
#### 4.5.1 Definition
- **Indirect Addressing:**
- Operand is located at the address stored in another register or memory location.
#### 4.5.2 Example
```assembly
mov eax, [ebx] ; Move the value stored at the memory address in register ebx into register eax
```
### 4.6 Indexed Addressing Mode
#### 4.6.1 Definition
- **Indexed Addressing:**
- Operand is located at the sum of a register and a constant (index).
#### 4.6.2 Example
```assembly
mov eax, [ebx + 4] ; Move the value stored at the memory address (ebx + 4) into register eax
```
### 4.7 Base-Register Addressing Mode
#### 4.7.1 Definition
- **Base-Register Addressing:**
- Operand is located at the sum of a base register and an index register.
#### 4.7.2 Example
```assembly
mov eax, [ebx + ecx] ; Move the value stored at the memory address (ebx + ecx) into register eax
```
### 4.8 Scaled-Indexed Addressing Mode
#### 4.8.1 Definition
- **Scaled-Indexed Addressing:**
- Similar to indexed addressing but allows scaling the index.
#### 4.8.2 Example
```assembly
mov eax, [ebx + 2*ecx] ; Move the value stored at the memory address (ebx + 2*ecx) into register eax
```
### 4.9 Relative Addressing Mode
#### 4.9.1 Definition
- **Relative Addressing:**
- Addresses are expressed as offsets from the current instruction.
#### 4.9.2 Example
```assembly
jmp short target_label ; Jump to a label specified by a short offset
```
### 4.10 Conclusion
Addressing modes provide flexibility in specifying operands, allowing assembly language programmers to access and manipulate data in various ways. Understanding the different addressing modes is crucial for effective programming and efficient use of system resources.

Comments
Post a Comment