From 72d2c5d97c8a74bf9d6279f7942e712e02fbfa33 Mon Sep 17 00:00:00 2001 From: radumacocian Date: Tue, 29 Apr 2025 19:26:31 +0200 Subject: [PATCH] added shift function and tests --- cpu/operations/shift.go | 5 +++++ cpu/operations/shift_test.go | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 cpu/operations/shift.go create mode 100644 cpu/operations/shift_test.go 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) + } +}