delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/10/19:46:33

From: Leath Muller <leathm AT gbrmpa DOT gov DOT au>
Message-Id: <199607102332.JAA14331@gbrmpa.gov.au>
Subject: Problems with inline ASM
To: djgpp AT delorie DOT com
Date: Thu, 11 Jul 1996 09:32:09 +1000 (EST)

Hi guys...

I was converting my blit routines to asm last night, and encountered a problem
with accessing C variables. As a result of the problem, I wrote the following
test program:

---
#include <stdio.h>

volatile int x = 0;

int main(void)
{
	volatile asm ("
		movl	$50, _x;
	");
	printf("%d\n",x);
	exit(0);
}
---

This code compiled flawlessly, and ran as expected, ie: printing out the
number 50.

However, when i try to do something similar in my main blitting program,
I experience some problems: It seems to compile ok through the first stage
of my makefile, but seems to complain when it tries to link the file.

The problem is this error:

vbe.exe:0 undeclared reference to variable 'x'

I get this with all the variables I use in the inline function. Is this a
common problem? I tried static, as well as volatile, and it make no difference!
It also brings up this problem whenever I try to access any C variable,
whether it be global, local or whatever.

Can someone help me at all?

Leathal.

- Raw text -


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