delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/11/19:32:38

Message-ID: <17@candrian.pcnet.ro>
Reply-To: candrian AT pcnet DOT pcnet DOT ro (Calin Andrian)
To: djgpp AT delorie DOT com
Date: Wed, 11 Jun 1997 19:55:10
Subject: Inline AMS Help
From: candrian AT pcnet DOT pcnet DOT ro (Calin Andrian)

Aaron Cosand <ACosand AT prodigy DOT net> wrote:

>
>I'm trying to use the following inline asm code in djgpp, but I'm
>afraid that I can't figure out how from the docs and the FAQ.  If any
>one could show me how to do this, it would be greatly appreciated
>
>Aaron Cosand
>
>inline AstFixedpoint_t AstFixMulFix( AstFixedpoint_t a, AstFixedpoint_t
>b )
>{
>AstFixedpoint_t result;
>
>  mov  eax, a
>  mov  ebx, b
>  imul ebx
>  shrd eax, edx, 16
>  mov  result, eax
>
>  return result;
>}

It looks like this:
extern __inline__ long fixmul(long op_a, long op_b)
{
  long result;

  __asm__ __volatile__ ("imull %0; shrdl $16,%1,%0"
                        : "=a" (result)
                        : "0" (op_a), "d" (op_b));
  return result;
}

To be put in headers.
Try it ! I didn't, but it should do the job. Use it, and look for
the code generated with FSDB. I changed a little the code, to
clobber only two regs. In FSDB it should (hopefully) look like this:
movl eax,op_a
movl edx,op_b
imull eax,edx (See if it's the 2-byte instruction)
shrdl eax,edx,16

That's all. Result in eax.
See also: djgpp/include/inlines/pc.h

By the way, the above mentioned pc.h should be rewritten to take
advantage of the <in al,number> and like instructions:
        Current:                        Should be:
        : "d" (_port)                   : "N,d" (_port)
        : "a" (_data)                   : "a,a" (_data)
        : "=a" (rv)                     : "=a,a" (rv)

Calin Andrian
candrian AT pcnet DOT pcnet DOT ro



- Raw text -


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