delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/26/02:29:14

Date: Sun, 25 Jan 1998 22:23:07 -0800 (PST)
Message-Id: <199801260623.WAA01719@adit.ap.net>
Mime-Version: 1.0
To: "d-range!" <d-range AT thefridge DOT et DOT fnt DOT hvu DOT nl>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: WATCOM #pragma to DJGPP __asm__ ?!!

At 09:13  1/25/1998 GMT, d-range! wrote:
>Heya,
>
>I recently decided to switch from WATCOM to DJGPP, to make my code more
>portable, but I ran into the following 'problem' making the code compilable
>under DJGPP:
[snipped]
>My question: how can I make inline functions like this one to work with
>DJGPP. I read the DJGPP assembler tutorial, and I know you can #define the
>function like this,
>
>#define FixSHR(arg1,arg2,arg3) __asm__ \
>            "sarl %1,%0" \
>	: "=r" (arg3) \
>	: "0" (arg1), "1" (arg2) \
>	: "0";
Try this:
inline int FixSHR(int n, unsigned c)
{
   int result;
   asm ("sarl %2,%0"
        : "=g" (result)
        : "0" (n), "cI" (c));
   return result;
}

Incidentally, since your operands are `int', `FixSHR(a,b)' has the same
effect as `a >> b'.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


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