Skip to content

Instantly share code, notes, and snippets.

@usrnatc
Created January 30, 2026 05:15
Show Gist options
  • Select an option

  • Save usrnatc/b2a126c007d240a497bfe468e3a1027b to your computer and use it in GitHub Desktop.

Select an option

Save usrnatc/b2a126c007d240a497bfe468e3a1027b to your computer and use it in GitHub Desktop.
16-, 32-, and 64-bit byteswap implementation for win32 with no CRT
;; win32_bswap.asm
;;
;; This is intended as a replacement to the MS _byteswap_xxxx functions
;; This is unneeded if not build with /NODEFAULTLIB
;;
.code
_byteswap_ulong proc
bswap ecx
mov eax, ecx
ret
_byteswap_ulong endp
_byteswap_uint64 proc
bswap rcx
mov rax, rcx
ret
_byteswap_uint64 endp
_byteswap_ushort proc
xchg cl, ch
movzx eax, cx
ret
_byteswap_ushort endp
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment