Пример #1
0
def _(operand):
    item = single(operand)
    if isinstance(item, Label):
        return ExtendedIndirect(item)
    elif isinstance(item, Integral):
        if item < 0:
            raise ValueError("Direct address {} is negative.".format(operand))
        if item <= 0xFFFF:
            return ExtendedIndirect(item)
        raise ValueError(
            "Indirect address 0x{:X} out of range 0x0000-0xFFFF".format(item))
    else:
        raise TypeError(
            "Expected integer address or label. Got {}".format(item))
Пример #2
0
def test_extended_indirect_inequality_different_types(address):
    assert ExtendedIndirect(address) != object()
Пример #3
0
def test_extended_indirect_equal_hash(address):
    assert hash(ExtendedIndirect(address)) == hash(ExtendedIndirect(address))
Пример #4
0
def test_extended_indirect_repr(address):
    r = repr(ExtendedIndirect(address))
    assert r.startswith('ExtendedIndirect')
    assert hex(address)[2:].upper() in r
    assert check_balanced(r)
Пример #5
0
def test_extended_indirect_inequality(a, b):
    assume(a != b)
    assert ExtendedIndirect(a) != ExtendedIndirect(b)
Пример #6
0
def test_extended_indirect_three_byte_address_raises_value_error(address):
    address = 0x010000
    with raises(ValueError):
        ExtendedIndirect(address)
Пример #7
0
def test_negative_extended_indirect_address_raises_value_error(address):
    with raises(ValueError):
        ExtendedIndirect(address)
Пример #8
0
def test_extended_indirect_address_must_be_two_byte(address):
    r = ExtendedIndirect(address)
    assert r.address == address
Пример #9
0
def test_extended_indirect_incorrect_type_raises_type_error():
    with raises(TypeError):
        ExtendedIndirect(object())
Пример #10
0
def test_extended_indirect_address_assembly():
    asm = AsmDsl()
    asm(INC, [{0x1C48}])
    assert statements(asm) == (Inc(ExtendedIndirect(0x1C48)), )