Declaring Pointers for Different Addressing Types

Learn how pointers are used to address memory cells and registers, as well as addressing different memory granularity in assembly language.

Pointers revisited

The pointer is a memory cell or a register that contains the address of another memory cell. Memory pointers have their own addresses because they are memory cells too. In 3232-bit Linux, pointers are 3232-bit, and in 6464-bit Linux, pointers are 6464-bit.

Addressing types

Memory cells can contain one byte, halfword, word, or doubleword. Therefore, a pointer can point to a byte, a halfword, a word, a doubleword, or a quadword. GDB disassembly output displays the suffix l in instructions involving pointers to 3232-bit (doubleword size) values.

Here are some illustrated examples:

movb $0xFF, (%rax)

The layout of memory before the movb instruction execution is shown in the figure below:

Get hands-on with 1400+ tech skills courses.