Skip to content

Commit

Permalink
Merge branch 'bits'
Browse files Browse the repository at this point in the history
  • Loading branch information
ElvishJerricco committed Sep 19, 2015
2 parents 67367ed + ea4d2e5 commit b556e5d
Show file tree
Hide file tree
Showing 5 changed files with 562 additions and 15 deletions.
24 changes: 12 additions & 12 deletions asm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ local InstructionTypes = { }
local sbxBias = 131071 -- (2^18 - 1) >> 1

function InstructionTypes.ABC(opcode, a, b, c)
a = bit.blshift(a, 6)
b = bit.blshift(b, 23)
c = bit.blshift(c, 14)
return bit.band(opcode + a + b + c, 2^32 - 1)
a = lshift(a, 6)
b = lshift(b, 23)
c = lshift(c, 14)
return band(opcode + a + b + c, 2^32 - 1)
end

function InstructionTypes.ABx(opcode, a, bx)
a = bit.blshift(a, 6)
bx = bit.blshift(bx, 14)
return bit.band(opcode + a + bx, 2^32 - 1)
a = lshift(a, 6)
bx = lshift(bx, 14)
return band(opcode + a + bx, 2^32 - 1)
end

function InstructionTypes.AsBx(opcode, a, sbx)
a = bit.blshift(a, 6)
a = lshift(a, 6)
sbx = sbx + sbxBias
sbx = bit.blshift(sbx, 14)
return bit.band(opcode + a + sbx, 2^32 - 1)
sbx = lshift(sbx, 14)
return band(opcode + a + sbx, 2^32 - 1)
end

function InstructionTypes.AB(opcode, a, b)
Expand Down Expand Up @@ -136,7 +136,7 @@ function makeChunkStream(numParams)
rk = stream.alloc()
stream.LOADK(rk, constant)
else
rk = bit.bor(256, constant)
rk = bor(256, constant)
end
return rk
end
Expand All @@ -152,7 +152,7 @@ function makeChunkStream(numParams)
rk = stream.alloc()
stream.LOADK(rk, constant)
else
rk = bit.bor(256, constant)
rk = bor(256, constant)
end
return rk, stream.allocRK(...)
end
Expand Down
4 changes: 2 additions & 2 deletions bindump.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ function makeDumpster(platform)
local function dumpNum(n, bytes, forcedEndianness)
if (platform.endianness == 0 or forcedEndianness == 0) and forcedEndianness ~= 1 then
for i=bytes-1, 0, -1 do
dump.dumpByte(bit.band(bit.brshift(n, i * 8), 0xff))
dump.dumpByte(band(rshift(n, i * 8), 0xff))
end
elseif platform.endianness == 1 or forcedEndianness == 1 then
for i=0, bytes - 1 do
dump.dumpByte(bit.band(bit.brshift(n, i * 8), 0xff))
dump.dumpByte(band(rshift(n, i * 8), 0xff))
end
else
error("Unsupported endianness:" .. tostring(platform.endianness))
Expand Down
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<copy todir="build/asm" file="load_asm.lua" />
<copy todir="build/asm" file="platform.json" />
<copy todir="build/asm" file="platform.lua" />
<copy todir="build/asm" file="numberlua.lua" />

<zip zip64Mode="never" destfile="build/asm.zip" basedir="build/asm" />
</target>
Expand Down
3 changes: 2 additions & 1 deletion load_asm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ local files = {
"asm.lua",
"bindump.lua",
"platform.lua",
"json.lua"
"json.lua",
"numberlua.lua"
}

for i,v in ipairs(files) do
Expand Down
Loading

0 comments on commit b556e5d

Please sign in to comment.