Module:Instruction set table builder: Difference between revisions

Added final formatting. Functions should be finished for now.
No edit summary
(Added final formatting. Functions should be finished for now.)
Line 21:
return output
end
 
function formatMnemonic(str)
str = str:gsub("rd", "r{{sub|d}}")
str = str:gsub("rs", "r{{sub|s}}")
str = str:gsub("rt", "r{{sub|t}}")
return str
end
 
function formatDescription(str)
str = formatMnemonic(str)
str = str:gsub("immediate", "\'\'immediate\'\'")
str = str:gsub("sa", "\'\'sa\'\'")
str = str:gsub("offset", "\'\'offset\'\'")
str = str:gsub("target", "\'\'target\'\'")
str = str:gsub("LO", "\'\'LO\'\'")
str = str:gsub("HI", "\'\'HI\'\'")
return str
end
 
Line 52 ⟶ 72:
for i = 1, #arr, 4 do
local mnemonic = formatMnemonic( string.gsub(string.format("%-10s", arr[i]), " ", " ") .. arr[i + 1] )
local descrip = formatDescription( arr[i + 2] )
local word = string.addSpacing(string.gsub(arr[i + 3], " ", ""), 4)
s = s .. "|-\n"
s = s .. "| style=\"text-align: left; font-family: Consolas,Monaco,Lucida Console,monospace;\"| " .. string.gsub(string.format("%-10s", arr[i]), " ", " ") .. arr[i + 1]mnemonic
.. " || style=\"text-align: left; font-family: Consolas,Monaco,Lucida Console,monospace;\"| " .. arr[i + 2]descrip
.. " || style=\"font-family: Consolas,Monaco,Lucida Console,monospace;\"| " .. string.addSpacing(string.gsub(arr[i + 3], " ", ""), 4)word
.. "\n"
end