Module:GameboyAssembler
Appearance
Documentation for this module may be created at Module:GameboyAssembler/doc
--[[
This module is a very deep WIP. Do /not/ use. Feel free to contribute if you want, however.
Thanks, Moony.
]]
local p = {}
local data = mw.loadData('Module:GameboyAssembler/data')
local bit = require('bit');
local opcode = {};
do
local opcode_mt = {}
function opcode_mt:clone()
return setmetatable({
dword = self.dword,
length = self.length
}, opcode_mt)
end
function opcode:dump()
return ("%08X "):rep(#self.dwords):format(unpack(self.dwords))
end
function opcode:addbyte(by)
if (self.length >= 4) then
error("Out of range. GB instrs are at most 4 bytes!")
end
self.dword = self.dword + bit.lshift(by, self.length * 8)
return self
end
function opcode.make(by, size)
return setmetatable({
dword = by,
length = math.ceil(size)
}, opcode_mt)
end
end
-- Temporary nonsense below this line.
p.data = data
return p