mirror of
https://github.com/g012/l65.git
synced 2025-01-21 02:33:58 +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
|
end end
|
||||||
|
|
||||||
-- position independent sections
|
-- 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
|
for _,section in ipairs(position_independent_sections) do
|
||||||
local chunks = {}
|
local chunks = {}
|
||||||
for _,chunk in ipairs(location.chunks) do
|
for _,chunk in ipairs(location.chunks) do
|
||||||
@ -87,8 +87,13 @@ M.link = function()
|
|||||||
if constraint.type == 'samepage' then goto constraints_not_met end
|
if constraint.type == 'samepage' then goto constraints_not_met end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local w = math.min(address - chunk.start, chunk.size - (address - chunk.start))
|
local w = math.min(address - chunk.start, chunk.size - (address+section.size - chunk.start))
|
||||||
if w < waste then waste=w position=address end
|
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::
|
::constraints_not_met::
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -197,6 +202,10 @@ M.writesym = function(filename)
|
|||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.getstats = function()
|
||||||
|
return 'TODO' -- TODO
|
||||||
|
end
|
||||||
|
|
||||||
M.location = function(start, finish)
|
M.location = function(start, finish)
|
||||||
if type(start) == 'table' then
|
if type(start) == 'table' then
|
||||||
for _,v in ipairs(locations) do if v == start then
|
for _,v in ipairs(locations) do if v == start then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user