Ejemplo n.º 1
0
    public Task StartAsync(CancellationToken cancellationToken)
    {
        var inputFile = config["input"];

        if (inputFile == null)
        {
            Usage();
        }
        logger.LogInformation("start async");

        logger.LogInformation($"Input file: {inputFile}");

        try
        {
            // Load the app image at address zero
            cpu.Memory.Load(inputFile);

            // Run the CPU
            cpu.Run();

            Console.WriteLine();
            cpu.Registers.ToConsole();
            Console.WriteLine();
            cpu.Memory.ToConsole(0, 128);
            Console.WriteLine();
        }
        catch (EmulatorException emulatorException)
        {
            Console.WriteLine($"Emulator error: {emulatorException.Message}\n".Pastel(Color.Tomato));
        }
        catch (Exception emulatorException)
        {
            logger.LogError("Unexpected exception {exception}", emulatorException.Message);
        }


        applicationLifetime.StopApplication();
        return(Task.CompletedTask);
    }