From: david DOT stegbauer AT cz DOT opel DOT com X-Lotus-FromDomain: GMCZECHIA AT EDSHUBEUROPE Sender: david DOT stegbauer AT cz DOT opel DOT com To: djgpp AT delorie DOT com Message-ID: <4125673F.005E129F.00@derumg01.cyberlink.eds.com> Date: Thu, 25 Mar 1999 18:19:58 +0100 Subject: Inline assembly - rotate left Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Content-Disposition: inline Reply-To: djgpp AT delorie DOT com Hi,(I do not need help) here is my solution how to do bit rotation via inline assembly. So, if this is stupid hint, don't beat my head, nor softly :-) #ifdef __DJGPP__ #define roll(val,cnt) asm volatile (\ "movl %2, %%ecx \n\t" \ "roll %%cl, %1" \ :"=r" (val) \ :"r"(val), "r"(cnt) \ :"%ecx") #endif /*__DJGPP__*/ let me explain: "movl %2, %%ecx \n\t" \ "roll %%cl, %1" \ this is actual code. store number of bits in %cl using whole %ecx. this is must, because roll needs 8 bit count. both %ecx and %cl are prefixed with %%, beacause extended asm is used. :"=r" (val) \ store result back in in val :"r"(val), "r"(cnt) \ attach arguments to registers (gcc choose automatically) :"%ecx") mark %ecx as clobbered - we used it explicitly. Well, I really tested it on longs only, but this message is meant more as hint than I expect you will use it. Also I believe this can be done more elegant. More you can find in Brennan's Guide too http://www.rt.e-technik.tu-darmstadt.de/~georg/djgpp/djgpp-asm.htm Any improvements are welcome David