;
; group d, test 1
;
; 8-bit memory loads
;

m4_include(..\tmacros.h)

INIT_TEST(d,0x01)

; declare labels here
SYM(next0)
SYM(next1)
SYM(next2)
SYM(next3)
SYM(next4)
SYM(next5)
SYM(next6)
SYM(next7)

; Begin test here

SUBTEST(1)

;   DP w/ 16-bit offset

    ld.16   b,MEM0x80_8
    lea	    a,-513(b)
    copy    dp,a
    ld.8    a,513(dp)
    cmpb.eq.8	a,0x80,next0
    FAIL

next0:

SUBTEST(2)
    ld.16   a,MEM0x80_8
    lea	    a,-513(a)
    copy    dp,a
    ld.8    b,513(dp)
    copy    a,b
    cmpb.eq.8	a,0x80,next1
    FAIL

next1:

SUBTEST(3)

;   SP w/ 8-bit offset
;   NOTE: restore SP to 0x7000 after

    ld.16   a,MEM0x7F_8
    lea	    a,-122(a)
    copy    sp,a
    ld.8    a,122(sp)
    cmpb.eq.8	a,0x7f,next2
    FAIL

next2:
    ld.16   a,0x7000
    copy    sp,a

SUBTEST(4)
    ld.16   a,MEM0x01_8
    lea	a,-13(a)
    copy    sp,a
    ld.8    b,13(sp)
    copy    a,b
    cmpb.eq.8	a,0x01,next3
    FAIL

next3:
    ld.16   a,0x7000
    copy    sp,a

SUBTEST(5)
    ld.16   a,MEM0x80_8
    lea	    a,-100(a)
    ld.8    b,100(a)
    copy    a,b
    cmpb.eq.8	a,0x80,next4
    FAIL

next4:

SUBTEST(6)
    ld.16   a,MEM0x80_8
    lea	    b,-100(a)
    ld.8    b,100(b)
    copy    a,b
    cmpb.eq.8	a,0x80,next5
    FAIL

next5:

SUBTEST(7)
    ld.16   b,MEM0x7F_8
    lea	    a,-44(b)
    ld.8    a,44(a)
    cmpb.eq.8	a,0x7f,next6
    FAIL

next6:

SUBTEST(8)
    ld.16   b,MEM0x7F_8
    lea	    b,-44(b)
    ld.8    a,44(b)
    cmpb.eq.8	a,0x7f,next7
    FAIL

next7:
    

;   Finally, when done branch to pass
    END_TEST
