Skip to main content
Engineering LibreTexts

4.4: Data Section

  • Page ID
    19879
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    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.


    This page titled 4.4: Data Section is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Ed Jorgensen.

    • Was this article helpful?