mirror of
https://github.com/emptyynes/LIVM.git
synced 2025-01-04 23:52:25 +03:00
Add files via upload
This commit is contained in:
parent
560bc596ad
commit
45700a571c
9 changed files with 81 additions and 32 deletions
16
faxm.lua
16
faxm.lua
|
@ -1,7 +1,10 @@
|
||||||
local date = require"date"
|
local date = require"date"
|
||||||
local opcode = require"faxmopcode"
|
local opcode = require"faxmopcode"
|
||||||
local FX = {
|
local FX = {
|
||||||
|
--require"faxm/fraCinize",
|
||||||
require"faxm/string",
|
require"faxm/string",
|
||||||
|
require"faxm/ximplifier",
|
||||||
|
require"faxm/fraxevice",
|
||||||
require"faxm/freeform"
|
require"faxm/freeform"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,18 +68,17 @@ function parseCode(source, code, data)
|
||||||
local objects = {}
|
local objects = {}
|
||||||
for line in source:gmatch("([^;]+)") do
|
for line in source:gmatch("([^;]+)") do
|
||||||
for k, v in pairs(FX) do if v.any_line then line = v.any_line(line) end end
|
for k, v in pairs(FX) do if v.any_line then line = v.any_line(line) end end
|
||||||
if line == "[mainfile]" then
|
if line:sub(1, 1) == '[' then
|
||||||
elseif line:sub(1, 1) == '[' then
|
|
||||||
for k, v in pairs(date.decode(raw(line:sub(2, #line - 1):gsub("+", ":")))) do
|
for k, v in pairs(date.decode(raw(line:sub(2, #line - 1):gsub("+", ":")))) do
|
||||||
if type(k) == "number" then
|
if type(k) == "number" then
|
||||||
if v:sub(1, 1) == 'x' then xtype = v:sub(2, #v)
|
if v:sub(1, 1) == 'x' then xtype = v:sub(2, #v)
|
||||||
elseif v == "CODE" then section = code;
|
elseif v == "CODE" then section = code;
|
||||||
elseif v == "DATA" then section = data;
|
elseif v == "DATA" then section = data;
|
||||||
elseif k == "nominsize" then
|
elseif k == "noalign" then
|
||||||
if section == code then cminsize = -1
|
if section == code then cminsize = -1
|
||||||
else dminsize = -1 end
|
else dminsize = -1 end
|
||||||
end
|
end
|
||||||
elseif k == "minsize" then
|
elseif k == "align" then
|
||||||
if section == code then cminsize = v else dminsize = v end
|
if section == code then cminsize = v else dminsize = v end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -179,10 +181,8 @@ end
|
||||||
|
|
||||||
local file = io.open(source)
|
local file = io.open(source)
|
||||||
if file then
|
if file then
|
||||||
if file:read():gsub("%s", "") == "[mainfile]" then
|
file:seek("set", 0)
|
||||||
file:seek("set", 0)
|
parseCode(file:read"*a", code, data)
|
||||||
parseCode(file:read"*a", code, data)
|
|
||||||
end
|
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
local loader_segment = {
|
local loader_segment = {
|
||||||
|
|
5
faxm/fraCinize.lua
Normal file
5
faxm/fraCinize.lua
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
return {
|
||||||
|
source = function(source)
|
||||||
|
return source
|
||||||
|
end
|
||||||
|
}
|
14
faxm/fraxevice.lua
Normal file
14
faxm/fraxevice.lua
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
return {
|
||||||
|
source = function(source)
|
||||||
|
source = source:gsub("(%s*)console%.print%s+(%S+%s+%S+);", "%1console.write %2;%1console.out;")
|
||||||
|
source = source:gsub("(%a+)%.write", "write ____%1")
|
||||||
|
source = source:gsub("(%a+)%.out", "out ____%1")
|
||||||
|
source = source:gsub("(%a+)%.wait", "wait ____%1")
|
||||||
|
source = source:gsub("(%a+)%.read", "read ____%1")
|
||||||
|
source = source:gsub("____clock", "|0")
|
||||||
|
source = source:gsub("____timer", "|0")
|
||||||
|
source = source:gsub("____console", "|1")
|
||||||
|
source = source:gsub("____rom", "|2")
|
||||||
|
return source
|
||||||
|
end
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
return {
|
return {
|
||||||
source = function(source)
|
source = function(source)
|
||||||
return source:gsub("\n", ""):gsub("]", "];"):gsub(":", ":;")
|
return source:gsub("\n", "")
|
||||||
end,
|
end,
|
||||||
any_line = function(line)
|
any_line = function(line)
|
||||||
return line:trim():gsub("%s+", " ")
|
return line:trim():gsub("%s+", " "):gsub("%s+=%s+", "=")
|
||||||
end,
|
end,
|
||||||
line = function(line)
|
line = function(line)
|
||||||
return line:gsub(",", " "):gsub("%s+", " "):split" "
|
return line:gsub(",", " "):gsub("%s+", " "):split" "
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
return {
|
return {
|
||||||
source = function(source)
|
source = function(source)
|
||||||
|
local tl = {}
|
||||||
while source:match[[|"[^"]+"]] do
|
while source:match[[|"[^"]+"]] do
|
||||||
local s = source:match[[|"[^"]+"]]
|
local s = source:match[[|"[^"]+"]]
|
||||||
local ss = s
|
local ss = s
|
||||||
|
@ -16,11 +17,20 @@ return {
|
||||||
r[#r + 1] = "|x" .. table.concat(rt, "")
|
r[#r + 1] = "|x" .. table.concat(rt, "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if #(r[#r]:gsub("000", "")) == #(r[#r]) then
|
||||||
|
r[#r + 1] = "|x0000000000000000"
|
||||||
|
end
|
||||||
local function regexEscape(str)
|
local function regexEscape(str)
|
||||||
return str:gsub("[%(%)%.%%%+%-%*%?%[%^%$%]]", "%%%1")
|
return str:gsub("[%(%)%.%%%+%-%*%?%[%^%$%]]", "%%%1")
|
||||||
end
|
end
|
||||||
source = source:gsub(regexEscape(ss), table.concat(r, ", "))
|
local tt = table.concat(r, ", ")
|
||||||
|
tl[tt] = #r
|
||||||
|
source = source:gsub(regexEscape(ss), tt)
|
||||||
end
|
end
|
||||||
|
source = source:gsub("(string%s+(%w+)%s?:(%s+)([|xa-f0-9, ]+)[^;])", function(found)
|
||||||
|
found = "object" .. found:sub(7)
|
||||||
|
return found .. " ? length=|" .. tostring(tl[found:gsub("object%s+%w+%s?:(%s+)", "")] * 8)
|
||||||
|
end)
|
||||||
return source
|
return source
|
||||||
end
|
end
|
||||||
}
|
}
|
9
faxm/ximplifier.lua
Normal file
9
faxm/ximplifier.lua
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
source = function(source)
|
||||||
|
source = source:gsub("%(([^)]+)%)", " %1")
|
||||||
|
source = source:gsub("([|%^#][%w.]+%s+)([a-z]+)", "%1;%2"):gsub(":", ":;")
|
||||||
|
source = source:gsub("object", ";object"):gsub("section", ";section"):gsub("%[", ";["):gsub("%]", "];")
|
||||||
|
source = source:gsub("(\n%s+);", ";%1"):gsub(";(%s+);", ";%1"):gsub("^;", "")
|
||||||
|
return source .. ";"
|
||||||
|
end
|
||||||
|
}
|
21
main.faxm
21
main.faxm
|
@ -1,15 +1,8 @@
|
||||||
[mainfile]
|
[x64u+DATA+align-8]
|
||||||
[x64u+DATA+minsize-8]
|
string helloworld: |"hello world";
|
||||||
object helloworld:
|
string hellohell: |"hell-oh!";
|
||||||
|"hello world", |0 ?
|
[x64+CODE+noalign]
|
||||||
length=|12;
|
|
||||||
object hellohell:
|
|
||||||
|"hell-oh!", |0 ?
|
|
||||||
length=|9;
|
|
||||||
[x64+CODE+nominsize]
|
|
||||||
section start:
|
section start:
|
||||||
write |1 ^helloworld, #helloworld.length;
|
console.print(^helloworld, #helloworld.length)
|
||||||
out |1;
|
console.print(^hellohell, #hellohell.length)
|
||||||
write |1 ^hellohell, #hellohell.length;
|
poff
|
||||||
out |1;
|
|
||||||
poff;
|
|
30
opcodelist
30
opcodelist
|
@ -1,16 +1,34 @@
|
||||||
nop
|
nop
|
||||||
goto
|
goto
|
||||||
ive
|
iv
|
||||||
iveselei
|
ivse
|
||||||
selei
|
se
|
||||||
saveip
|
saveip
|
||||||
setspp
|
|
||||||
setsp
|
setsp
|
||||||
savesp
|
savesp
|
||||||
setdpp
|
|
||||||
setdp
|
setdp
|
||||||
savedp
|
savedp
|
||||||
poweroff
|
poff
|
||||||
|
pushu64
|
||||||
|
push64
|
||||||
|
pushd
|
||||||
|
pushu32
|
||||||
|
push32
|
||||||
|
pushf
|
||||||
|
pushu16
|
||||||
|
push16
|
||||||
|
pushu8
|
||||||
|
push8
|
||||||
|
popu64
|
||||||
|
pop64
|
||||||
|
popd
|
||||||
|
popu32
|
||||||
|
pop32
|
||||||
|
popf
|
||||||
|
popu16
|
||||||
|
pop16
|
||||||
|
popu8
|
||||||
|
pop8
|
||||||
ilsumu64
|
ilsumu64
|
||||||
ilsubu64
|
ilsubu64
|
||||||
ilmulu64
|
ilmulu64
|
||||||
|
|
2
out.fx
2
out.fx
|
@ -1 +1 @@
|
||||||
8, 1, 6, 1, 1, 16, 8, 1004, 8031924123371070824, 6581362, 0, 2407296241712784744, 0, 0, 0, 0, 399, 3, 1, 0, 30, 400, 1, 1, 399, 3, 1, 3, 31, 400, 1, 1, 10, 0, 0, 0, 0, 0, 12, 9
|
8, 1, 6, 1, 1, 16, 8, 1004, 8031924123371070824, 6581362, 2407296241712784744, 0, 0, 0, 0, 0, 399, 3, 1, 0, 30, 400, 1, 1, 399, 3, 1, 2, 31, 400, 1, 1, 10, 0, 0, 0, 0, 0, 16, 16
|
Loading…
Reference in a new issue