MCPcopy Create free account
hub / github.com/djhworld/simple-computer / TestALUAdd

Function TestALUAdd

cpu/cpu_test.go:614–637  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

612}
613
614func TestALUAdd(t *testing.T) {
615 ClearMem()
616
617 var inputs [4]uint16 = [4]uint16{0x0002, 0x0003, 0xFD04, 0x0005}
618 testInstruction(0x0080, inputs, [4]uint16{inputs[0] + inputs[0], inputs[1], inputs[2], inputs[3]}, t)
619 testInstruction(0x0081, inputs, [4]uint16{inputs[0], inputs[1] + inputs[0], inputs[2], inputs[3]}, t)
620 testInstruction(0x0082, inputs, [4]uint16{inputs[0], inputs[1], inputs[2] + inputs[0], inputs[3]}, t)
621 testInstruction(0x0083, inputs, [4]uint16{inputs[0], inputs[1], inputs[2], inputs[3] + inputs[0]}, t)
622
623 testInstruction(0x0084, inputs, [4]uint16{inputs[0] + inputs[1], inputs[1], inputs[2], inputs[3]}, t)
624 testInstruction(0x0085, inputs, [4]uint16{inputs[0], inputs[1] + inputs[1], inputs[2], inputs[3]}, t)
625 testInstruction(0x0086, inputs, [4]uint16{inputs[0], inputs[1], inputs[2] + inputs[1], inputs[3]}, t)
626 testInstruction(0x0087, inputs, [4]uint16{inputs[0], inputs[1], inputs[2], inputs[3] + inputs[1]}, t)
627
628 testInstruction(0x0088, inputs, [4]uint16{inputs[0] + inputs[2], inputs[1], inputs[2], inputs[3]}, t)
629 testInstruction(0x0089, inputs, [4]uint16{inputs[0], inputs[1] + inputs[2], inputs[2], inputs[3]}, t)
630 testInstruction(0x008A, inputs, [4]uint16{inputs[0], inputs[1], inputs[2] + inputs[2], inputs[3]}, t)
631 testInstruction(0x008B, inputs, [4]uint16{inputs[0], inputs[1], inputs[2], inputs[3] + inputs[2]}, t)
632
633 testInstruction(0x008C, inputs, [4]uint16{inputs[0] + inputs[3], inputs[1], inputs[2], inputs[3]}, t)
634 testInstruction(0x008D, inputs, [4]uint16{inputs[0], inputs[1] + inputs[3], inputs[2], inputs[3]}, t)
635 testInstruction(0x008E, inputs, [4]uint16{inputs[0], inputs[1], inputs[2] + inputs[3], inputs[3]}, t)
636 testInstruction(0x008F, inputs, [4]uint16{inputs[0], inputs[1], inputs[2], inputs[3] + inputs[3]}, t)
637}
638
639func TestALUAddWithCarry(t *testing.T) {
640 ClearMem()

Callers

nothing calls this directly

Calls 2

ClearMemFunction · 0.85
testInstructionFunction · 0.85

Tested by

no test coverage detected