public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: y2bismil@engmail.uwaterloo.ca
Cc: GCC- help <gcc-help@gcc.gnu.org>
Subject: Re: inline assembler
Date: Wed, 05 Nov 2003 18:04:00 -0000	[thread overview]
Message-ID: <87brrq669q.fsf@student.uni-tuebingen.de> (raw)
In-Reply-To: <1068055268.3fa93ae4389fb@www.nexusmail.uwaterloo.ca>

y2bismil@engmail.uwaterloo.ca writes:

> I was wondering about inline assember.  I've been reading up quite a bit on it,
> and have noticed a common pattern to 'emulate' functions.
> ***************************************
> example from: 
> http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html
> ***************************************
> #define times3(arg1, arg2) \
> __asm__ ( \
>   "leal (%0,%0,2),%0" \
>   : "=r" (arg2) \
>   : "0" (arg1) );
> ***************************************
> 
> Is there a way in inline assembler to do 'real' functions?  As an example
> suppose I have the following:  
> #define times3(arg1)__asm__ (...);  /*this results in arg1*3*/
> 
> Would there be a way for me to say 
> int x = times3(arg1);

Just define an inline function:

static inline int times3(int x) {
  int r;
  asm(...);
  return r; 
}

-- 
	Falk

  reply	other threads:[~2003-11-05 18:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-05 18:01 y2bismil
2003-11-05 18:04 ` Falk Hueffner [this message]
2003-11-05 18:13   ` y2bismil
2003-11-05 18:25     ` Falk Hueffner
2003-11-05 19:07 ` Kimmo Fredriksson
2003-11-05 19:23   ` y2bismil
  -- strict thread matches above, loose matches on Subject: below --
2000-05-18  1:17 Oldrich Kepka
2000-05-18  1:30 ` Alexandre Oliva
2000-05-19  7:57   ` Gary Funck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87brrq669q.fsf@student.uni-tuebingen.de \
    --to=falk.hueffner@student.uni-tuebingen.de \
    --cc=gcc-help@gcc.gnu.org \
    --cc=y2bismil@engmail.uwaterloo.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).