Esempio n. 1
0
def _(operand):
    item = single(operand)
    if isinstance(item, Label):
        return ExtendedDirect(item)
    elif isinstance(item, Integral):
        if item < 0:
            raise ValueError("Direct address {} is negative.".format(operand))
        if item <= 0xFF:
            return PageDirect(item)
        if item <= 0xFFFF:
            return ExtendedDirect(item)
        raise ValueError(
            "Direct address 0x{:X} out of range 0x0000-0xFFFF".format(item))
    else:
        raise TypeError(
            "Expected integer address or label. Got {}".format(item))
Esempio n. 2
0
def _(item):
    if item < 0:
        raise ValueError("Direct address {} is negative.".format(item))
    if item <= 0xFF:
        return PageDirect(item)
    if item <= 0xFFFF:
        return ExtendedDirect(item)
    raise ValueError(
        "Direct address 0x{:X} out of range 0x0000-0xFFFF".format(item))
Esempio n. 3
0
def _(item):
    return ExtendedDirect(item.value)
Esempio n. 4
0
def test_extended_direct_equal_hash(address):
    assert hash(ExtendedDirect(address)) == hash(ExtendedDirect(address))
Esempio n. 5
0
def test_extended_direct_inequality_different_types(address):
    assert ExtendedDirect(address) != object()
Esempio n. 6
0
def test_extended_direct_inequality(a, b):
    assume(a != b)
    assert ExtendedDirect(a) != ExtendedDirect(b)
Esempio n. 7
0
def test_extended_direct_repr(address):
    r = repr(ExtendedDirect(address))
    assert r.startswith('ExtendedDirect')
    assert hex(address)[2:].upper() in r
    assert check_balanced(r)
Esempio n. 8
0
def test_extended_direct_three_byte_address_raises_value_error(address):
    address = 0x010000
    with raises(ValueError):
        ExtendedDirect(address)
Esempio n. 9
0
def test_negative_extended_direct_address_raises_value_error(address):
    with raises(ValueError):
        ExtendedDirect(address)
Esempio n. 10
0
def test_extended_direct_address_must_be_two_byte(address):
    r = ExtendedDirect(address)
    assert r.address == address
Esempio n. 11
0
def test_extended_direct_incorrect_type_raises_type_error():
    with raises(TypeError):
        ExtendedDirect(object())
Esempio n. 12
0
def test_extended_direct_address_assembly():
    asm = AsmDsl()
    asm(ADDB, {0x1C48})
    assert statements(asm) == (AddB(ExtendedDirect(0x1C48)), )