替代 NASM32 中的@data [英] Alternative to @data in NASM32
问题描述
我现在正在学习汇编,我意识到符号 @data
没有在 NASM 中定义.这是我的代码:
section .datavar1 db 0x3var2 db 0x4节.text全球主要主要的:移动 eax,@datamov ds, eaxmov eax, var1mov ebx, var2移动轴,0
我在网上搜索替代符号,但没有找到任何东西.那么有没有什么可以替代 @data
的呢?感谢您的帮助.
Symbol @data
表示某些汇编程序中data
段的第一个字节的段落地址.另请参阅 NASM 第 9 章中的 16 位 .EXE 文件示例.在用于 DOS 或 Windows 3 的实模式 16 位程序中,在访问数据之前加载段寄存器是必不可少的.当这样的程序启动时,它的DS和ES指向Program Segment Prefix结构,而不是你程序的data
段.当段被声明时,汇编器还创建了一个具有相应名称的可重定位符号,例如@data
或data
,可以在您的程序中用于初始化段寄存器.其他汇编器可能使用不同的语法,例如 MOV AX,PARA# [data].>
当扁平的 32|64 位保护模式程序启动时,它的段寄存器已经预先加载了有效的索引到 Segment Descriptor Table,您根本不必关心段寄存器.
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.
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.
这篇关于替代 NASM32 中的@data的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!