-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathhoge.lua
More file actions
47 lines (37 loc) · 717 Bytes
/
hoge.lua
File metadata and controls
47 lines (37 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
luabit= require "./luabit"
function doit(a,b)
print(a,b,luabit.brshift(a,b))
end
doit(0,1)
doit(1,1)
doit(2,1)
doit(-1,1)
doit(-2,1)
doit(-4,1)
doit(-8,1)
doit(-16,1)
doit(-1024,1)
function int16to2byte(n)
if n < 0 then
n = n + 65536
end
return math.floor(n / 256), n % 256
end
print("----------")
print(0, int16to2byte( 0))
print(1, int16to2byte( 1))
print(254, int16to2byte(254))
print(255, int16to2byte(255))
print(-1, int16to2byte(-1))
print(-2, int16to2byte(-2))
print("---------")
function orit(a,b)
print(a,b, luabit.bor(a,b) % 256 )
end
orit(0xf0,0x1)
orit(0xe0,-1)
orit(0xe0,-15)
-- make 8bit with [0x high4 low4]
function bit_4_4_or(high4,low4)
return high4*16 + low
end