luametalatex/luametalatex-bit32.lua

22 lines
431 B
Lua
Raw Normal View History

2019-07-17 21:14:34 +02:00
local mask32 = 0xFFFFFFFF
return {
rshift = function(i, s)
return (mask32 & i) >> s
end,
lshift = function(i, s)
return mask32 & (i << s)
end,
band = function(i, j)
return i & j & mask32
end,
bor = function(i, j)
return (i | j) & mask32
end,
bor = function(i, j)
return (i ^ j) & mask32
end,
extract = function(v, shift, count)
return ((mask32 & v) >> shift) & ((1<<count)-1)
2019-07-17 21:14:34 +02:00
end,
}