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})