SWAP4

Syntax:

    SWAP4( VariableA)

Command Availability:

Available on all microcontrollers.

Support Bytes only.

Explanation:

A function that swaps (or exchanges) nibbles (or the 8 bits of a byte in nibbles).

Example:

    dim ByteVariable as Byte

    ' Set variable to  0x12
    ByteVariable = 0x12

    ByteVariable = Swap4( ByteVariable )          ' <<< the SWAP4 instruction

    HSerPrint hex(ByteVariable)

    ' Would return 0x21

Key line: ByteVariable = Swap4( ByteVariable ) — swaps the high and low nibbles of the byte, turning 0x12 into 0x21.

See Also:

  • SWAP — related command in the same category
  • Using Variables — related command in the same category