Reputation: 179
I'm learning assembly right now and I realized that the symbol @data
isn't defined in NASM. Here is my code:
section .data
var1 db 0x3
var2 db 0x4
section .text
global main
main:
mov eax, @data
mov ds, eax
mov eax, var1
mov ebx, var2
mov eax, 0
I search the web for alternative symbols and I didn't found anything. So is there any alternative to @data
at all? Thanks for your help.
Upvotes: 1
Views: 254
Reputation: 5805
Symbol @data
represents the paragraph address of the first byte of data
segment in some assemblers. See also the example of 16bit .EXE file at NASM Chapter 9. Loading segment registers before accessing data is essential in real-mode 16bit programs for DOS or Windows 3. When such program starts, its DS and ES point to Program Segment Prefix structure, not to the data
segment of your program. When was the segment declared, assembler also created a relocatable symbol with corresponding name, such as @data
or data
, which can be used in your program to initialize segment register. Other assemblers may use a different syntax, for instance MOV AX,PARA# [data].
When a flat 32|64bit protected-mode program starts, its segment registers are already preloaded with valid indexes to Segment Descriptor Table and you don't have to care about segment registers at all.
Upvotes: 5