From ff3305d27321657e36874f52dc9d6e0ce44437ad Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sun, 10 Apr 2016 08:56:42 -0700 Subject: [PATCH] update lips; update lips writers --- Lua/inject.lua | 7 +++---- Lua/lib/lips/Dumper.lua | 3 +-- Lua/lib/lips/init.lua | 2 +- patch/patch.lua | 8 +++----- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Lua/inject.lua b/Lua/inject.lua index 6f717b1..1a23e99 100644 --- a/Lua/inject.lua +++ b/Lua/inject.lua @@ -112,16 +112,15 @@ local function inject(fn, dumb) local inject_bytes = {} local size = 0 local cons_pos = inject_addr - local function write(pos, line) - assert(#line == 2, "that ain't const") - dprint(("%08X"):format(pos), line) + local function write(pos, b) + dprint(("%08X %02X"):format(pos, b)) pos = pos % 0x80000000 size = size + 1 -- FIXME: doesn't detect .skip/.space directives if pos > cons_pos and (pos < inject_end or cons_pos == pos - 1) then cons_pos = pos end - inject_bytes[pos] = tonumber(line, 16) + inject_bytes[pos] = b end -- offset assembly labels so they work properly, and assemble! diff --git a/Lua/lib/lips/Dumper.lua b/Lua/lib/lips/Dumper.lua index 1792b41..c02345e 100644 --- a/Lua/lib/lips/Dumper.lua +++ b/Lua/lib/lips/Dumper.lua @@ -233,8 +233,7 @@ end function Dumper:write(t) for _, b in ipairs(t) do - local s = ('%02X'):format(b) - self.writer(self.pos, s) + self.writer(self.pos, b) self.pos = self.pos + 1 end end diff --git a/Lua/lib/lips/init.lua b/Lua/lib/lips/init.lua index 76768bb..74bc83b 100644 --- a/Lua/lib/lips/init.lua +++ b/Lua/lib/lips/init.lua @@ -18,7 +18,7 @@ function lips.word_writer() local max = -1 return function(pos, b) if pos then - buff[pos] = b + buff[pos] = ("%02X"):format(b) if pos > max then max = pos end diff --git a/patch/patch.lua b/patch/patch.lua index 490f35a..c046b9e 100644 --- a/patch/patch.lua +++ b/patch/patch.lua @@ -21,8 +21,7 @@ local function inject(args) end end - local function write(pos, line) - assert(#line == 2, "that ain't const") + local function write(pos, b) if args.extra_rom and args.extra_ram and pos >= args.extra_ram then pos = pos - args.extra_ram + args.extra_rom elseif pos >= args.offset then @@ -30,15 +29,14 @@ local function inject(args) end if pos >= 1024*1024*1024 then print("you probably don't want to do this:") - print(("%08X"):format(pos), line) + print(("%08X %02X"):format(pos, b)) return end f:seek('set', pos) -- TODO: write hex dump format of written bytes - --print(("%08X %s"):format(pos, line)) - f:write(string.char(tonumber(line, 16))) + f:write(string.char(b)) end assemble(args.input, write, {unsafe=true, offset=args.offset, labels=state})