www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/03/01/12:00:30

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: "Michael Sisco" <michael DOT sisco AT qtiworld DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: extended asm problems (bug???)
Date: Fri, 1 Mar 2002 10:21:58 -0600
Lines: 85
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700
NNTP-Posting-Host: 161.49.70.118
Message-ID: <3c7faa96$1@news.qgraph.com>
X-Trace: news.qgraph.com 1014999702 161.49.70.118 (1 Mar 2002 10:21:42 -0600)
Organization: Quad/Graphics,Inc.
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I have some questions concerning extended asm, one general and several
specific:

First the general question - I have yet to find a very thorough treatise on
the use of extended asm with DJGPP. I have found enough to get through the
basics, but there are things that don't work as I would have expected, and
other things that I just can't find an example of. My general question is:
What is the definitive text on using extended asm with DJGPP?

My more specific questions:

1) This one appears to me to be a bug. The following code fragment compiles
fine, and the .s file contains exactly the asm code I would expect, as long
as optimizations are not turned on. However, when I turn on optimizations
(-O3), the compiler attempts to use the di register for a movb at the
location shown.  The linker has serious issues with this attempt, and gives
an error message stating that the data size is invalid for mov instruction.

// uchar is of course a typedef for unsigned char, and the various eValues
are members of an enumeration.
void QClock::vSetRTClockTime(uchar ucHours, uchar ucMin, uchar ucSec)
{
  __asm__ __volatile__(
   "movb %2, %%al\n\t"
   "out %%al, %0\n\t"
   "movb %5, %%al\n\t" <<<=== OK if no optimization ("movb -1(%ebp), %al)
   "out %%al, %1\n\t"   // set the hours
  // Irrelevant code deleted...
   :
   : "g" (eCLOCK_WRITE_PORT), "g" (eCLOCK_REG_PORT), "g" (eHOURS),
         "g" (eMINUTES), "g" (eSECONDS), "g" (ucHours), "g" (ucMin), "g"
(ucSec)
   : "ax"
  );
}
Here's the output from the .s file (I've pulled out the irrelevant parts):

 .ascii "QClock::vSetRTClockTime\0"
 .p2align 4
.globl __ZN6QClock15vSetRTClockTimeEhhh
__ZN6QClock15vSetRTClockTimeEhhh:
LFB10:
 pushl %ebp
LCFI46:
 movl %esp, %ebp
LCFI47:
 pushl %edi
LCFI48:
 pushl %esi
LCFI49:
 pushl %ebx
LCFI50:
 subl $24, %esp
LCFI51:
 movb 20(%ebp), %bl
 movzbl 12(%ebp), %edi
 movzbl 16(%ebp), %esi
/APP

    movb $4, %al
    out %al, $112
    movb %di, %al   <<<=== Error occurs here!!!!
    out %al, $113
                 // set the hours

Any idea what might be happening here?

2) A colleague of mine has the following question: This is simply a matter
of syntax translation, but I can't find the answer anywhere:

How would you convert the following statements to AT&T syntax?
MOV ES:[BX][DI], AL
MOV SI, ES:[DI]
MOV AL, ES:[BX][DI]
MOV ES:[DI], BX

3) Hopefully simple: We have been unable to use any labels within an __asm__
block other than numbers(i.e. 0:, 1:, 23:). Is this a real limitation, or
are we missing something?

Thanks for your time,

Michael


- Raw text -


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