Ejemplo n.º 1
0
    elif len(sys.argv) == 2 and sys.argv[1] == 'benchmark':
        Benchmark('programs/conway_life.asm', 10.0, 1000000)

    elif len(sys.argv) == 3 and sys.argv[1] == 'run':

        sys.stdout.write(" [ ] Creating Virtual Machine...")
        sys.stdout.flush()
        c = VirtualMachine()
        sys.stdout.write("\r [+] Virtual Machine Created...\n")
        sys.stdout.flush()
        sys.stdout.write(" [ ] Assembling File...")
        sys.stdout.flush()
        program = AssembleFile(sys.argv[2])
        sys.stdout.write("\r [+] File Assembled...   \n")
        sys.stdout.flush()
        sys.stdout.write(" [ ] Loading Binary Data...")
        sys.stdout.flush()
        c.LoadProgramFromData(program)
        sys.stdout.write("\r [+] Binary Data Loaded...   \n")
        sys.stdout.flush()
        print(' [*] Running Program!')
        print('*' * 80 + '\n')
        while not c.halted:
            c.Run()
            print(c.Output)
            c.Output = ''
            if c.waiting_for_input:
                c.Input = input() + '\n'
    else:
        doui()