delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/01/21/05:00:22

Message-ID: <3E2D132C.CEF919C4@yahoo.com>
From: CBFalconer <cbfalconer AT yahoo DOT com>
Organization: Ched Research
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: C/C++ versions of asm opcodes.
References: <12212N341 AT web2news DOT com>
Lines: 30
Date: Tue, 21 Jan 2003 09:55:00 GMT
NNTP-Posting-Host: 12.90.167.169
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc05-news.ops.worldnet.att.net 1043142900 12.90.167.169 (Tue, 21 Jan 2003 09:55:00 GMT)
NNTP-Posting-Date: Tue, 21 Jan 2003 09:55:00 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Joel_S wrote:
> 
> Ok, there are some C/C++ functions for asm opcodes, like << and
> >> for shl and shr (using Intel assembly syntax instead of AT&T).
> And I know how to translate some opcodes that don't have a C/C++
> equivalent.  But there are some things in asm that I'm wondering
> if I could do in C or C++, like
> ror
> rol
> adc
> sbb
> if anybody knows how to do these in C, I'd like to know.  Thanks.

/* untested example */
unsigned int ror(unsigned int n)
{
   unsigned int signbit, sign;

   signbit = UINT_MAX - INT_MAX;  /* shaky here */
   sign = (n & 1) * signbit;
   n = (n >> 1) | sign;
   return n;
}

-- 
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!


- Raw text -


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