delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/11/19/19:01:52

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: cbramix AT libero DOT it (Carlo)
Newsgroups: comp.os.msdos.djgpp
Subject: problem with assembly constraints
Date: 19 Nov 2003 15:59:41 -0800
Organization: http://groups.google.com
Lines: 51
Message-ID: <d2ad330a.0311191559.39d6b67a@posting.google.com>
NNTP-Posting-Host: 151.25.153.117
X-Trace: posting.google.com 1069286381 6214 127.0.0.1 (19 Nov 2003 23:59:41 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Wed, 19 Nov 2003 23:59:41 +0000 (UTC)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello everyone,

I'm asking your help for solving a strange problem.
Let's take this code:

static void function_1(void)
{
	printf("function 1 called\n");
}

void function_2(void)
{
	asm (" jmp _function_1 ");
}

This is a very simple example about what I want to do.
At the end of function_2() I want to call function_1().
My optimization is:

	jmp function_1

instead of:

	call function_1
	ret

This is an optimization done by newer GCC versions too when it
compiles the source.
But for some reasons I must do it myself.
The real problem happens when the global optimizer find that
function_1() doesn't seem to be used, and since it's declared as
"static" it removes it!!!
And the final result is that function_1() is missing.
I haven't this problems with my old GCC 2.7.2.1, so I tried to do some
tests...

I changed to:

	asm (" jmp %0 " ::"i"(function_1) );

but without success, because GCC converts it to:

	jmp $_function_1

and the '$' character stops AS.EXE during assembling.
I'm weak about constraints usage, can you give me some suggestions for
correcting this line?

Sincerely,

Carlo

- Raw text -


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