From: "Joel_S" Newsgroups: comp.os.msdos.djgpp Subject: Re: C/C++ versions of asm opcodes. Date: Wed, 22 Jan 2003 01:44:13 +0100 Organization: Web2news.com Message-ID: <12333N451@web2news.com> References: <12212N341 AT web2news DOT com> <3E2D132C DOT CEF919C4 AT yahoo DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 NNTP-Posting-Host: 198.81.26.238 X-Complaints-To: abuse AT web2news DOT net Lines: 28 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Thank you. > 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; > } -- Posted via http://web2news.com the faster web2news on the web