示例#1
0
def _(operand):
    """Parse an immediate operand.

    Immediate operands are simple values such as 0, 0x10, or 0b10101010, or an expression evaluating
    to such a value, such as ord("A").
    """
    return Immediate(operand)
示例#2
0
文件: asmdsl.py 项目: abingham/asm68
def _(operand):
    try:
        byte = single(operand)
    except ValueError as ve:
        raise ValueError(
            "Immediate8 string operand must contain an single ASCII character. Got {} in {!r}"
            .format(len(operand), operand)) from ve

    return Immediate(byte)
示例#3
0
def test_immediate_hash(a):
    assert hash(Immediate(a)) == hash(Immediate(a))
示例#4
0
def test_immediate_inequality_different_types(a):
    assert Immediate(a) != object()
示例#5
0
def test_immediate_inequality(a, b):
    assume(a != b)
    assert Immediate(a) != Immediate(b)
示例#6
0
def test_immediate_equality(a):
    assert Immediate(a) == Immediate(a)
示例#7
0
def test_bytes_operand_gives_immediate_value(b):
    assert parse_operand(b) == Immediate(b[0], 1)
示例#8
0
def _(operand):
    unsigned = operand.value.to_bytes(2, byteorder="big", signed=True)
    return Immediate(int.from_bytes(unsigned, byteorder="big", signed=False),
                     2)
示例#9
0
文件: asmdsl.py 项目: abingham/asm68
def _(operand):
    return Immediate(operand)
示例#10
0
def test_i16_operand():
    assert parse_operand(I16(-4567)) == Immediate(60969, 2)
示例#11
0
def test_i32_operand():
    assert parse_operand(I32(0x45671234)) == Immediate(0x45671234, 4)
示例#12
0
def test_i8_operand():
    assert parse_operand(I8(-42)) == Immediate(214, 1)
示例#13
0
def test_u16_operand():
    assert parse_operand(U16(0x4567)) == Immediate(0x4567, 2)
示例#14
0
def test_u8_operand():
    assert parse_operand(U8(42)) == Immediate(42, 1)
示例#15
0
def _(operand):
    return Immediate(int.from_bytes(operand, byteorder="big", signed=False),
                     len(operand))
示例#16
0
def test_immediate_value(a):
    assert Immediate(a).value == a
示例#17
0
def _(operand):
    return Immediate(operand.value, 4)
示例#18
0
def test_immediate_repr(a):
    r = repr(Immediate(a))
    assert r.startswith('Immediate')
    assert str(a) in r
    assert check_balanced(r)
示例#19
0
def _(operand):
    return Immediate(
        int.from_bytes(operand.value.to_bytes(4, byteorder="big", signed=True),
                       byteorder="big",
                       signed=False), 4)
示例#20
0
def test_immediate_address_assembly():
    asm = AsmDsl()
    asm(LDA, 0x30)
    assert statements(asm) == (LdA(Immediate(0x30)), )