我正在编写16位实模式汇编代码,它使用BIOS例程将内存缓冲区转储到磁盘。在设置指向要转储的数据缓冲区的指针时,我似乎无法找出正确设置段寄存器的语法。 (我使用gcc作为我的汇编器和链接器。)
.text
# mov Doesn't work when $data_buffer_section ends up in a different segment.
mov $data_buffer_section, %bx
# Enough code here to put the .data section in a different segment
.section .data
data_buffer_section: .ascii "<Generated data overwrites this.>"
mov
有效,只要.text
部分足够小,.data
部分位于同一网段。一旦代码足够大,我就会收到此链接器错误:(.stage2+0x22f): relocation truncated to fit: R_386_16 against .data
这意味着我需要专门加载%sp
以及%bx
,对吗?我试过les $data_buffer_section, %si
和les $data_buffer_section, %bx
;但是,得到此语法错误:Error: operand type mismatch for les
我也尝试了les data_buffer_section, %si
(没有$
)。语法错误消失了,但链接器错误却没有。 (另外,我不认为这会加载正确的值,是吗?)