|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
function lbl(labelname) nasm(0, format("%s:\n", labelname)) end
function glbl(labelname)
nasm(0, format(" global %s\n", labelname))
lbl(labelname)
end
function tolbl(labelname) nasm(2, format("\tdw %s -_f0\n", labelname)) end
ntmplabels = 0
tmplabelstack = {}
tmplabelpush = function( str ) end
tmplabelpop = function( ) return tremove(tmplabelstack, 1) end
tmplabelname = function( str )
local labelname, _, n
if str == ">" then -- push a new tmplabel on the stack
ntmplabels = ntmplabels + 1
labelname = "LBL_"..ntmplabels
tinsert(tmplabelstack, 1, labelname)
return labelname
else
_, _, n = strfind(str, "^<([0-9]*)$")
if n then -- pop some tmplabel from the stack
return tremove(tmplabelstack, tonumber(n))
end
end
return "LBL_"..nasmify(str)
end
gettmplabelname = function( ) return tmplabelname(getword()) end
dict["lbl:"] = function() lbl(gettmplabelname()) end
dict["tolbl"] = function() tolbl(gettmplabelname()) end
dict["if"] = function() mf("0BRANCH tolbl >") end
dict["else"] = function() mf(" BRANCH tolbl > lbl: <2") end
dict["then"] = function() mf("lbl: <1") end