Mirrors pairs of 2, 4 or 8 adjacent bytes
_Swab src, dest, count
_SwabL src, dest, count
_Swab8 src, dest, count
src, dest, count | : ivar |
The _Swab function copies count bytes from src, mirroring each pair of adjacent bytes, and stores the result at dest. The integer count should be a multiple of 2 to allow for swapping.
_SwabL and _Swab8 perform a similar task but mirror every 4 and 8 adjacent bytes respectively,
The _Swab commands are typically used to prepare binary data for transfer to a machine that uses a different byte order.
OpenW 1
Local a As String
a = "AbCdEfGhIjKlMnOpQrStUvWxYz12"
_Swab V:a, V:a, Len(a)
Debug a //Result: bAdCfEhGjIlKnMpOrQtSvUxWzY21
a = "AbCdEfGhIjKlMnOpQrStUvWxYz12"
_SwabL V:a, V:a, Len(a)
Debug a //Result: dCbAhGfElKjIpOnMtSrQxWvU21zY
a = "AbCdEfGhIjKlMnOpQrStUvWxYz12"
_Swab8 V:a, V:a, Len(a)
Debug a //Result: hGfEdCbApOnMlKjIxWvUtSrQYz12
Debug.Show
Use Mirror to swap at the bit-level.
{Created by Sjouke Hamstra; Last updated: 15/01/2023 by James Gaite}