Difference between revisions of "IC10"
From Unofficial Stationeers Wiki
m (added device highlighting and fixed r6-r9) |
m (added a bunch more opcodes) |
||
| Line 3: | Line 3: | ||
-- List of IC10 opcodes (all strings) | -- List of IC10 opcodes (all strings) | ||
local opcodes = { | local opcodes = { | ||
| − | "add"," | + | "abs","add","alias","and", |
| − | " | + | "b","beq","beqz","bge","bgez","bgt","blt","bne", |
| − | " | + | "ceil","clrd","clr","define","div","exp","floor", |
| − | "move"," | + | "get","getd","hcf","ins","jr","jal","j","lerp", |
| − | " | + | "l","lb","lbn","lbs","log","ls","lr","max","min", |
| − | "s","sb", | + | "mod","move","mul","not","nor","or","pop","poke", |
| − | "yield" | + | "pow","put","putd","push","peek","rand","round", |
| + | "rmap","s","sb","sbn","sbs","select","sla","sll", | ||
| + | "sra","srl","sub","sqrt","trunc","yield", | ||
| + | "sap","sapz","seq","seqz", | ||
| + | "sge","sgez","sgt","sgtz","sle","slez","slt","sltz", | ||
| + | "sna","snan","snanz","snaz","sne","snez" | ||
} | } | ||
Revision as of 23:51, 19 February 2026
Documentation for this module may be created at Module:IC10/doc
local p = {}
-- List of IC10 opcodes (all strings)
local opcodes = {
"abs","add","alias","and",
"b","beq","beqz","bge","bgez","bgt","blt","bne",
"ceil","clrd","clr","define","div","exp","floor",
"get","getd","hcf","ins","jr","jal","j","lerp",
"l","lb","lbn","lbs","log","ls","lr","max","min",
"mod","move","mul","not","nor","or","pop","poke",
"pow","put","putd","push","peek","rand","round",
"rmap","s","sb","sbn","sbs","select","sla","sll",
"sra","srl","sub","sqrt","trunc","yield",
"sap","sapz","seq","seqz",
"sge","sgez","sgt","sgtz","sle","slez","slt","sltz",
"sna","snan","snanz","snaz","sne","snez"
}
-- Build lookup table
local opcode_lookup = {}
for _, op in ipairs(opcodes) do
opcode_lookup[op] = true
end
local function highlight_line(line)
line = mw.text.nowiki(line)
-- comments
line = string.gsub(line, "(#.*)",
'<span style="color:#6a9955;font-style:italic;">%1</span>')
-- labels
line = string.gsub(line, "^(%w+:)",
'<span style="color:#dcdcaa;">%1</span>')
-- registers r0–r15
line = string.gsub(line, "%f[%w](r([0-9]|1[0-5]))%f[%W]",
'<span style="color:#4fc1ff;">%1</span>')
-- devices d0–d5
line = string.gsub(line, "%f[%w](d[0-5])%f[%W]",
'<span style="color:#4fc1ff;">%1</span>')
-- numbers hex
line = string.gsub(line, "%f[%w](%-?0x%x+)%f[%W]",
'<span style="color:#b5cea8;">%1</span>')
-- numbers decimal
line = string.gsub(line, "%f[%w](%-?%d+)%f[%W]",
'<span style="color:#b5cea8;">%1</span>')
-- opcodes
for op,_ in pairs(opcode_lookup) do
line = string.gsub(line,
"%f[%w]("..op..")%f[%W]",
'<span style="color:#c586c0;font-weight:bold;">%1</span>')
end
return line
end
function p.highlight(frame)
local text = frame.args[1] or ""
local lines = mw.text.split(text, "\n")
for i,line in ipairs(lines) do
lines[i] = highlight_line(line)
end
return '<pre style="font-family:monospace; background-color:#f8f9fa; border:1px solid #eaecf0; white-space:pre; display:block; padding:8px;">'
.. table.concat(lines, "\n") ..
'</pre>'
end
return p
