示例#1
0
 def testContinuousRegisters(self):
     # 10101nnn
     # Pop r4-r[4+nnn], r14.
     self.assertEqual(bytes([0b10101000]), EncodePop([4, 14]))
     self.assertEqual(bytes([0b10101001]), EncodePop([4, 5, 14]))
     self.assertEqual(bytes([0b10101111]),
                      EncodePop([4, 5, 6, 7, 8, 9, 10, 11, 14]))
示例#2
0
 def testDiscontinuousRegisters(self):
     # 1000iiii iiiiiiii
     # Pop up to 12 integer registers under masks {r15-r12}, {r11-r4}.
     self.assertEqual(bytes([0b10001000, 0b00000001]), EncodePop([4, 15]))
     self.assertEqual(bytes([0b10000100, 0b00011000]), EncodePop([7, 8,
                                                                  14]))
     self.assertEqual(bytes([0b10000111, 0b11111111]),
                      EncodePop([4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]))
     self.assertEqual(bytes([0b10000100, 0b10111111]),
                      EncodePop([4, 5, 6, 7, 8, 9, 11, 14]))
示例#3
0
 def testSingleRegister(self):
     # Should reject registers outside r4 ~ r15 range.
     for r in 0, 1, 2, 3, 16:
         self.assertRaises(AssertionError, lambda: EncodePop([r]))
     # Should use
     # 1000iiii iiiiiiii
     # Pop up to 12 integer registers under masks {r15-r12}, {r11-r4}.
     self.assertEqual(bytes([0b10000000, 0b00000001]), EncodePop([4]))
     self.assertEqual(bytes([0b10000000, 0b00001000]), EncodePop([7]))
     self.assertEqual(bytes([0b10000100, 0b00000000]), EncodePop([14]))
     self.assertEqual(bytes([0b10001000, 0b00000000]), EncodePop([15]))