def updateUI(self): self.num_lines1 = 0 self.num_lines2 = 0 with open(self.fname) as f: lines = list(f.readlines()) self.mips = assembler(lines) self.loadText1(lines) self.loadText2(self.mips.hexs())
def test_assembly_Add(self): testOutput = assembler( '/Users/Sean/Desktop/nand2tetris/projects/06/Assembler/add/Add.asm' ) self.assertEqual(len(testOutput), 6) counter = 0 with open( '/Users/Sean/Desktop/nand2tetris/projects/06/Assembler/add/Add.testhack', mode='r') as f: lines = f.read().splitlines() for line in lines: self.assertEqual(testOutput[counter], line) counter += 1
def test_assembly_Pong(self): testOutput = assembler( '/Users/Sean/Desktop/nand2tetris/projects/06/Assembler/pong/Pong.asm' ) self.assertEqual(len(testOutput), 27483) counter = 0 with open( "/Users/Sean/Desktop/nand2tetris/projects/06/Assembler/pong/Pong.testhack", mode='r') as f: lines = f.read().splitlines() for line in lines: self.assertEqual(testOutput[counter], line) counter += 1
"-showcoord": True, "-showlookup": False, "-showinstructioncount": True } for arg in sys.argv[1:]: if arg.split("=")[0] in argv: try: argv[arg.split("=")[0]] = False if arg.split( "=")[1].lower() == 'false' else True except: argv[arg.split("=")[0]] = True sys.argv.clear() code = assembler(fileinput.input()) first_pass() second_pass() if (argv["-showcoord"]): coordinate_pairs() if (argv["-showmem"]): memory_contents() if (argv["-showreg"]): register_contents() if (argv["-showcounter"]): counter_contents() if (argv["-showfmem"]): fast_mem() if (argv["-showinstructioncount"]): showinstructioncount()
def compile(self): lines = self.ui.editor.toPlainText().split('\n') self.num_lines1 = 0 self.num_lines2 = 0 self.mips = assembler(lines) self.loadText2(self.mips.hexs())