diff --git a/cpu/operations/shift.go b/cpu/operations/shift.go new file mode 100644 index 0000000..c68259a --- /dev/null +++ b/cpu/operations/shift.go @@ -0,0 +1,5 @@ +package operations + +func Shift(r1 *byte) { + *r1 = *r1 << 1 +} diff --git a/cpu/operations/shift_test.go b/cpu/operations/shift_test.go new file mode 100644 index 0000000..5073b69 --- /dev/null +++ b/cpu/operations/shift_test.go @@ -0,0 +1,17 @@ +package operations + +import ( + "testing" +) + +func TestShift(t *testing.T) { + r1 := byte(0b01010101) + Shift(&r1) + + expected := byte(0b10101010) + actual := r1 + + if actual != expected { + t.Errorf("actual %x != expected %x", actual, expected) + } +}