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

Function testMultiply

cpu/cpu_test.go:907–941  ·  view source on GitHub ↗
(inputA, inputB uint16, t *testing.T)

Source from the content-addressed store, hash-verified

905}
906
907func testMultiply(inputA, inputB uint16, t *testing.T) {
908 c := SetUpCPU()
909
910 setMemoryLocation(c, 50, 0x0023) // DATA R3
911 setMemoryLocation(c, 51, 0x0001) // .. 1
912 setMemoryLocation(c, 52, 0x00EA) // XOR R2, R2
913 setMemoryLocation(c, 53, 0x0060) // CLF
914 setMemoryLocation(c, 54, 0x0090) // SHR R0
915 setMemoryLocation(c, 55, 0x0058) // JC
916 setMemoryLocation(c, 56, 59) // ...addr 59
917 setMemoryLocation(c, 57, 0x0040) // JMP
918 setMemoryLocation(c, 58, 61) // ...addr 61
919 setMemoryLocation(c, 59, 0x0060) // CLF
920 setMemoryLocation(c, 60, 0x0086) // ADD R1, R2
921 setMemoryLocation(c, 61, 0x0060) // CLF
922 setMemoryLocation(c, 62, 0x00A5) // SHL R1
923 setMemoryLocation(c, 63, 0x00AF) // SHL R3
924 setMemoryLocation(c, 64, 0x0058) // JC
925 setMemoryLocation(c, 65, 68) // ...addr 68
926 setMemoryLocation(c, 66, 0x0040) // JMP
927 setMemoryLocation(c, 67, 53) // ...addr 53
928
929 setRegisters(c, [4]uint16{inputA, inputB, 0, 0})
930
931 c.SetIAR(50)
932
933 for {
934 doFetchDecodeExecute(c)
935 if c.iar.Value() >= 68 {
936 break
937 }
938 }
939
940 checkRegister(c, 2, inputA*inputB, t)
941}
942
943func TestIOInputInstruction(t *testing.T) {
944 ClearMem()

Callers 1

TestMultiplyFunction · 0.85

Calls 7

SetUpCPUFunction · 0.85
setMemoryLocationFunction · 0.85
setRegistersFunction · 0.85
doFetchDecodeExecuteFunction · 0.85
checkRegisterFunction · 0.85
SetIARMethod · 0.80
ValueMethod · 0.80

Tested by

no test coverage detected