Mail Archives: djgpp/1997/01/17/03:38:00
On Wed, 15 Jan 1997, Matthew Kennedy wrote:
>
> I'm building a an experimental ISR in GAS and I would like to access
> various parts of the BIOS data area (segment 0x40 etc).
>
> I know that conceptually, the assembler code should be like this:
>
> movw __go32_info_block.selector_for_linear_memory, %fs
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The assembler knows nothing about struct member names, only replaces
variable names with addresses. The assembler thinks that
__go32_info_block.selector_for_linear_memory is a single address label.
The compiler changes structure member names with offsets added to the
address of the variable address. In this case it would replace
_go32_info_block.selector_for_linear_memory with __go32_info_block+26,
which the assembler understands as 26 bytes after the address labeled
__go32_info_block.
Personally I find it much easier to let the compiler do this kind of work
for me - it's much less error prone. Write your ISR in C first, adding
asm statements to do things like saving registers. Then compile the C
code using the -S option to output the assembler which you can then edit
appropriately.
As for your concern about the struct layout changing in the future,
you'ld have the same problem with C. The compiler also outputs
__go32_info_block+26, so if the offset changes you'd have to recompile
all you sources anyway.
---------------
Peter Berdeklis
Dept. of Physics, Univ. of Toronto
- Raw text -