Memory addressing modes define how instructions access data stored in memory or registers. Understanding these modes is crucial for efficient assembly programming.
mov rax, 5 ; Load the immediate value 5 into rax
mov rax, rbx ; Copy the value of rbx into rax
section .data num db 10 ; Define a byte in memory section .text mov al, [num] ; Load the value at memory address 'num' into AL
section .bss buffer resb 4 ; Reserve 4 bytes in memory section .text mov rsi, buffer ; Load the address of 'buffer' into RSI mov byte [rsi], 42 ; Store 42 at the address in RSI
section .data array db 1, 2, 3, 4 ; Define an array section .text mov rsi, array ; Load the base address of 'array' into RSI mov al, [rsi+2] ; Load the third element of the array into AL
Indexed addressing is useful for working with arrays and data structures.