public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc's x86 "RET"-machine instruction optimization
@ 2005-08-01 13:56 Josef Angermeier
  2005-08-01 17:19 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Josef Angermeier @ 2005-08-01 13:56 UTC (permalink / raw)
  To: gcc-help


Hello

Im trying to write a script which patches gcc's assembler output (-S
option) in that way, that those functions which are exported (.gobl
asm-directive) return with a near-jump instead of a
near-return-instruction. (Im writing a BIOS for a virtual machine...)

So i fist that it would be an easy task to replace all
"retl"-instructions by "lretw" ones in gcc's asm code. But then now im
facing a problem:

C code like that:
kbd.c:

bios_16_xxxx(struct regs *regs)
{
	if (AH == 0x00) {
		bios_16_00xx(regs);
	} else {
		....
	}
}

kbd.s

bios_16_xxxx:
.LCFI71:
	...
	jmp	bios_16_00xx
.L105:
	...
	lretw		(PATCHED RETURN)


....


bios_16_00xx:
.LFB59:
	...
	ret


GCC uses a jmp-instruction instead of a call one, so 'speeds up' execution by
saving the execution of bios_16_xxxx's return instruction (lretw one). This of course
ruins my efforts. Therfore i'd like to know how this optimization is called, and if
there is any gcc option to disable this particular optimization.

Big thanks in advance
josef

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-08-01 19:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-01 13:56 gcc's x86 "RET"-machine instruction optimization Josef Angermeier
2005-08-01 17:19 ` Ian Lance Taylor
2005-08-01 19:01   ` Josef Angermeier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).