Ejemplo n.º 1
0
 def run(self, trace):
     self._pc = settings.BASE_PC
     self._trace = trace
     dis = disassembler.Disassembler()
     while self._pc < self._endpos:
         if self._trace or self._pc in self._breaks:
             self._trace = True
             dis.disassemble_line(self._mem, self._pc)
             self.traceCPU()
             if not self.traceStep(dis):
                 return
         opcode = self._mem[self._pc]
         self._pc += 1
         self.execute[opcode](self)
import disassembler
import simulator
import sim

mydis = disassembler.Disassembler()
output = {}
output = mydis.run()    #returns all dissasembler lists to output
mydis.print()           #prints dissasembler


mysimulator = simulator.Simulator(**output)   #passes all dissasembler return values to constructor of Simulator()
mysimulator.run()

mysim = sim.simClass(**output)
mysim.run()

Ejemplo n.º 3
0
            address = '0x{:08X}'.format(_[0])
            operation = _[1]
            operands = _[2]

            self.maintui.addContent(
                "e_section", "{} {} {}".format(address, operation, operands))

        for _ in self.Disassemble.getSections():
            address = '0x{:08X}'.format(self.Disassemble.getSections()[_])
            self.maintui.addContent("s_section0", address + " " + _)

        for _ in self.Disassemble.getStrings():
            self.maintui.addContent("s_section1", _)


Disassemble = disassembler.Disassembler(sys.argv[1])
TUI = Main(Disassemble)
Terminal = Terminal(TUI, Disassemble)


def handler(signal_received, frame):
    TUI.switchForm(None)


if __name__ == '__main__':
    # Ho usato il modulo signal per fare un handler per quando l'utente schiaccia ^C
    # Questo serve per uscire dalla versione grafica ma senza uscire interamente da tutto il programma
    signal(SIGINT, handler)

    try:
        Terminal.run()
Ejemplo n.º 4
0
    f.close()

    infile = outfile
        
if args.disassemble:
    if not args.quiet:
        print ("Disassembling...")
    try:
        f = open(infile, "r")
        code = json.load(f)
        f.close()
    except:
        print ("Error: Could not decode input file: " + infile)
        sys.exit()

    disassembler = disassembler.Disassembler()
    disassembler.disassemble(code)

if args.execute or args.trace:
    try:
        f = open(infile, "r")
        code = json.load(f)
        f.close()
    except:
        print ("Error: Could not decode input file: " + infile)
        sys.exit()

    if not args.quiet:
        print ("Executing...")
    action = simulator.Simulator(code)
    action.run(args.trace)