1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-05-18 05:23:22 -07:00
This commit is contained in:
Connor Olding 2015-12-22 06:37:40 -08:00
parent 108c4189ef
commit fa082d3a1d
2 changed files with 6 additions and 4 deletions

View File

@ -70,7 +70,7 @@ function inject(fn)
local inject_bytes = {}
local length = 0
local function add_word(pos, line)
local function write(pos, line)
length = length + #line/2
dprint(("%08X"):format(pos), line)
pos = pos % 0x80000000
@ -79,11 +79,11 @@ function inject(fn)
-- offset assembly labels so they work properly, and assemble!
local true_offset = 0x80000000 + inject_addr
assemble(header, add_word, {unsafe=true, offset=true_offset})
assemble(asm_path, add_word, {unsafe=true, offset=true_offset + length})
assemble(header, write, {unsafe=true, offset=true_offset})
assemble(asm_path, write, {unsafe=true, offset=true_offset + length})
printf("length: %i words", length/4)
if #inject_bytes > inject_maxlen then
if length > inject_maxlen then
print("Assembly too large!")
return
end

View File

@ -1015,6 +1015,8 @@ function Parser:instruction()
local h = instructions[name]
self:advance()
-- FIXME: errors thrown here probably have the wrong line number (+1)
if h == nil then
self:error('undefined instruction')
elseif h == 'LI' then