delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/14/22:44:57

From: Matthew Kennedy <q9522772 AT helios DOT usq DOT edu DOT au>
Newsgroups: comp.os.msdos.djgpp
Subject: assembler and C structs - how do I interface them?
Date: Wed, 15 Jan 1997 00:08:59 +1000
Organization: University of Southern Queensland
Lines: 71
Message-ID: <Pine.HPP.3.95.970114233606.14399A-100000@helios.usq.edu.au>
NNTP-Posting-Host: helios.usq.edu.au
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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
  movl **some address: seg*16+offs**, %eax
  movX **move whatever to**, %fs:(%eax)

This would assemble but fails upon linkage with an "undefined reference 
__go32_info_block.selector_for_linear_memory" message.

To explain my problem better, the following is a code example
representitive of the actual problem code:

/** get_selector.S ******************************************/

  .global _get_selector
  .extern __go32_info_block.selector_for_linear_memory

  .text

  # int get_selector(void)
  #
  # Just load _dos_ds into AX
  #
_get_selector: .align 4
    # THE FOLLOWING IS WHAT CAUSES THE LINKER ERROR (I THINK)
    movw __go32_info_block.selector_for_linear_memory, %ax
  ret


/** test.c **************************************************/

#include <stdio.h>

extern int get_selector(void);

void main(void)
{
  printf("selector: 0x%04x\n", get_selector());
}

/** compilation command *************************************/

gcc get_selector.S test.c -o test.exe

/** the error message ***************************************/

c:/gcc/tmp\cccaaaaa(.text+0x2):fake: undefined reference to
`_go32_info_block.selector_for_linear_memory'



I suspect that the assembler can't interpret fields of structures.  In
this case I'll have to use __go32_info_block+26 as the memory reference -
which works.  But thats harder to read as a program and the relative
address (+26) might change in future versions. ANY IDEAS?


PLEASE NOTE: I already know that the farpoke/peek functions would do the
same function as what I'm getting at, but I need something that works in
assembler since my function is too large and cumbersome to implement
in C or inline.

Also, no mention of how to do this in the as-info node (I've read it top
to bottom)



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019