This commit is contained in:
Andre Wagner
2026-05-05 16:26:34 -05:00
parent 43dea6ee8f
commit 6428c6cf7f
3 changed files with 68 additions and 5 deletions

View File

@@ -118,10 +118,21 @@ end
----------------------
-- --
-- VM STACK --
-- VM ARITH --
-- --
----------------------
local function arith(a, b, op)
return VM:new():load(assemble(string.format([[
.func 0
pushi %d
pushi %d
%s
ret
]], a, b, op))):call(0)
end
do
local vm = VM:new()
-- vm.debug = true
@@ -144,4 +155,9 @@ do
assert_eq(vm:to_integer(-1), 5)
end
do
assert_eq(arith(2, 5, 'sum'):to_integer(-1), 7)
assert_eq(arith(2, 5, 'sub'):to_integer(-1), -3)
end
print('End.')