;
; group e, test 2
;
; 16-bit memory stores
;

m4_include(..\tmacros.h)

INIT_TEST(e,0x02)

; Hop over data declarations

; declare symbols here
SYM(hop0)
SYM(word)
SYM(next0)
SYM(next1)
SYM(next2)
SYM(next3)
SYM(next4)
SYM(next5)
SYM(next6)
SYM(next7)
SYM(next8)
SYM(next9)


    ld.16    a,0x6000
    ld.16    b,0x0000
    st.16    0(a),b

; Begin test here

SUBTEST(1)

;   DP w/ 16-bit offset

    ld.16   b,0x6000
    lea	    a,-513(b)
    copy    dp,a
    ld.16    a,0x8012
    st.16    513(dp),a
    ld.16    a,0xff12
    ld.16    a,513(dp)
    cmpb.eq.16	a,0x8012,next0
    FAIL

next0:

SUBTEST(2)
    ld.16   a,0x6000
    lea	    a,-513(a)
    copy    dp,a
    ld.16    b,0x8012
    st.16    513(dp),b
    ld.16    a,513(dp)
    cmpb.eq.16	a,0x8012,next1
    FAIL

next1:

SUBTEST(3)

;   SP w/ 8-bit offset
;   NOTE: restore SP to 0x7000 after

    ld.16   a,0x6000
    lea	    a,-122(a)
    copy    sp,a
    ld.16    a,0x7f12
    st.16    122(sp),a
    ld.16    a,0x0012
    ld.16    a,122(sp)
    cmpb.eq.16	a,0x7f12,next2
    FAIL

next2:
    ld.16   a,0x7000
    copy    sp,a

SUBTEST(4)
    ld.16   a,0x6000
    lea	a,-13(a)
    copy    sp,a
    ld.16    b,0x0112
    st.16    13(sp),b
    ld.16    a,13(sp)
    cmpb.eq.16	a,0x0112,next3
    FAIL

next3:
    ld.16   a,0x7000
    copy    sp,a

SUBTEST(5)
    ld.16   a,0x6000
    lea	    a,-100(a)
    ld.16    b,0x8012
    st.16    100(a),b
    ld.16    a,100(a)
    cmpb.eq.16	a,0x8012,next4
    FAIL

next4:

SUBTEST(6)
    ld.16   a,0x6000
    lea	    b,-100(a)
    ld.16    a,0x8012
    st.16    100(b),a
    ld.16    a,100(b)
    cmpb.eq.16	a,0x8012,next5
    FAIL

next5:

SUBTEST(7)
    ld.16   b,0x6000
    lea	    a,-44(b)
    ld.16    b,0x7f12
    st.16    44(a),b
    ld.16    a,44(a)
    cmpb.eq.16	a,0x7f12,next6
    FAIL

next6:

SUBTEST(8)
    ld.16   b,0x6000
    lea	    b,-44(b)
    ld.16    a,0x7f12
    st.16    44(b),a
    ld.16    a,44(b)
    cmpb.eq.16	a,0x7f12,next7
    FAIL

next7:
    

SUBTEST(9)
    ld.16   a,0x6000
    copy    b,a
    st.16    0(a),a
    copy    a,b
    ld.16   b,0x6000
    cmpb.eq.16	a,0(b),next8
    FAIL
next8:

SUBTEST(10)
    ld.16   b,0x6000
    copy    a,b
    st.16    0(b),b
    cmpb.eq.16	a,0(b),next9
    FAIL
next9:

;   Finally, when done branch to pass
    END_TEST
