To get a diversion from the "core" Topaz code, I started working on an assembler. It is progressing really fast, and can convert
:class MyClass
:func MyFunc
PUSH 1
PUSH 2
THISCALL __add
PEEK tmp
PUSH "The result is %d"
THISCALL format
PUSHG io
STACALL writeln
PUSH 3
THISCALL __eq
:branch
.When true
PUSH "Result == 3"
PUSHG io
STACALL writeln
.End
.When false
PUSH "Result != 3"
PUSHG io
STACALL writeln
.End
.End
into
MyClass = { -- :class MyClass
MyFunc = { -- :func MyFunc
{0x11, 1}, -- PUSH 1
{0x11, 2}, -- PUSH 2
{0x41, "__add"}, -- THISCALL __add
{0x31, "tmp"}, -- PEEK tmp
{0x11, "\"The result is %d\""}, -- PUSH "The result is %d"
{0x41, "format"}, -- THISCALL format
{0xFFFFFFFF, "io"}, -- PUSHG io
{0x42, "writeln"}, -- STACALL writeln
{0x11, 3}, -- PUSH 3
{0x41, "__eq"}, -- THISCALL __eq
{0x61, nil} -- :branch
{ -- :branch
[true] = { -- .When true
{0x11, "\"Result == 3\""}, -- PUSH "Result == 3"
{0xFFFFFFFF, "io"}, -- PUSHG io
{0x42, "writeln"}, -- STACALL writeln
},
[false] = { -- .When false
{0x11, "\"Result != 3\""}, -- PUSH "Result != 3"
{0xFFFFFFFF, "io"}, -- PUSHG io
{0x42, "writeln"}, -- STACALL writeln
},
},
}
}
Of course, this is completely useless as long as the VM doesn't work, but it's nice to relax(?) with some simpler code.
2 comments:
Awesome!
Is there any chance that you could share the source-code, or maybe set up an SVN repo (wiremod.com maybe)?
Here
Keep in mind that code is far from finished and is only meant as a "playground" for me to test out ideas. Feel free to join the "team" and give me feedback on assembla.
Post a Comment