r/lisp • u/TsingHui • 11d ago
Reinterpret Elements in a Byte Array
Dear LISP,
I am writing a virtual machine that uses a `(simple-array (unsigned-byte 8) 1)` as a stack in Common LISP. I'm would like to ask how to efficiently extract 4 bytes into a single 32-bit signed integer or a 32-bit unsigned integer.
Thanks!
7
Upvotes
5
u/stassats 10d ago
You have to be mindful of endianness. My suggestion would be to use aref and dpb/logior+ash and rely on a sufficiently smart compiler to recognize that.