From 7c4becf0b6841ddd9ec330510312d47fb8177054 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 13 Jan 2016 11:46:29 -0800 Subject: [PATCH] use 2**n alignment instead of 2*n --- README.md | 8 ++++---- lips/Dumper.lua | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e65730b..bfb0483 100644 --- a/README.md +++ b/README.md @@ -113,13 +113,13 @@ be wary of potential alignment issues. writes a series of 32-bit numbers until end-of-line. * `.align [n] [fill]` -aligns the next datum to a `n*2` boundary using `fill` for spacing. -if `n` is not given, 2 is implied. -if `fill` is not given, 0 is implied. +aligns the next datum to a `2**n` boundary using `fill` for spacing. +if `n` is omitted, 2 is implied. +if `fill` is omitted, 0 is implied. * `.skip {n} [fill]` skips the next `n` bytes using `fill` for spacing. -if `fill` is not given, no bytes are overwritten, +if `fill` is omitted, no bytes are overwritten, and only the position is changed. * `.org {address}` diff --git a/lips/Dumper.lua b/lips/Dumper.lua index adb497c..ab86ac8 100644 --- a/lips/Dumper.lua +++ b/lips/Dumper.lua @@ -93,11 +93,13 @@ function Dumper:add_directive(line, name, a, b) self:advance(0) elseif name == 'ALIGN' then t.kind = 'ahead' - local align = a*2 - if align == 0 then + local align + if a == 0 then align = 4 - elseif align < 0 then + elseif a < 0 then self:error('negative alignment') + else + align = 2^a end local temp = self.pos + align - 1 t.skip = temp - (temp % align) - self.pos