Ejemplo n.º 1
0
def test_read_initial_state():
    # The following are not necessary, but it was very helpful in debugging
    Emulator.run_to(0x2FF, max_instructions=10_000_000)  # Entry of vCPU
    Emulator.run_vcpu_to(0x200)  # Pass through loading sequence
    buffer = bytearray()
    for _ in range(5):
        value = Emulator.read_serial(bits=8)
        buffer.append(value)
    assert buffer == b"READY"
Ejemplo n.º 2
0
def test_MulShift8(a, b):
    _prepare_for_vcpu_execution_at(execution_address)
    Emulator.run_vcpu_to(
        0x300)  # Run the first page, so the variable is defined
    _write_word(vars.sysFn, asm.symbol("SYS_MultiplyBytes_120"), signed=False)
    _write_word(symbol_table["A"], a, signed=True)
    _write_word(symbol_table["B"], b, signed=True)

    _call_vcpu_function("MulShift8")

    assert int(a * b / 256) == _read_word(vars.vAC, signed=True)
Ejemplo n.º 3
0
def _call_vcpu_function(variable):
    return_point = Emulator.vPC & 0xFF00 | (Emulator.vPC + 2) & 0xFF
    Emulator.AC = symbol_table[variable]
    Emulator.next_instruction = "CALL"
    Emulator.step_vcpu()  # Execute CALL
    Emulator.run_vcpu_to(return_point)