4.4: Data Section
- Page ID
- 19879
The initialized data must be declared in the "section .data" section. There must be a space after the word 'section'. All initialized variables and constants are placed in this section. Variable names must start with a letter, followed by letters or numbers, including some special characters (such as the underscore, "_"). Variable definitions must include the name, the data type, and the initial value for the variable.
The general format is:
<variableName> <dataType> <initialValue>
Refer to the following sections for a series of examples using various data types. The supported data types are as follows:
Declaration | |
db | 8-bit variable(s) |
dw | 16-bit variable(s) |
dd | 32-bit variable(s) |
dq | 64-bit variable(s) |
ddq | 128-bit variable(s) \(\to\) integer |
dt | 128-bit variable(s) \(\to\) float |
These are the primary assembler directives for initialized data declarations. Other directives are referenced in different sections.
Initialized arrays are defined with comma separated values.
Some simple examples include:
bVar db 10 ; byte variable cVar db "H" ; single character strng db "Hello World ; string wVar dw 5000 ; 16-bit variable dVar dd 50000 ; 32-bit variable arr dd 100, 200, 300 ; 3 element array flt1 dd 3.14159 ; 32-bit float qVar dq 1000000000 ; 64-bit variable
The value specified must be able to fit in the specified data type. For example, if the value of a byte sized variables is defined as 500, it would generate an assembler error.