This commit is contained in:
Andre Wagner
2026-05-06 12:00:53 -05:00
parent 7ecffcfdda
commit 8f851a330e
3 changed files with 8 additions and 8 deletions

View File

@@ -5,9 +5,9 @@ Progress of the Lua port:
- [x] Logic/arithmetic expressions
- [x] Variables
- [x] Local variables
- [ ] Functions
- [ ] Calling functions
- [ ] Calling functions with parameters
- [x] Functions
- [x] Calling functions
- [x] Calling functions with parameters
- [ ] Control flow
- [ ] Lablels in Assembly
- [ ] Recursion

View File

@@ -198,7 +198,7 @@ do TEST("VM: local variables")
end
do TEST("VM: functions")
local vm = VM:new():set_debug(true):load(assemble([[
local vm = VM:new():load(assemble([[
.func 0
pushf 1
pushi 2
@@ -208,12 +208,12 @@ do TEST("VM: functions")
.func 1
dupv 0
dupv 1
sum
sub
ret
]])):call(0)
assert_eq(vm:stack_sz(), 1)
assert_eq(vm:to_integer(-1), 5)
assert_eq(vm:to_integer(-1), -1)
end
print('End.')

View File

@@ -340,11 +340,11 @@ function VM:_step()
elseif op.operator == 'set' then
assert(op.operand >= 0)
local a = self.stack:pop()
self.stack[op.operand + 1] = a
self.stack[op.operand] = a
elseif op.operator == 'dupv' then
assert(op.operand >= 0)
local a = self.stack[op.operand + 1]
local a = self.stack[op.operand]
self.stack:push(a)
--