delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/10/18:45:34

From: Endlisnis <s257m AT unb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Bug in GCC?
Date: Thu, 10 Sep 1998 17:58:30 -0300
Organization: NBTel Internet
Lines: 72
Message-ID: <35F83D75.B9359ABB@unb.ca>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 980908101052 DOT 26824C-100000 AT is> <35F5B07A DOT 8E37D184 AT unb DOT ca> <35F73F2C DOT FF0583BC AT cartsys DOT com>
NNTP-Posting-Host: fctnts10c71.nbnet.nb.ca
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Nate Eldredge wrote:
> > OK, Here is the input file, which seems to compile differently when giving asm
> > output, but it still isn't right!  And included is the complete asm output, I
> > marked the place where it screws up, in the add function.  Is there something
> > I'm doing wrong?
> I see you solved it, but I'm wondering about your original problem.  How
> did you get that strange assembler?  If you used a DJGPP tool to
> disassemble it, perhaps the disassembler has a bug.  Actually, I suspect
> you might have looked at the assembly for something else by mistake...
	Well, I can still seem to get the weird code, but now I think it may be the
Disassembler window screwing up (in RHIDE).  I compiled the exact same code
with the exact same switches (-m486 included) with the exception of the -S for
asm output, here is what I got for asm output (for the function 'add' as you
can see)

.globl _add__Fii
_add__Fii:
LFB1:
	.def	.bf;	.val	.;	.scl	101;	.line	4;	.endef
	.def	_a;	.val	8;	.scl	9;	.type	04;	.endef
	.def	_b;	.val	12;	.scl	9;	.type	04;	.endef
	.def	_Ret;	.val	0;	.scl	4;	.type	04;	.endef
	pushl %ebp
LCFI0:
	movl %esp,%ebp
LCFI1:
	.ln	6
	movl 8(%ebp),%eax
/APP
	addl 12(%ebp), %eax
/NO_APP
	.ln	8
	leave
	ret

And this is what I get from the Disassembler window:

add__Fii (at t2.cc:8):
000015a0:  pushl  %ebp
000015a2:  inl    $0x8b,%eax
000015a4:  incl   %ebp
000015a5:  orb    %al,(%ebx)
000015a7:  incl   %ebp
000015a9:  leave
000015aa:  ret

As you can see, I'm not getting the function confused, the label is clearly
visible, and it appear immediately before the main, in both asm and the deasm
window.  AND the code does exactly what I want/expect it to do.  But it just
doesn't look right from within RHIDE.  It seems to get confused and think:
	movl %esp,%ebp
	movl 8(%ebp),%eax
	addl 12(%ebp), %eax
is:
	inl    $0x8b,%eax
	incl   %ebp
	orb    %al,(%ebx)
	incl   %ebp

	Can somebody tell me what the hex-code for each one of those would be?  Also,
turning off the "-m486" switch generates the EXACT same code for this
function, but RHIDE seems to display it perfectly...???  Does it have anything
to do with -m486 changing the alignment of functions so RHIDE gets confused
and it's disassembler gets misaligned with the real code?

-- 
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT GeoCities DOT com
          Endlis AT nbnet DOT nb DOT ca


- Raw text -


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