From a655e67bd38ffd9fa99df7ddc061931ed87c6da7 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 20 Apr 2016 02:35:57 -0700 Subject: [PATCH] fix align/skip fill value overflow --- lips/Dumper.lua | 4 ++-- lips/Parser.lua | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lips/Dumper.lua b/lips/Dumper.lua index 5a41c45..9cb1837 100644 --- a/lips/Dumper.lua +++ b/lips/Dumper.lua @@ -127,13 +127,13 @@ function Dumper:add_directive(fn, line, name, a, b) end local temp = self.pos + align - 1 t.skip = temp - (temp % align) - self.pos - t.fill = t.fill or 0 + t.fill = b and b % 0x100 or 0 insert(self.commands, t) self:advance(t.skip) elseif name == 'SKIP' then t.kind = 'ahead' t.skip = a - t.fill = b + t.fill = b and b % 0x100 or nil insert(self.commands, t) self:advance(t.skip) else diff --git a/lips/Parser.lua b/lips/Parser.lua index bb2ce09..ff0a774 100644 --- a/lips/Parser.lua +++ b/lips/Parser.lua @@ -23,7 +23,6 @@ function Parser:directive() local function add(...) self.dumper:add_directive(self.fn, self.line, ...) end - -- FIXME: some of these directives allow byte values greater than 255 if name == 'ORG' then add(name, self:number().tok) elseif name == 'ALIGN' or name == 'SKIP' then