Bitwise operators

This commit is contained in:
Ian Gulliver
2021-11-19 16:43:59 -10:00
parent 50f986fb13
commit cc8e4a8ccb
4 changed files with 102 additions and 18 deletions

View File

@@ -94,6 +94,47 @@ functions:
expectGlobalMemorySigned(t, state, 2, 1)
}
func TestNot(t *testing.T) {
state := assembleAndExecute(t, `
functions:
- - [mov, g0, 8]
- [not, g0]
- [and, g0, 15]
`)
expectGlobalMemory(t, state, 0, 7)
}
func TestAnd(t *testing.T) {
state := assembleAndExecute(t, `
functions:
- - [mov, g0, 7]
- [and, g0, 18]
`)
expectGlobalMemory(t, state, 0, 2)
}
func TestOr(t *testing.T) {
state := assembleAndExecute(t, `
functions:
- - [mov, g0, 7]
- [or, g0, 18]
`)
expectGlobalMemory(t, state, 0, 23)
}
func TestXor(t *testing.T) {
state := assembleAndExecute(t, `
functions:
- - [mov, g0, 7]
- [xor, g0, 18]
`)
expectGlobalMemory(t, state, 0, 21)
}
func TestEq(t *testing.T) {
state := assembleAndExecute(t, `
functions: