1

I get that you'd want to do something like take the first four bits put them on a stack (reading from left to right) then do you just put them in a register and shift them x times to put them at the right part of the number?

Something like

1000 0000 | 0000 0000 | 0000 0000 | 0000 1011

Stack: bottom - 1101 - top shift it 28 times to the left

Then do something similar with the last four bits but shift to the right and store in a register.

Then you and that with an empty return value of 0

Is there an easier way?

Heinz
  • 11
  • 2
  • 3
    Left-shift `1101` by 28 bits? That's not how you change the byte order... I think you're changing the nibble order (is that even a term?) instead of the byte order... – user541686 Feb 08 '11 at 04:49
  • Check this out http://www.codeguru.com/forum/showthread.php?t=292902 – gsk Feb 08 '11 at 04:52
  • Thx, I think I was a little confused on the definition. – Heinz Feb 08 '11 at 04:54

2 Answers2

2

Yes there is. Check out the _byteswap functions/intrinsics, and/or the bswap instruction.

user541686
  • 205,094
  • 128
  • 528
  • 886
0

You could do this way.. For example I/p : 0010 1000 and i want output 1000 0010

input store into a variable x int x; i = x>>4 j = x<<4 k = i | j print(K) //it will have 1000 0010.

kriya
  • 11
  • 2