示例#1
0
 def run_assembly(src, inp=None):
     prg = translator.translate(src.splitlines())
     cpu = Executor()
     if inp:
         cpu.regs = [int(x, 16) for x in inp.split()]
     cpu.run(prg)
     return ' '.join('{:x}'.format(x) for x in cpu.regs)
示例#2
0
 def run_assembly(src, inp=None):
     prg = translator.translate(src.splitlines())
     cpu = Executor()
     if inp:
         cpu.regs = [int(x, 16) for x in inp.split()]
     cpu.run(prg)
     return ' '.join('{:x}'.format(x) for x in cpu.regs)
示例#3
0
def main():
    try:
        src = loadSource()
        prg = translator.translate(src)
        cpu = EnhancedExecutor()
        fetchState(cpu)
        cpu.run(prg)
    except Exception as e:
        sys.stderr.write("Error: %s\n" % e)
示例#4
0
def main():
    try:
        src = loadSource()
        prg = translator.translate(src)
        cpu = EnhancedExecutor()
        fetchState(cpu)
        cpu.run(prg)
    except Exception as e:
        sys.stderr.write("Error: %s\n" % e)
示例#5
0
def main():
    print "Content-Type: text/plain"
    print ''

    try:
        src, inputData = loadSource()
        prg = translator.translate(src)
        cpu = EnhancedExecutor()
        if len(inputData) == 1:
            if cpu.fetchState(inputData[0]):
                inputData = []
        cpu.inputData = '\n'.join(inputData)
        cpu.run(prg)
        if len(inputData) == 0:
            cpu.printRegs()
    except Exception as e:
        print "Error: %s\n" % e
示例#6
0
def main():
    print "Content-Type: text/plain"
    print ''

    try:
        src, inputData = loadSource()
        prg = translator.translate(src)
        cpu = EnhancedExecutor()
        if len(inputData) == 1:
            if cpu.fetchState(inputData[0]):
                inputData = []
        cpu.inputData = '\n'.join(inputData)
        cpu.run(prg)
        if len(inputData) == 0:
            cpu.printRegs()
    except Exception as e:
        print "Error: %s\n" % e
示例#7
0
 def load_assembly(self, src):
     self.prg = translator.translate(src.splitlines())
 def load_assembly(self, src):
     self.prg = translator.translate(src.splitlines())