aboutsummaryrefslogtreecommitdiff
path: root/dynasm
diff options
context:
space:
mode:
Diffstat (limited to 'dynasm')
-rw-r--r--dynasm/dasm_x86.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/dynasm/dasm_x86.lua b/dynasm/dasm_x86.lua
index c51b8c5d..29c62ae5 100644
--- a/dynasm/dasm_x86.lua
+++ b/dynasm/dasm_x86.lua
@@ -1473,8 +1473,8 @@ local function dopattern(pat, args, sz, op, needrex)
1473 local rex = 0 1473 local rex = 0
1474 1474
1475 -- Limit number of section buffer positions used by a single dasm_put(). 1475 -- Limit number of section buffer positions used by a single dasm_put().
1476 -- A single opcode needs a maximum of 2 positions. !x64 1476 -- A single opcode needs a maximum of 5 positions.
1477 if secpos+2 > maxsecpos then wflush() end 1477 if secpos+5 > maxsecpos then wflush() end
1478 1478
1479 -- Process each character. 1479 -- Process each character.
1480 for c in gmatch(pat.."|", ".") do 1480 for c in gmatch(pat.."|", ".") do
@@ -1676,6 +1676,7 @@ end
1676if x64 then 1676if x64 then
1677 function map_op.mov64_2(params) 1677 function map_op.mov64_2(params)
1678 if not params then return { "reg, imm", "reg, [disp]", "[disp], reg" } end 1678 if not params then return { "reg, imm", "reg, [disp]", "[disp], reg" } end
1679 if secpos+2 > maxsecpos then wflush() end
1679 local opcode, op64, sz, rex 1680 local opcode, op64, sz, rex
1680 local op64 = match(params[1], "^%[%s*(.-)%s*%]$") 1681 local op64 = match(params[1], "^%[%s*(.-)%s*%]$")
1681 if op64 then 1682 if op64 then
@@ -1724,6 +1725,7 @@ local function op_data(params)
1724 else 1725 else
1725 wputszarg(sz, a.imm) 1726 wputszarg(sz, a.imm)
1726 end 1727 end
1728 if secpos+2 > maxsecpos then wflush() end
1727 end 1729 end
1728end 1730end
1729 1731
@@ -1768,6 +1770,7 @@ end
1768-- Label pseudo-opcode (converted from trailing colon form). 1770-- Label pseudo-opcode (converted from trailing colon form).
1769map_op[".label_2"] = function(params) 1771map_op[".label_2"] = function(params)
1770 if not params then return "[1-9] | ->global | =>pcexpr [, addr]" end 1772 if not params then return "[1-9] | ->global | =>pcexpr [, addr]" end
1773 if secpos+2 > maxsecpos then wflush() end
1771 local a = parseoperand(params[1]) 1774 local a = parseoperand(params[1])
1772 local mode, imm = a.mode, a.imm 1775 local mode, imm = a.mode, a.imm
1773 if type(imm) == "number" and (mode == "iJ" or (imm >= 1 and imm <= 9)) then 1776 if type(imm) == "number" and (mode == "iJ" or (imm >= 1 and imm <= 9)) then
@@ -1783,9 +1786,9 @@ map_op[".label_2"] = function(params)
1783 -- SETLABEL must immediately follow LABEL_LG/LABEL_PC. 1786 -- SETLABEL must immediately follow LABEL_LG/LABEL_PC.
1784 local addr = params[2] 1787 local addr = params[2]
1785 if addr then 1788 if addr then
1786 local a = parseoperand(params[2]) 1789 local a = parseoperand(addr)
1787 if a.mode == "iPJ" then 1790 if a.mode == "iPJ" then
1788 waction("SETLABEL", a.imm) -- !x64 (secpos) 1791 waction("SETLABEL", a.imm)
1789 else 1792 else
1790 werror("bad label assignment") 1793 werror("bad label assignment")
1791 end 1794 end
@@ -1798,6 +1801,7 @@ map_op[".label_1"] = map_op[".label_2"]
1798-- Alignment pseudo-opcode. 1801-- Alignment pseudo-opcode.
1799map_op[".align_1"] = function(params) 1802map_op[".align_1"] = function(params)
1800 if not params then return "numpow2" end 1803 if not params then return "numpow2" end
1804 if secpos+1 > maxsecpos then wflush() end
1801 local align = tonumber(params[1]) or map_opsizenum[map_opsize[params[1]]] 1805 local align = tonumber(params[1]) or map_opsizenum[map_opsize[params[1]]]
1802 if align then 1806 if align then
1803 local x = align 1807 local x = align
@@ -1817,6 +1821,7 @@ end
1817-- Spacing pseudo-opcode. 1821-- Spacing pseudo-opcode.
1818map_op[".space_2"] = function(params) 1822map_op[".space_2"] = function(params)
1819 if not params then return "num [, filler]" end 1823 if not params then return "num [, filler]" end
1824 if secpos+1 > maxsecpos then wflush() end
1820 waction("SPACE", params[1]) 1825 waction("SPACE", params[1])
1821 local fill = params[2] 1826 local fill = params[2]
1822 if fill then 1827 if fill then