Lesson 4 of 15

The Data Section

The Data Section

The .data section holds initialized data that your program uses. You define variables using data directives.

Data Directives

DirectiveSizeExample
db1 bytedb 0x41 or db "A"
dw2 bytes (word)dw 1000
dd4 bytes (double word)dd 100000
dq8 bytes (quad word)dq 0xFFFFFFFF

Strings

Strings are just sequences of bytes. Common patterns:

msg db "Hello", 10     ; String followed by newline (10 = '\n')
msg db "Hi", 0         ; Null-terminated string
msg db 72, 101, 108    ; Individual byte values

The value 10 is the ASCII code for a newline character. You append it after the string with a comma.

Multiple Data Items

You can define multiple items:

section .data
greeting db "Hello", 10
farewell db "Bye", 10
number dd 42

Each label points to the start of its data in memory.

Your Task

Define three strings in the data section and print them in order:

  1. "One" followed by a newline (4 bytes)
  2. "Two" followed by a newline (4 bytes)
  3. "Three" followed by a newline (6 bytes)
x86_64 runtime loading...
Loading...
Click "Run" to execute your code.