Reversebytes: Difference between revisions
Jump to navigation
Jump to search
imported>Jeremy (Importing text file) |
imported>Chuck No edit summary |
||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Line 10: | Line 9: | ||
===Description=== | ===Description=== | ||
Generalized reversal of bytes. Inputs | Generalized reversal of bytes. Note that the default is to swap 2 hex bytes in a 16 bit number. | ||
====Inputs==== | |||
* '''y''' = the input value(s) to operate on | |||
* '''totalbytes''' = the total number of bytes to swap | |||
* '''base''' = the number base to work in {default = 2\^8 = 256 = 1 hex byte} | |||
====Outputs==== | |||
* '''res''' = result of byte reversal on input '''y''' | |||
===Examples=== | ===Examples=== | ||
To swap 4 | To swap 4 '''bytes''' in a 32 bit number: | ||
:reversebytes(y,4) | :reversebytes(y,4) | ||
To swap 2 | To swap 2 '''words''' in a 32 bit number: | ||
:reversebytes(y,2,2\^16) | :reversebytes(y,2,2\^16) |
Revision as of 11:56, 9 October 2008
Purpose
Flips order of bytes in a word.
Synopsis
- res = reversebytes(y,totalbytes,base)
Description
Generalized reversal of bytes. Note that the default is to swap 2 hex bytes in a 16 bit number.
Inputs
- y = the input value(s) to operate on
- totalbytes = the total number of bytes to swap
- base = the number base to work in {default = 2\^8 = 256 = 1 hex byte}
Outputs
- res = result of byte reversal on input y
Examples
To swap 4 bytes in a 32 bit number:
- reversebytes(y,4)
To swap 2 words in a 32 bit number:
- reversebytes(y,2,2\^16)