From fa082d3a1d259c364309d4eeac22a9e7799b8b22 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Tue, 22 Dec 2015 06:37:40 -0800 Subject: [PATCH] misc --- Lua/inject.lua | 8 ++++---- Lua/inject/lips.lua | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Lua/inject.lua b/Lua/inject.lua index c6dffea..b8d1fa7 100644 --- a/Lua/inject.lua +++ b/Lua/inject.lua @@ -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 diff --git a/Lua/inject/lips.lua b/Lua/inject/lips.lua index 1ca76c9..e9c907a 100644 --- a/Lua/inject/lips.lua +++ b/Lua/inject/lips.lua @@ -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