Conditional return instructions

This commit is contained in:
Ian Gulliver
2021-11-19 16:30:11 -10:00
parent 7a24eee583
commit 50f986fb13
4 changed files with 94 additions and 30 deletions

View File

@@ -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)
}