Conditional return instructions
This commit is contained in:
@@ -11,21 +11,6 @@ functions:
|
||||
expectGlobalMemory(t, state, 0, 0)
|
||||
}
|
||||
|
||||
func TestRet(t *testing.T) {
|
||||
state := assembleAndExecute(t, `
|
||||
functions:
|
||||
- - [cal, +1]
|
||||
- [add, g0, 1]
|
||||
- [ret]
|
||||
|
||||
- - [mov, g0, 5]
|
||||
- [ret]
|
||||
- [add, g0, 2]
|
||||
`)
|
||||
|
||||
expectGlobalMemory(t, state, 0, 6)
|
||||
}
|
||||
|
||||
func TestMov(t *testing.T) {
|
||||
state := assembleAndExecute(t, `
|
||||
functions:
|
||||
@@ -360,3 +345,54 @@ functions:
|
||||
|
||||
expectGlobalMemory(t, state, 0, 16)
|
||||
}
|
||||
|
||||
func TestRet(t *testing.T) {
|
||||
state := assembleAndExecute(t, `
|
||||
functions:
|
||||
- - [cal, +1]
|
||||
- [add, g0, 1]
|
||||
- [ret]
|
||||
|
||||
- - [mov, g0, 5]
|
||||
- [ret]
|
||||
- [add, g0, 2]
|
||||
`)
|
||||
|
||||
expectGlobalMemory(t, state, 0, 6)
|
||||
}
|
||||
|
||||
func TestRetT(t *testing.T) {
|
||||
state := assembleAndExecute(t, `
|
||||
functions:
|
||||
- - [cal, +1]
|
||||
- [add, g0, 1]
|
||||
|
||||
- - [add, g0, 2]
|
||||
- [eq, 0, 0]
|
||||
- [rett]
|
||||
- [add, g0, 4]
|
||||
- [eq, 0, 1]
|
||||
- [rett]
|
||||
- [add, g0, 8]
|
||||
`)
|
||||
|
||||
expectGlobalMemory(t, state, 0, 3)
|
||||
}
|
||||
|
||||
func TestRetF(t *testing.T) {
|
||||
state := assembleAndExecute(t, `
|
||||
functions:
|
||||
- - [cal, +1]
|
||||
- [add, g0, 1]
|
||||
|
||||
- - [add, g0, 2]
|
||||
- [eq, 0, 0]
|
||||
- [retf]
|
||||
- [add, g0, 4]
|
||||
- [eq, 0, 1]
|
||||
- [retf]
|
||||
- [add, g0, 8]
|
||||
`)
|
||||
|
||||
expectGlobalMemory(t, state, 0, 7)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user