#
# TEST PROGRAM
#

# INSTR   IR15 IR14 IR13 IR12 IR11 IR10 IR09 IR08 IR07 IR06 IR05 IR04 IR03 IR02 IR01 IR00
# MOVE    0    0    0    0    X    X    X    X    K    K    K    K    K    K    K    K
# ADD     0    0    0    1    X    X    X    X    K    K    K    K    K    K    K    K
# SUB     0    0    1    0    X    X    X    X    K    K    K    K    K    K    K    K
# AND     0    0    1    1    X    X    X    X    K    K    K    K    K    K    K    K

# LOAD    0    1    0    0    X    X    X    X    A    A    A    A    A    A    A    A
# STORE   0    1    0    1    X    X    X    X    A    A    A    A    A    A    A    A
# ADDM    0    1    1    0    X    X    X    X    A    A    A    A    A    A    A    A
# SUBM    0    1    1    1    X    X    X    X    A    A    A    A    A    A    A    A

# JUMPU   1    0    0    0    X    X    X    X    A    A    A    A    A    A    A    A
# JUMPZ   1    0    0    1    X    X    X    X    A    A    A    A    A    A    A    A
# JUMPNZ  1    0    1    0    X    X    X    X    A    A    A    A    A    A    A    A

 
# ACC BIT TEST
# ------------

start:
    move   0x00
    move   0x01
    move   0x02
    move   0x04
    move   0x08
    move   0x10
    move   0x20
    move   0x40
    move   0x80
    move   0x40
    move   0x20
    move   0x10
    move   0x08
    move   0x04
    move   0x02
    move   0x01

# ADD TEST
# --------

    add    0xFF     # zero ACC
    add    0xF0     # load high nibble
    add    0x0F     # load low nibble
    add    0x01     # zero ACC

# SUB TEST
# --------

    sub    0x01     # set all bits high 
    sub    0xF0     # zero high nibble
    sub    0x0F     # zero low nibble 
    sub    0x01     # set all bits high 
    sub    0x01     # toggle all bits
    add    0x01
    sub    0x02
    add    0x02
    sub    0x04
    add    0x04
    sub    0x08
    add    0x08
    sub    0x10
    add    0x10
    sub    0x20
    add    0x20
    sub    0x40
    add    0x40
    sub    0x80
    add    0x80

# AND TEST
# --------

    and    0x7F     # toggle all bits
    and    0x3F
    and    0x1F
    and    0x0F
    and    0x07
    and    0x03
    and    0x01
    and    0x00

# LOAD / STORE TEST
# -----------------

    move   0x01     # store bit patterns to memory
    store  0xF8
    move   0x02
    store  0xF9
    move   0x04
    store  0xFA
    move   0x08
    store  0xFB
    move   0x10
    store  0xFC
    move   0x20
    store  0xFD
    move   0x40
    store  0xFE
    move   0x80
    store  0xFF

    load   0xF8     # load bit patterns from memory
    load   0xF9
    load   0xFA
    load   0xFB
    load   0xFC
    load   0xFD
    load   0xFE
    load   0xFF

# ADDM SUBM TEST
# --------------

    move 0x00       # toggle all bits
    addm 0xF8
    subm 0xF8
    addm 0xF9
    subm 0xF9
    addm 0xFA
    subm 0xFA
    addm 0xFB
    subm 0xFB
    addm 0xFC
    subm 0xFC
    addm 0xFD
    subm 0xFD
    addm 0xFE
    subm 0xFE
    addm 0xFF
    subm 0xFF

# JUMP TEST
# ---------

test1:
    move   0x00 - test jump taken
    jumpZ  test2
    move   0x0F

test2:
    move   0x01
    jumpNZ test3
    move   0x0F

test3:
    move   0x00 - test jump not taken
    jumpNZ test4
    jump   test5
test4:
    move   0x0F

test5:
    move   0x01
    jumpZ  test6
    jump   test7
test6:
    move   0x0F

test7:
    move   0x00
    jump   start












