Module:Instruction set table builder: Difference between revisions

Reduced font size for instruction table to shrink table width
No edit summary
(Reduced font size for instruction table to shrink table width)
 
(8 intermediate revisions by the same user not shown)
Line 21:
return output
end
 
function formatMnemonic(str)
str = str .. " "
str = str:gsub("rd ", "r<sub>d</sub> ")
str = str:gsub("rd,", "r<sub>d</sub>,")
str = str:gsub("rs", "r<sub>s</sub>")
str = str:gsub("rt", "r<sub>t</sub>")
str = str:gsub("r'd", "rd")
str = str:gsub("r't", "rt")
str = str:gsub("r's", "rs")
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 44 ⟶ 70:
function p.set( frame )
local args = getArgs(frame)
local s = "{| class=\"wikitable\" style=\"text-align: center; font-size: 85%;\"\n! Mnemonic !! Description !! 32-bit Instruction Word\n"
local arr = {}
Line 52 ⟶ 78:
for i = 1, #arr, 4 do
local mnemonic = formatMnemonic( string.gsub(string.format("%-10s", arr[i]), " ", "&nbsp;") .. arr[i + 1] )
mnemonic = mnemonic:gsub(arr[i], "[[#"..arr[i].."|"..arr[i].."]]")
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;\"| "padding: ..1px string.gsub(string.format("%-10s",7px arr[i]),1px 7px;\"| ", "&nbsp;") .. arr[i + 1]mnemonic
.. " || style=\"text-align: left; font-family: Consolas,Monaco,Lucida Console,monospace; padding: 1px 7px 1px 7px;\"| " .. arr[i + 2]descrip
.. " || style=\"font-family: Consolas,Monaco,Lucida Console,monospace;\"| "padding: ..1px string.addSpacing(string.gsub(arr[i7px + 3],1px 7px;\"| ", ""),.. 4)word
.. "\n"
end