mirror of
https://github.com/notwa/mm
synced 2025-02-05 05:23:22 -08:00
fix asm length calculation
This commit is contained in:
parent
8a666f7dfc
commit
9cd9381463
1 changed files with 4 additions and 3 deletions
|
@ -49,14 +49,15 @@ start:
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local inject = {}
|
local inject = {}
|
||||||
|
local length = 0
|
||||||
local add_inject = function(line)
|
local add_inject = function(line)
|
||||||
--print(line)
|
length = length + #line/2
|
||||||
table.insert(inject, tonumber(line, 16))
|
table.insert(inject, tonumber(line, 16))
|
||||||
end
|
end
|
||||||
local true_offset = 0x80000000 + inject_addr
|
local true_offset = 0x80000000 + inject_addr
|
||||||
assemble(header, add_inject, {unsafe=true, offset=true_offset})
|
assemble(header, add_inject, {unsafe=true, offset=true_offset})
|
||||||
-- warning: assumes each line is 4 bytes long
|
assemble(asm_path, add_inject, {unsafe=true, offset=true_offset + length})
|
||||||
assemble(asm_path, add_inject, {unsafe=true, offset=true_offset + #inject*4})
|
printf("length: %i words", length/4)
|
||||||
|
|
||||||
if #inject > inject_maxlen then
|
if #inject > inject_maxlen then
|
||||||
print("Assembly too large!")
|
print("Assembly too large!")
|
||||||
|
|
Loading…
Add table
Reference in a new issue