1
0
Fork 0
mirror of https://github.com/notwa/lips synced 2024-11-14 09:59:03 -08:00

use 2**n alignment instead of 2*n

This commit is contained in:
Connor Olding 2016-01-13 11:46:29 -08:00
parent f8805e6deb
commit 7c4becf0b6
2 changed files with 9 additions and 7 deletions

View file

@ -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}`

View file

@ -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