1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2025-02-05 13:23:23 -08:00

update lips; update lips writers

This commit is contained in:
Connor Olding 2016-04-10 08:56:42 -07:00
parent d19fd2d3ae
commit ff3305d273
4 changed files with 8 additions and 12 deletions

View file

@ -112,16 +112,15 @@ local function inject(fn, dumb)
local inject_bytes = {} local inject_bytes = {}
local size = 0 local size = 0
local cons_pos = inject_addr local cons_pos = inject_addr
local function write(pos, line) local function write(pos, b)
assert(#line == 2, "that ain't const") dprint(("%08X %02X"):format(pos, b))
dprint(("%08X"):format(pos), line)
pos = pos % 0x80000000 pos = pos % 0x80000000
size = size + 1 size = size + 1
-- FIXME: doesn't detect .skip/.space directives -- FIXME: doesn't detect .skip/.space directives
if pos > cons_pos and (pos < inject_end or cons_pos == pos - 1) then if pos > cons_pos and (pos < inject_end or cons_pos == pos - 1) then
cons_pos = pos cons_pos = pos
end end
inject_bytes[pos] = tonumber(line, 16) inject_bytes[pos] = b
end end
-- offset assembly labels so they work properly, and assemble! -- offset assembly labels so they work properly, and assemble!

View file

@ -233,8 +233,7 @@ end
function Dumper:write(t) function Dumper:write(t)
for _, b in ipairs(t) do for _, b in ipairs(t) do
local s = ('%02X'):format(b) self.writer(self.pos, b)
self.writer(self.pos, s)
self.pos = self.pos + 1 self.pos = self.pos + 1
end end
end end

View file

@ -18,7 +18,7 @@ function lips.word_writer()
local max = -1 local max = -1
return function(pos, b) return function(pos, b)
if pos then if pos then
buff[pos] = b buff[pos] = ("%02X"):format(b)
if pos > max then if pos > max then
max = pos max = pos
end end

View file

@ -21,8 +21,7 @@ local function inject(args)
end end
end end
local function write(pos, line) local function write(pos, b)
assert(#line == 2, "that ain't const")
if args.extra_rom and args.extra_ram and pos >= args.extra_ram then if args.extra_rom and args.extra_ram and pos >= args.extra_ram then
pos = pos - args.extra_ram + args.extra_rom pos = pos - args.extra_ram + args.extra_rom
elseif pos >= args.offset then elseif pos >= args.offset then
@ -30,15 +29,14 @@ local function inject(args)
end end
if pos >= 1024*1024*1024 then if pos >= 1024*1024*1024 then
print("you probably don't want to do this:") print("you probably don't want to do this:")
print(("%08X"):format(pos), line) print(("%08X %02X"):format(pos, b))
return return
end end
f:seek('set', pos) f:seek('set', pos)
-- TODO: write hex dump format of written bytes -- 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 end
assemble(args.input, write, {unsafe=true, offset=args.offset, labels=state}) assemble(args.input, write, {unsafe=true, offset=args.offset, labels=state})