X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: "Francisco Pastor" 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 : push %ebp 0x17d65 : mov %esp,%ebp 0x17d67 : sub $0x14,%esp 0x17d6a : push %ebx 0x17d6b : mov 0x8(%ebp),%eax 0x17d6e : mov %eax,%edx 0x17d70 : in (%dx),%al 0x17d71 : mov %al,0xfffffffe(%ebp) 0x17d74 : lea 0xfffffffe(%ebp),%ecx 0x17d77 : mov (%ecx),%al 0x17d79 : mov %al,0xffffffff(%ebp) 0x17d7c : xor %ebx,%ebx 0x17d7e : mov 0xffffffff(%ebp),%bl 0x17d81 : mov %ebx,%eax 0x17d83 : jmp 0x17d90 0x17d85 : jmp 0x17d90 0x17d87 : jmp 0x17d90 0x17d89 : lea 0x0(%esi,1),%esi 0x17d90 : mov 0xffffffe8(%ebp),%ebx 0x17d93 : mov %ebp,%esp 0x17d95 : pop %ebp 0x17d96 : 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 : push %ebp 0x19225 : mov %esp,%ebp 0x19227 : sub $0x18,%esp 0x1922a : mov 0x8(%ebp),%eax 0x1922d : mov %eax,%edx 0x1922f : in (%dx),%al 0x19230 : mov %al,0xffffffff(%ebp) 0x19233 : xor %ecx,%ecx 0x19235 : mov 0xffffffff(%ebp),%cl 0x19238 : mov %ecx,%eax 0x1923a : jmp 0x19240 0x1923c : jmp 0x19240 0x1923e : jmp 0x19240 0x19240 : mov %ebp,%esp 0x19242 : pop %ebp 0x19243 : 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 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 : push %ebp 0x2ee1 : mov %esp,%ebp 0x2ee3 : mov 0x8(%ebp),%edx 0x2ee6 : in (%dx),%al 0x2ee7 : movzbl %al,%eax 0x2eea : mov %ebp,%esp 0x2eec : pop %ebp 0x2eed : 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