I am writing 16-bit real mode assembly code that uses BIOS routines to dump a memory buffer to disk. I can't seem to figure out the syntax to get the segment register set correctly when setting up the pointer to the data buffer to be dumped. (I'm using gcc as my assembler and linker.)
.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
works, as long as the .text
section is small enough that the .data
section is in the same segment. Once the code is large enough, then I get this linker error: (.stage2+0x22f): relocation truncated to fit: R_386_16 against .data
This means that I need to specifically load %sp
as well as %bx
, correct? I tried les $data_buffer_section, %si
and les $data_buffer_section, %bx
; but, get this syntax error: Error: operand type mismatch for les
I also tried les data_buffer_section, %si
(without the $
). The syntax error goes away, but the linker error does not. (Plus, I don't think that will load the correct values, will it?)