luametalatex/luametalatex-bit32.lua

22 lines
430 B
Lua

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 ((bit32 & v) >> shift) & ((1<<count)-1)
end,
}