[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] How to get the GCC to use the swap instruction?
From: |
Jerry Quinn |
Subject: |
[avr-gcc-list] How to get the GCC to use the swap instruction? |
Date: |
Tue, 29 Oct 2002 22:39:35 -0500 |
Tehn Yit Chin writes:
> Hi all,
>
> I want to swap the nibbles in a byte, but I can't seem to get the GCC to use
> the SWAP instruction without using assembler? Does anybody know how to do
> it?
I suspect the answer is that gcc doesn't do this because it doesn't
consider a nibble to be a complete data type. If there was a halfchar
datatype, then you could expect gcc to do it for you.
So the short answer is 'no, use assembler'. If it's wrapped in a
macro, this shouldn't be too bad. Something like this (warning - I
haven't tried it):
#define swap_nibble(a) { asm("swap %0": "=r" (a) : "r" (a)); }
Something like this might make a useful addition to the libc package.
Jerry Quinn
avr-gcc-list at http://avr1.org
[avr-gcc-list] movin' up to Linux, Marlin Unruh, 2002/11/03
Re: [avr-gcc-list] How to get the GCC to use the swap instruction?, Bruce D. Lightner, 2002/11/03