Ponde byteswap(w32)

This returns a byteswapped 32-bit word from the given value.

word
byteswap(w32)
{
    __push__(w32);

asm {
    dup
    byt     // (0)
    swp
    rol8
    dup
    byt     // (1)
    rol8    // (1) << 8
    swp
    rol8
    dup
    byt     // (2)
    exw     // (2) << 16
    swp
    rol8
    byt     // (3)
    rol8
    exw     // (3) << 24
    or      // (3) | (2)
    or      // (3) | (2) | (1)
    or      // (3) | (2) | (1) | (0)
}
    return __pop__();
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License