Skip to content

Instantly share code, notes, and snippets.

@stepantubanov
Last active June 5, 2021 03:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stepantubanov/1867a3662ba1098a42cf5837870c662c to your computer and use it in GitHub Desktop.
Save stepantubanov/1867a3662ba1098a42cf5837870c662c to your computer and use it in GitHub Desktop.
arm64 binary to hex
// Suggestion for https://codereview.stackexchange.com/questions/256828/binary-to-hex-in-arm64-simd-assembly
rev x1, x1
# x1 = low nibble
# x2 = high nibble
and x2, x1, #0xf0f0f0f0f0f0f0f0
lsr x2, x2, #4
and x1, x1, #0x0f0f0f0f0f0f0f0f
fmov d0, x1
fmov d1, x2
// Interleave
zip1 v0.16b, v1.16b, v0.16b
ldr q1, hex_table
tbl v0.16b, { v1.16b }, v0.16b
st1 { v0.16b }, [x0]
strb wzr, [x0, #16]
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment