delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/03/17:42:29

Date: Mon, 04 Aug 1997 09:44:46 +1100
From: Bill Currie <billc AT blackmagic DOT tait DOT co DOT nz>
Subject: Re: FIXDIV for ASM
In-reply-to: <m0wulJn-0003FjC@fwd03.btx.dtag.de>
To: djgpp AT delorie DOT com
Message-id: <199708032149.JAA12878@teleng1.tait.co.nz gatekeeper.tait.co.nz>
Organization: Tait Electronics Limited
MIME-version: 1.0
Comments: Authenticated sender is <billc AT blackmagic DOT tait DOT co DOT nz>

On  2 Aug 97 at 23:02, Georg Kolling wrote:

> Mark Goodwin schrieb:
> >   inline static long FIXDIV(long Num, long Denom)
> >   {
> >       long Result;
> >       asm ("movl Num, %%eax;"
> >            "movl %%eax, %%edx;"
> >            "sarl %%edx, 16;"
> >            "shll %%eax, 16;"
> >            "idivl Denom"
> 
> You just have to use _Num and _Denom!

Nope, uses extended asm instead (Mark was getting close):

       asm ("movl %1, %%eax;"
            "movl %%eax, %%edx;"
            "sarl %%edx, 16;"
            "shll %%eax, 16;"
            "idivl %2"
			:"=a"(Result)			/* output */
			:"g"(Num),"g"(Denom)	/* input */
			:"%edx"					/* modified */
		);

Bill
--
Leave others their otherness.

- Raw text -


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