Index | PAL Intro | Commands | Registers | Indices | Stack | Macros | Classes | Attributes | Errors


Manual Reference Pages  - op_swap (5)

NAME

op/swap - Swap bytes

CONTENTS

Synopsis
Description
Error Handling
Examples
See Also
Author

SYNOPSIS

op/swap write, #value, #select

DESCRIPTION

Re-orders bytes in a 4-byte (32-bit) raw index supplied as a value argument according to the sequence identified in the select argument, storing the result in the write register.

The highest 4 bits (nibble) of the select argument tell the instruction which byte position the first byte should be moved to (where #1 is the first byte position), the next nibble which byte position the second byte should be moved to etc. If a nibble is zero, then the corresponding byte will remain unmoved.

For example, to convert 0xff41ffff to 0xffffff41 the select argument should contain the index 0x0402, i.e. the 2nd nibble contains the number 4 because we want the 2nd byte moving to the 4th position and the 4th nibble contains the number 2 because the 4th byte is moving to the 2nd position, i.e. the bytes are swapping positions.

ERROR HANDLING

A runtime error is generated if a write argument is not a register or if a value or select argument is not a number (raw index) nor a register containing one.

EXAMPLES

op/swap P0, #0x4182f9, #0x402
  Swaps the 2nd and 4th bytes, storing 0xf98241 in register P0.
op/swap PUSH, #0xffe0ac0f, #0x4321
  Reverses the byte order pushing the result to the stack.

SEE ALSO

pal_commands(5), pal_registers(5), pal_indices(5), op_maths(5), op_mask(5),
PROSE Assembly Language at prose.sourceforge.net.

AUTHOR

Copyright (c) 2002-2011 Mark R. Bannister <cambridge@users.sourceforge.net>.

This is free software and can be downloaded from prose.sourceforge.net; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


PAL 1.0 op_swap (5) 13 January 2011
Generated by manServer 1.07 from man5/op_swap.5 using man macros.