Esempio n. 1
0
def test_add():
    pe = PE()
    inst = asm.add()
    res, res_p, irq = pe(inst, Data(1), Data(3))
    assert res == 4
    assert res_p == 0
    assert irq == 0
Esempio n. 2
0
def test_sub():
    pe = PE()
    inst = asm.sub()
    res, res_p, irq = pe(inst, Data(1), Data(3))
    assert res == -2
    assert res_p == 0
    assert irq == 0
Esempio n. 3
0
def test_smax():
    pe = PE()
    inst = asm.smax()
    res, res_p, irq = pe(inst, Data(1), Data(2))
    assert res == 2
    assert res_p == 0
    assert irq == 0
Esempio n. 4
0
def test_neg():
    pe = PE()
    inst = asm.neg()
    res, res_p, irq = pe(inst, Data(0), Data(1))
    assert res == 0xffff
    assert res_p == 0
    assert irq == 0
Esempio n. 5
0
def test_inv():
    pe = PE()
    inst = asm.sub()
    res, res_p, irq = pe(inst, Data(0xffff), Data(1))
    assert res == 0xfffe
    assert res_p == 0
    assert irq == 0
Esempio n. 6
0
def test_xor():
    pe = PE()
    inst = asm.xor()
    res, res_p, irq = pe(inst, Data(1), Data(3))
    assert res == 2
    assert res_p == 0
    assert irq == 0
Esempio n. 7
0
def test_umin():
    pe = PE()
    inst = asm.umin()
    res, res_p, irq = pe(inst, Data(1), Data(2))
    assert res == 1
    assert res_p == 0
    assert irq == 0
Esempio n. 8
0
def test_sel():
    pe = PE()
    inst = asm.sel()
    res, res_p, irq = pe(inst, Data(1), Data(2), Bit(0))
    assert res == 2
    assert res_p == 0
    assert irq == 0
Esempio n. 9
0
def test_asr():
    pe = PE()
    inst = asm.asr()
    res, res_p, irq = pe(inst, Data(-2), Data(1))
    assert res == 65535
    assert res_p == 0
    assert irq == 0
Esempio n. 10
0
def test_lsr():
    pe = PE()
    inst = asm.lsr()
    res, res_p, irq = pe(inst, Data(2), Data(1))
    assert res == 1
    assert res_p == 0
    assert irq == 0
Esempio n. 11
0
def test_and():
    # instantiate an PE - calls PE.__init__
    pe = PE()
    # format an 'and' instruction
    inst = asm.and_()
    # execute PE instruction with the arguments as inputs -  call PE.__call__
    res, res_p, irq = pe(inst, Data(1), Data(3))
    assert res == 1
    assert res_p == 0
    assert irq == 0
Esempio n. 12
0
def test_mult1():
    pe = PE()

    inst = asm.umult1()
    res, res_p, irq = pe(inst, Data(0x200), Data(3))
    assert res == 6
    assert res_p == 0
    assert irq == 0

    inst = asm.smult1()
    res, res_p, irq = pe(inst, Data(-512), Data(3))
    assert res == -6
    assert res_p == 0
    assert irq == 0
Esempio n. 13
0
def test_mult2():
    pe = PE()

    inst = asm.umult2()
    res, res_p, irq = pe(inst, Data(0x200), Data(0x300))
    assert res == 6
    assert res_p == 0
    assert irq == 0

    inst = asm.smult2()
    res, res_p, irq = pe(inst, Data(-2 * 256), Data(3 * 256))
    assert res == -6
    assert res_p == 0
    assert irq == 0
Esempio n. 14
0
def test_abs():
    pe = PE()
    inst = asm.abs()
    res, res_p, irq = pe(inst, Data(-1))
    assert res == 1
    assert res_p == 0
    assert irq == 0
Esempio n. 15
0
def test_slt():
    pe = PE()
    inst = asm.slt()
    res, res_p, irq = pe(inst, Data(1), Data(1))
    assert res_p == 0
Esempio n. 16
0
def test_ule():
    pe = PE()
    inst = asm.ule()
    res, res_p, irq = pe(inst, Data(1), Data(1))
    assert res_p == 1