;
; group e, test 3
;
; memcopy
;

m4_include(..\tmacros.h)

INIT_TEST(e,0x02)

; Hop over data declarations

; declare symbols here
SYM(next0)
SYM(next1)
SYM(next2)
SYM(next3)
SYM(next4)
SYM(next5)

        ld.16  a,0x6000
        ld.8   b,0xff
        st.8   0(a),b
        ld.8   b,0x01
        st.8   1(a),b
        ld.8   b,0x02
        st.8   2(a),b
        ld.8   b,0x03
        st.8   3(a),b
        ld.8   b,0x04
        st.8   4(a),b
        ld.8   b,0xee
        st.8   5(a),b

        ld.16  a,0x6100
        ld.8   b,0x44
        st.8   0(a),b
        ld.8   b,0x45
        st.8   1(a),b
        ld.8   b,0x46
        st.8   2(a),b
        ld.8   b,0x47
        st.8   3(a),b
        ld.8   b,0x48
        st.8   4(a),b
        ld.8   b,0x49
        st.8   5(a),b

; Begin test here

SUBTEST(1)

;   Copy 4 bytes, from 0x6000+1 to 0x6100+1
    ld.16   a,0x6100+1
    ld.16   b,0x6000+1
    ld.16   c,4
    memcopy

;   Now, test to make sure we didn't step on anything

    ld.16   b,0x6100
    ld.8    a,0(b)
    cmpb.eq.8	a,0x44,next0
    FAIL
next0:
    ld.8    a,1(b)
    cmpb.eq.8	a,0x01,next1
    FAIL
next1:
    ld.8    a,2(b)
    cmpb.eq.8	a,0x02,next2
    FAIL
next2:
    ld.8    a,3(b)
    cmpb.eq.8	a,0x03,next3
    FAIL
next3:
    ld.8    a,4(b)
    cmpb.eq.8	a,0x04,next4
    FAIL
next4:
    ld.8    a,5(b)
    cmpb.eq.8	a,0x49,next5
    FAIL
next5:

;   Finally, when done branch to pass
    END_TEST
