mirror of
https://github.com/macocianradu/goboy.git
synced 2026-03-18 21:10:07 +00:00
finished first row of opcodes
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package operations
|
||||
|
||||
func Shift(r1 *byte) {
|
||||
func ShiftLeft(r1 *byte) {
|
||||
*r1 = *r1 << 1
|
||||
}
|
||||
|
||||
func ShiftRight(r1 *byte) {
|
||||
*r1 = *r1 >> 1
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestShift(t *testing.T) {
|
||||
func TestShiftLeft(t *testing.T) {
|
||||
r1 := byte(0b01010101)
|
||||
Shift(&r1)
|
||||
ShiftLeft(&r1)
|
||||
|
||||
expected := byte(0b10101010)
|
||||
actual := r1
|
||||
@@ -15,3 +15,15 @@ func TestShift(t *testing.T) {
|
||||
t.Errorf("actual %x != expected %x", actual, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShiftRight(t *testing.T) {
|
||||
r1 := byte(0b01010101)
|
||||
ShiftLeft(&r1)
|
||||
|
||||
expected := byte(0b00101010)
|
||||
actual := r1
|
||||
|
||||
if actual != expected {
|
||||
t.Errorf("actual %x != expected %x", actual, expected)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user