mirror of
https://github.com/notwa/mm
synced 2024-11-04 22:49:03 -08:00
update lips; update lips writers
This commit is contained in:
parent
d19fd2d3ae
commit
ff3305d273
4 changed files with 8 additions and 12 deletions
|
@ -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!
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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})
|
||||
|
|
Loading…
Reference in a new issue