Add conditional call instructions

This commit is contained in:
Ian Gulliver
2021-11-19 16:24:04 -10:00
parent 6e36152b6a
commit 7a24eee583
4 changed files with 89 additions and 25 deletions

View File

@@ -11,20 +11,6 @@ functions:
expectGlobalMemory(t, state, 0, 0)
}
func TestCal(t *testing.T) {
state := assembleAndExecute(t, `
functions:
- - [cal, +1]
- [add, g0, 1]
- [cal, +2] # Function doesn't exist, immediate implicit return
- [add, g0, 2]
- - [mov, g0, 5]
`)
expectGlobalMemory(t, state, 0, 8)
}
func TestRet(t *testing.T) {
state := assembleAndExecute(t, `
functions:
@@ -324,3 +310,53 @@ functions:
expectGlobalMemory(t, state, 0, 5)
}
func TestCal(t *testing.T) {
state := assembleAndExecute(t, `
functions:
- - [cal, +1]
- [add, g0, 1]
- [cal, +2] # Function doesn't exist, immediate implicit return
- [add, g0, 2]
- - [mov, g0, 5]
`)
expectGlobalMemory(t, state, 0, 8)
}
func TestCalT(t *testing.T) {
state := assembleAndExecute(t, `
functions:
- - [eq, 0, 0]
- [calt, +1]
- [add, g0, 1]
- [eq, 0, 1]
- [calt, +2]
- [add, g0, 2]
- - [add, g0, 5]
- - [add, g0, 13]
`)
expectGlobalMemory(t, state, 0, 8)
}
func TestCalF(t *testing.T) {
state := assembleAndExecute(t, `
functions:
- - [eq, 0, 0]
- [calf, +1]
- [add, g0, 1]
- [eq, 0, 1]
- [calf, +2]
- [add, g0, 2]
- - [add, g0, 5]
- - [add, g0, 13]
`)
expectGlobalMemory(t, state, 0, 16)
}