lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

It was thus said that the Great Flyer31 Test once stated:
> By the way for "bit witchraft", it would be very nice if the math
> library would support the VERY useful ARM commands clz and rbit  e. g.
> math.clz and math.rbit (Count leading zeros and reverse bits). I know
> that especially "good old Intel CPU''s" are lazy here and partly do
> not support this, and still no standardized c/c++ coding available for
> this - but these two are really VERY useful for bit representation
> checking and if not available in a standardized way by basic software,
> very nerving  and time consuming for loops are needed).

  You could always make a Lua module for those two instructions.  Back in
2020 I wrote a Lua module in x86 assembly [1][2] just to wrap the Intel x86
RDTSC instruction, so I don't see why this couldn't be done for the ARM CLZ
and RBIT instructions.



[2]	Overkill?  Sure.  And silly, as 8K of memory space is consumed by
	this very small module when running.  But mainly I did it just