NASM Coding: Declaring Variables & Reserving Data

Declaring and setting variables (in the

.data
section:)

db    0x55                 ; (db = 'define byte(s)') just the byte 0x55
db    0x55, 0x56, 0x57     ; three bytes in succession
db    'hello', 13, 10, '$' ; characters and string literals also work
dw    0x1234               ; ('define word(s)' = 2*n bytes) 0x34 0x12
dw    'a'                  ; 0x61 0x00 (character followed by null)
dw    'ab'                 ; 0x61 0x62 (2 characters)
dw    'abc'                ; 0x61 0x62 0x63 0x00 (string: 3 chars + null)
dd    0x12345678           ; ('define dword(s)' = 4*n bytes) 0x78 0x56 0x34 0x12
dq    0x123456789          ; ('define qword(s)' = 8*n bytes) 0x89 0x67 0x45 0x23 0x01 0x00 0x00 0x00 

Example:

mystr db 'hello', ' ', 'world', 10, '$'