Example #1
0
def test_jms():
    addr = 2
    inst = asm.jms(addr)
    pdp8 = PDP8([inst])
    pdp8()
    assert pdp8.peak_pc() == 3
    assert pdp8.peak_acc() == 0
    assert pdp8.peak_mem(addr) == 1
Example #2
0
def test_page():
    addr = 1
    value = 0o7777
    inst = asm.tad(addr,p=asm.MP.CURRENT_PAGE)
    pdp8 = PDP8([inst])
    pdp8.poke_mem(addr,Word(value))
    pdp8()
    assert pdp8.peak_pc() == 1
    assert pdp8.peak_acc() == value
Example #3
0
def test_tad(a,b):
    addr = 1
    inst = asm.tad(addr)
    pdp8 = PDP8([inst])
    pdp8.poke_mem(addr,a)
    pdp8.poke_acc(b)
    pdp8()
    assert pdp8.peak_pc() == 1
    assert pdp8.peak_acc() == a+b
Example #4
0
def test_isz():
    addr = 1
    inst = asm.isz(addr)
    pdp8 = PDP8([inst])
    pdp8.poke_mem(addr,0)
    pdp8()
    assert pdp8.peak_pc() == 1
    assert pdp8.peak_acc() == 0
    assert pdp8.peak_mem(addr) == 1
Example #5
0
def test_dca(a):
    addr = 1
    inst = asm.dca(addr)
    pdp8 = PDP8([inst])
    pdp8.poke_mem(addr,0)
    pdp8.poke_acc(a)
    pdp8()
    assert pdp8.peak_pc() == 1
    assert pdp8.peak_acc() == 0
    assert pdp8.peak_mem(addr) == a
Example #6
0
def test_prog_add():
    A, B = 4, 5
    code = [asm.cla(),
            asm.tad(A),
            asm.tad(B),
            asm.hlt()]
    pdp8 = PDP8(code)
    pdp8.poke_mem(A,3)
    pdp8.poke_mem(B,4)
    pdp8.run()
    assert pdp8.peak_acc() == 7
Example #7
0
def test_indirect():
    addr = 1
    data = 2
    value = 0o7777
    inst = asm.tad(addr,i=asm.IA.INDIRECT)
    pdp8 = PDP8([inst])
    pdp8.poke_mem(addr,Word(data))
    pdp8.poke_mem(data,Word(value))
    pdp8()
    assert pdp8.peak_pc() == 1
    assert pdp8.peak_acc() == value
Example #8
0
def test_prog_cmp():
    data = 14
    A, B = data, data+1
    code = [asm.cla(cll=1),
            asm.tad(A),
            asm.cia(),
            asm.tad(B),
            asm.hlt()]
    pdp8 = PDP8(code)
    pdp8.poke_mem(A,3)
    pdp8.poke_mem(B,4)
    pdp8.run()
    assert pdp8.peak_lnk() == 1
Example #9
0
def test_lnk():
    addr = 4
    inst = asm.tad(addr)
    pdp8 = PDP8([asm.tad(addr),asm.cll(),asm.cml()])
    pdp8.poke_mem(addr,Word(0o7777))
    pdp8.poke_acc(1)
    pdp8()
    assert pdp8.peak_pc() == 1
    assert pdp8.peak_acc() == 0
    assert pdp8.peak_lnk() == 1
    pdp8()
    assert pdp8.peak_lnk() == 0
    pdp8()
    assert pdp8.peak_lnk() == 1
Example #10
0
def test_prog_xor2():
    data = 14
    A, B, C = data, data+1, data+2
    code = [asm.cla(),
            asm.tad(A),
            asm.and_(B),
            asm.opr1(cll=1, ral=1),
            asm.opr1(cma=1, iac=1),
            asm.tad(A),
            asm.tad(B),
            asm.hlt()]
    pdp8 = PDP8(code)
    pdp8.poke_mem(A,3)
    pdp8.poke_mem(B,4)
    pdp8.run()
    assert pdp8.peak_acc() == 7
Example #11
0
def test_prog_or():
    data = 10
    A, B, C = data, data+1, data+2
    code = [asm.cla(),
            asm.tad(A),
            asm.cma(),
            asm.dca(C),
            asm.tad(B),
            asm.cma(),
            asm.and_(C),
            asm.cma(),
            asm.hlt()]
    pdp8 = PDP8(code)
    pdp8.poke_mem(A,3)
    pdp8.poke_mem(B,4)
    pdp8.run()
    assert pdp8.peak_acc() == 7
Example #12
0
def test_rtr():
    pdp8 = PDP8([asm.rtr()])
    pdp8.poke_acc(4)
    pdp8()
    assert pdp8.peak_pc() == 1
    assert pdp8.peak_acc() == 1
Example #13
0
def test_jmp():
    addr = 2
    inst = asm.jmp(addr)
    pdp8 = PDP8([inst])
    pdp8()
    assert pdp8.peak_pc() == addr
Example #14
0
def test_cml():
    pdp8 = PDP8([asm.cml()])
    pdp8.poke_lnk(1)
    pdp8()
    assert pdp8.peak_lnk() == 0
Example #15
0
def test_cla():
    pdp8 = PDP8([asm.cla()])
    pdp8.poke_acc(1)
    pdp8()
    assert pdp8.peak_acc() == 0
Example #16
0
def test_ral():
    pdp8 = PDP8([asm.ral()])
    pdp8.poke_acc(1)
    pdp8()
    assert pdp8.peak_pc() == 1
    assert pdp8.peak_acc() == 2
Example #17
0
def test_sna():
    pdp8 = PDP8([asm.sna()])
    pdp8.poke_acc(1)
    pdp8()
    assert pdp8.peak_pc() == 2
Example #18
0
def test_cia():
    pdp8 = PDP8([asm.cia()])
    pdp8.poke_acc(0o7777)
    pdp8()
    assert pdp8.peak_acc() == 1
Example #19
0
def test_iac():
    pdp8 = PDP8([asm.iac()])
    pdp8()
    assert pdp8.peak_acc() == 1
Example #20
0
def test_stl():
    pdp8 = PDP8([asm.stl()])
    pdp8.poke_lnk(0)
    pdp8()
    assert pdp8.peak_lnk() == 1