def test_twos_comp(self): self.assertEqual(emu8086.to_2compl(0, True), 0) self.assertEqual( # 7654321076543210 emu8086.to_2compl(0b0000000001111111, True), 0b0000000001111111) self.assertEqual( # 7654321076543210 emu8086.to_2compl(-0b0000000001111111, True), 0b1111111110000001)
def test_twos_comp(self): self.assertEqual(emu8086.to_2compl(0, True), 0) self.assertEqual( # 7654321076543210 emu8086.to_2compl(0b0000000001111111, True), 0b0000000001111111 ) self.assertEqual( # 7654321076543210 emu8086.to_2compl(-0b0000000001111111, True), 0b1111111110000001)
def test_twos_comp_neg1(self): self.assertEqual(emu8086.to_2compl(-1, True), 0xffff)