def test_convert_0xCXNN_to_RND(self): # Arrange: opcodes = [0xBFFF] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('JP #fff, V0', mnemonics[0])
def test_convert_0x8XY0_to_LD(self): # Arrange: opcodes = [0x8AE0] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEquals('LD Va, Ve', mnemonics[0])
def test_convert_0xANNN_to_LD(self): # Arrange: opcodes = [0xAFFF] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('LD I, #fff', mnemonics[0])
def test_convert_0x2FFF_to_CALL(self): # Arrange: opcodes = [0x2FFF] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('CALL #fff', mnemonics[0])
def test_convert_0x4XNN_to_SNE(self): # Arrange: opcodes = [0x4EFF] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('SNE Ve, #ff', mnemonics[0])
def test_convert_0x00E0_to_CLS(self): # Arrange: opcodes = [0x00E0] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('CLS', mnemonics[0])
def test_convert_0xFX65_LD(self): # Arrange: opcodes = [0xFF65] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('LD Vf, [I]', mnemonics[0])
def test_convert_0x3XNN_to_SE(self): # Arrange: opcodes = [0x3FFF] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEquals('SE Vf, #ff', mnemonics[0])
def test_convert_0x7XNN_to_ADD(self): # Arrange: opcodes = [0x7F00] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('ADD Vf, #00', mnemonics[0])
def test_convert_0xFX55_LD(self): # Arrange: opcodes = [0xFF55] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEquals('LD [I], Vf', mnemonics[0])
def test_convert_0x1FFF_to_JP(self): # Arrange: opcodes = [0x1FFF] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEquals('JP #fff', mnemonics[0])
def test_convert_0xFX1E_LD(self): # Arrange: opcodes = [0xFF1E] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEquals('ADD I, Vf', mnemonics[0])
def test_convert_0xFX0A_LD(self): # Arrange: opcodes = [0xFF0A] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEquals('LD Vf, K', mnemonics[0])
def test_convert_0x8XY7_to_SUBN(self): # Arrange: opcodes = [0x8AE7] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEquals('SUBN Va, Ve', mnemonics[0])
def test_convert_0xDXYN_to_DRW(self): # Arrange: opcodes = [0xDFE5] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('DRW Vf, Ve, #5', mnemonics[0])
def test_convert_0x8XY3_to_XOR(self): # Arrange: opcodes = [0x8AE3] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('XOR Va, Ve', mnemonics[0])
def test_convert_0xEXA1_SKNP(self): # Arrange: opcodes = [0xEFA1] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('SKNP Vf', mnemonics[0])
def test_convert_0x8XY4_to_ADD(self): # Arrange: opcodes = [0x8AE4] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('ADD Va, Ve', mnemonics[0])
def test_convert_0xFX33_LD(self): # Arrange: opcodes = [0xFF33] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('LD B, Vf', mnemonics[0])
def test_convert_0xNNNN_to_DW(self): # Arrange: opcodes = [0xF000] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('DW #f000', mnemonics[0])
def test_convert_0x00EE_to_RET(self): # Arrange: opcodes = [0x00EE] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('RET', mnemonics[0])
def test_convert_0x8XYE_to_SHL(self): # Arrange: opcodes = [0x8AEE] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('SHL Va, Ve', mnemonics[0])
def test_convert_0xfff_to_SYS(self): # Arrange: opcodes = [0x0FFF] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('SYS #fff', mnemonics[0])
def test_convert_0x9XY0_to_SNE(self): # Arrange: opcodes = [0x9AE0] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('SNE Va, Ve', mnemonics[0])
def test_convert_0x5XY0_to_SE(self): # Arrange: opcodes = [0x5EF0] # Act: mnemonics = disassembler.generate(opcodes) # Assert: self.assertEqual('SE Ve, Vf', mnemonics[0])
def exec_decompile(args): import array opcodes = array.array('H') try: opcodes.fromfile(args.filename, 1024) except EOFError: pass opcodes.byteswap() mnemonics = disassembler.generate(opcodes) args.output.write('\n'.join(mnemonics)) args.output.close()