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))
def test_extended_indirect_inequality_different_types(address): assert ExtendedIndirect(address) != object()
def test_extended_indirect_equal_hash(address): assert hash(ExtendedIndirect(address)) == hash(ExtendedIndirect(address))
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)
def test_extended_indirect_inequality(a, b): assume(a != b) assert ExtendedIndirect(a) != ExtendedIndirect(b)
def test_extended_indirect_three_byte_address_raises_value_error(address): address = 0x010000 with raises(ValueError): ExtendedIndirect(address)
def test_negative_extended_indirect_address_raises_value_error(address): with raises(ValueError): ExtendedIndirect(address)
def test_extended_indirect_address_must_be_two_byte(address): r = ExtendedIndirect(address) assert r.address == address
def test_extended_indirect_incorrect_type_raises_type_error(): with raises(TypeError): ExtendedIndirect(object())
def test_extended_indirect_address_assembly(): asm = AsmDsl() asm(INC, [{0x1C48}]) assert statements(asm) == (Inc(ExtendedIndirect(0x1C48)), )