Data structures in assembly language, as in high-level languages, are nested structures composed of references, structs, and arrays. These structures are often dynamically allocated, which gives programs the capability of adjusting their memory usage to the immediate needs.

A data item that is used in several places in a program can exist as multiple copies, or a single copy can be referenced from different places. References are useful for data that will be updated frequently - only one copy needs to be updated.

References are widely used in natural languages and are supported in many ways in high-level programming languages. In assembly languages, the basic reference mechanism is the memory address, which is the mechanism behind pointers in high-level languages.

A computer can enhance this mechanism by defining addressing modes. For many RISC processors, the only memory addressing modes are base-displacement and direct addressing. The first specifies an address by adding a displacement that is coded into the instruction to the contents of a base register. Direct addressing is a simpler form in which the displacement is 0.

High-Level Language Structs

In high-level languages, structs, also known as records and objects, have the following characteristics.

In assembly language, structs are handled as follows.

High-Level Language Arrays

In high-level languages, array have the following characteristics.

In assembly language, arrays are handled as follows.

Data structures can be nested in two ways directly and indirectly. With direct nesting, the entire inner structure is contained in the outer structure. With indirect nesting, the outer structure only contains a reference to the inner structure.

    int A[][] = {
        { 0, 1, 2 },
        { 3, 4, 5 }
    int* A[] = {
        { 0, 1, 2 },
        { 3, 4, 5 }
    int[] A = {
        new int[] { 0, 1, 2 },
        new int[] { 3, 4, 5 }

In assembly language, data structures can be nested either directly or indirectly. For direct nesting, the entire inner structure is included in the outer structure. Direct nesting is usually only done for multidimensional arrays. For indirect nesting, the address of the inner structure is included in the outer structure.

Data access in the inner structure is just like data access in a statically declared structure except that a load instruction is used instead of a load address instruction to get the base address into a register.

Allocating a struct or array dynamically (at run time) requires an operating system call. The system call code depends on the operating system.