Reversebytes: Difference between revisions
Jump to navigation
Jump to search
imported>Jeremy (Importing text file) |
imported>Jeremy (Importing text file) |
||
| Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Flips order of bytes in a word. | Flips order of bytes in a word. | ||
===Synopsis=== | ===Synopsis=== | ||
:res = reversebytes(y,totalbytes,base) | :res = reversebytes(y,totalbytes,base) | ||
===Description=== | ===Description=== | ||
Generalized reversal of bytes. Inputs are y, the value(s) to operate on, the total number of bytes to swap totalbytes {default = 2} in each word, and the number base to work in base {default = 2\^8 = 256 = 1 hex byte}. Note that the default is to swap 2 hex bytes in a 16 bit number. | Generalized reversal of bytes. Inputs are y, the value(s) to operate on, the total number of bytes to swap totalbytes {default = 2} in each word, and the number base to work in base {default = 2\^8 = 256 = 1 hex byte}. Note that the default is to swap 2 hex bytes in a 16 bit number. | ||
===Examples=== | ===Examples=== | ||
To swap 4 BYTES in a 32 bit number: | To swap 4 BYTES in a 32 bit number: | ||
:reversebytes(y,4) | :reversebytes(y,4) | ||
To swap 2 WORDS in a 32 bit number: | To swap 2 WORDS in a 32 bit number: | ||
:reversebytes(y,2,2\^16) | :reversebytes(y,2,2\^16) | ||
Revision as of 14:26, 3 September 2008
Purpose
Flips order of bytes in a word.
Synopsis
- res = reversebytes(y,totalbytes,base)
Description
Generalized reversal of bytes. Inputs are y, the value(s) to operate on, the total number of bytes to swap totalbytes {default = 2} in each word, and the number base to work in base {default = 2\^8 = 256 = 1 hex byte}. Note that the default is to swap 2 hex bytes in a 16 bit number.
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)