www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/01/02/18:04:30

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: "Francisco Pastor" <Francisco DOT Pastor AT uv DOT es>
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with gcc v2.953
Lines: 107
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <2hMY7.71$SI.731@news.ono.com>
Date: Wed, 02 Jan 2002 22:59:10 GMT
NNTP-Posting-Host: 62.42.23.245
X-Trace: news.ono.com 1010012350 62.42.23.245 (Wed, 02 Jan 2002 23:59:10 MET)
NNTP-Posting-Date: Wed, 02 Jan 2002 23:59:10 MET
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I have found a problem with the gcc version v2.953 when I use the function
inportb.

This have different results than gcc v2.952.

Compiling a C++ module that use inportb, the compilation results of that
function is the next assembler code:

(gbb) disas inportb
Dump of assembler code for function inportb:
0x17d64 <inportb>:      push   %ebp
0x17d65 <inportb+1>:    mov    %esp,%ebp
0x17d67 <inportb+3>:    sub    $0x14,%esp
0x17d6a <inportb+6>:    push   %ebx
0x17d6b <inportb+7>:    mov    0x8(%ebp),%eax
0x17d6e <inportb+10>:   mov    %eax,%edx
0x17d70 <inportb+12>:   in     (%dx),%al
0x17d71 <inportb+13>:   mov    %al,0xfffffffe(%ebp)
0x17d74 <inportb+16>:   lea    0xfffffffe(%ebp),%ecx
0x17d77 <inportb+19>:   mov    (%ecx),%al
0x17d79 <inportb+21>:   mov    %al,0xffffffff(%ebp)
0x17d7c <inportb+24>:   xor    %ebx,%ebx
0x17d7e <inportb+26>:   mov    0xffffffff(%ebp),%bl
0x17d81 <inportb+29>:   mov    %ebx,%eax
0x17d83 <inportb+31>:   jmp    0x17d90 <inportb+44>
0x17d85 <inportb+33>:   jmp    0x17d90 <inportb+44>
0x17d87 <inportb+35>:   jmp    0x17d90 <inportb+44>
0x17d89 <inportb+37>:   lea    0x0(%esi,1),%esi
0x17d90 <inportb+44>:   mov    0xffffffe8(%ebp),%ebx
0x17d93 <inportb+47>:   mov    %ebp,%esp
0x17d95 <inportb+49>:   pop    %ebp
0x17d96 <inportb+50>:   ret

But the same code compiled via gcc v2.952 give the next result:

(gbb) disas inportb
Dump of assembler code for function inportb:
0x19224 <inportb>:      push   %ebp
0x19225 <inportb+1>:    mov    %esp,%ebp
0x19227 <inportb+3>:    sub    $0x18,%esp
0x1922a <inportb+6>:    mov    0x8(%ebp),%eax
0x1922d <inportb+9>:    mov    %eax,%edx
0x1922f <inportb+11>:   in     (%dx),%al
0x19230 <inportb+12>:   mov    %al,0xffffffff(%ebp)
0x19233 <inportb+15>:   xor    %ecx,%ecx
0x19235 <inportb+17>:   mov    0xffffffff(%ebp),%cl
0x19238 <inportb+20>:   mov    %ecx,%eax
0x1923a <inportb+22>:   jmp    0x19240 <inportb+28>
0x1923c <inportb+24>:   jmp    0x19240 <inportb+28>
0x1923e <inportb+26>:   jmp    0x19240 <inportb+28>
0x19240 <inportb+28>:   mov    %ebp,%esp
0x19242 <inportb+30>:   pop    %ebp
0x19243 <inportb+31>:   ret

It looks similar but, if the inportb funcion is used in a interrupt handler
the first do not work properly because it put the address of a local
variable in the %ecx register using a instruction lea (offset in %ss
selector) and after use the same offset ussing de %ds selector with the mov
instruction. But in a interrupt handler %ss is different from %ds.

Another thing. I dont know why the next code :

#include <pc.h>

int main()
{
int a = inportb(0x300);
}

compiled with the file proof.cc have different result that if the name of
the file is proof.c.

With proof.cc and gcc v2.953 the code is similar to the first fragment of
assembler code.
In the last case ussing proof.c, the assembler code that print gdb for the
inportb function is:

(gdb) disas inportb
Dump of assembler code for function inportb:
0x2ee0 <inportb>:       push   %ebp
0x2ee1 <inportb+1>:     mov    %esp,%ebp
0x2ee3 <inportb+3>:     mov    0x8(%ebp),%edx
0x2ee6 <inportb+6>:     in     (%dx),%al
0x2ee7 <inportb+7>:     movzbl %al,%eax
0x2eea <inportb+10>:    mov    %ebp,%esp
0x2eec <inportb+12>:    pop    %ebp
0x2eed <inportb+13>:    ret

That correspond to the code included in the libc.a library.

Please, somebody know how to use correctly the inportb function in a
interrupt handler with the version 2.953 and why the C++ compiler do not use
the module from de libc.a library?

Thanks for your help


 Francisco Pastor Gomis.
 email: Francisco DOT Pastor AT uv DOT es

 Dep. d'Informàtica. Universitat de València
 Avda Vicent Andrés Estellés s/n. 46100 BURJASOT (Valencia). SPAIN
 Tlf(ph): (34) 96 316 0410.  Fax: (34) 96 316 0418




- Raw text -


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