mirror of
https://github.com/g012/l65.git
synced 2025-01-01 06:30:16 +00:00
Optimized a bit linking strategy.
This commit is contained in:
parent
86d46f101e
commit
59a2a614ba
15
6502.lua
15
6502.lua
@ -62,7 +62,7 @@ M.link = function()
|
||||
end end
|
||||
|
||||
-- position independent sections
|
||||
table.sort(position_independent_sections, function(a,b) return a.size < b.size end)
|
||||
table.sort(position_independent_sections, function(a,b) return a.size==b.size and a.label>b.label or a.size>b.size end)
|
||||
for _,section in ipairs(position_independent_sections) do
|
||||
local chunks = {}
|
||||
for _,chunk in ipairs(location.chunks) do
|
||||
@ -87,8 +87,13 @@ M.link = function()
|
||||
if constraint.type == 'samepage' then goto constraints_not_met end
|
||||
end
|
||||
end
|
||||
local w = math.min(address - chunk.start, chunk.size - (address - chunk.start))
|
||||
if w < waste then waste=w position=address end
|
||||
local w = math.min(address - chunk.start, chunk.size - (address+section.size - chunk.start))
|
||||
if w < waste then waste=w position=address
|
||||
elseif w==waste then
|
||||
-- if waste is the same, keep the one that leaves most aligned addresses for other sections
|
||||
-- TODO
|
||||
if position and address>position then waste=w position=address end
|
||||
end
|
||||
::constraints_not_met::
|
||||
end
|
||||
end
|
||||
@ -197,6 +202,10 @@ M.writesym = function(filename)
|
||||
f:close()
|
||||
end
|
||||
|
||||
M.getstats = function()
|
||||
return 'TODO' -- TODO
|
||||
end
|
||||
|
||||
M.location = function(start, finish)
|
||||
if type(start) == 'table' then
|
||||
for _,v in ipairs(locations) do if v == start then
|
||||
|
Loading…
Reference in New Issue
Block a user