4.2 Memory allocation
A program can allocate memory from any section/segment and initialize the memory locations at the same time. This is
quite useful for initialized variables in a program.
The following is a summary of the main types of memory allocation and initialization directives:
- .int <v1>{, <v>}*
This notation means that the .int directive has one or more integer values, separated by commas. The curly
braces {} is a grouping mechanism, while the asterisk * means any number of the previous item. Each value of
an .int directive is encoded as a 32-bit integer.
- .word <v1>{, <v>}*
Similar to .int, except each value is encoded as a 16-bit (word) integer.
- .byte <v1>{, <v>}*
Similar to .int, except each value is encoded as a 8-bit (byte) integer.
- .fill <count>[, <size>[, <value]]
.fill lets you specify a flexible repeating pattern. <count> specifies how many items. <size> specifies the
number of bytes used by each item, and <value> is the value of each item. In the absence of <value>, 0 is
assumed. In the absence of <size>, 1 is assumed.
- .ascii <string>
.ascii allocates and initializes memory locations for a string, represented in ASCII (one byte per character).
A string is quoted by the single quote symbol.
- asciz <string>
.asciz is similar to ascii, except a trailing byte of 0 is included for a null-terminated string.