Add conditional call instructions
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user