www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/26/16:45:40

From: "d-range!" <d-range AT thefridge DOT et DOT fnt DOT hvu DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: WATCOM #pragma to DJGPP __asm__ ?!!
Date: Mon, 26 Jan 1998 22:31:23 +0100
Organization: World Online
Lines: 31
Message-ID: <34CD00AB.8C850269@thefridge.et.fnt.hvu.nl>
References: <199801260623 DOT WAA01719 AT adit DOT ap DOT net>
NNTP-Posting-Host: hlv1-p233.worldonline.nl
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Nate Eldredge wrote:

> >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;
> }

Does this produce *inline* assembly? It looks like if the compiler makes a CALL
for every invocation.

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

Ah... WATCOM always does SHR instead of SAR

d-range!                  d-range AT thefridge DOT et DOT fnt DOT hvu DOT nl

- Raw text -


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