Undefined reference in inline assembler code.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

In the code below I want to test the outcome of the function reset(). I
do that simply by printf'ing _foo in main(). 

The compilation seems to go fine ('cc -c filename.c') but when using 'cc
-o filename filename.o' I get the following error messages in Cygwin GCC
(version 3.3.1):

testReset.o<.text+0x35>:testReset.c: undefined reference to '_LPT'
testReset.o<.text+0x3e>:testReset.c: undefined reference to '_foo'
collect2: ld returned 1 exit status

No matter whether I declare and/or define _foo within or outside main()
/ define _LPT in a header filer or not I still get the error. I would be
grateful if someone can clarify the error messages given. Thanks in
advance. :)

Yours,
Jack

#include <stdio.h>

#define _LPT 0x378

int _foo;

void reset()
{
    __asm__ (
	"movw _LPT+2,  %dx\n\t"
	"inb  %dx, %al\n\t"
	"orb  $0x1, %al\n\t"
	"outb %al, %dx\n\t"
	"movb _foo, %al"
    );
}

int main(int argc, char **argv) 
{
    reset();
    printf("foo: %d", _foo);
    exit(0);
}

---

Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.598 / Virus Database: 380 - Release Date: 28-02-2004
 


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux