;
; group j, test 1
;
; or.8
;

m4_include(..\tmacros.h)

INIT_TEST(i,0x01)

; declare symbols here
SYM(hop)
SYM(d1)
SYM(d2)
SYM(d3)
SYM(d4)
SYM(d5)
SYM(d6)
SYM(d7)
SYM(next0)
SYM(next1)
SYM(next2)
SYM(next3)
SYM(next4)
SYM(next5)
SYM(next6)
SYM(next7)
SYM(next8)
SYM(next9)
SYM(next10)
SYM(next11)
SYM(next12)
SYM(next13)
SYM(next14)
SYM(next15)

    br	hop

    ; Declare data here.  Format is:
    ;	op1
    ;	op2
    ;	expected a result
    ;	expected flags result V S C Z

d1:
    defb    0xff
    defb    0x01
    defb    0xff
    defb    0x04
d2:
    defb    0x00
    defb    0x00
    defb    0x00
    defb    0x01
d3:
    defb    0xf0
    defb    0x0f
    defb    0xff
    defb    0x04
d4:
    defb    0x80
    defb    0x81
    defb    0x81
    defb    0x04

hop:
; Begin test here

SUBTEST(1)
;   <op>.8  a,u16(dp)
    ld.16   a,d1
    lea	    a,-555(a)
    copy    dp,a
    ld.8    a,555(dp)
    or.8   a,555+1(dp)
    push    msw
    cmpb.eq.8	a,555+2(dp),next0
    FAIL
next0:
    pop	    a
    and.8   a,0x5
    cmpb.eq.8	a,555+3(dp),next1
    FAIL
next1:

SUBTEST(2)
;   <op>.8  a,u8(sp) # Don't forget to reset SP!
    ld.16   a,d2
    lea	    a,-55(a)
    copy    sp,a
    ld.8    a,55(sp)
    or.8   a,55+1(sp)
    cmpb.eq.8	a,55+2(sp),next2
    FAIL
next2:
next3:
    ld.16   a,0x7000
    copy    sp,a

SUBTEST(3)
;   <op>.8  a,u8(b)
    ld.16   a,d3
    lea	    b,-5(a)
    ld.8    a,5(b)
    or.8   a,5+1(b)
    push    msw
    cmpb.eq.8	a,5+2(b),next4
    FAIL
next4:
    pop	    a
    and.8   a,0x5
    cmpb.eq.8	a,5+3(b),next5
    FAIL
next5:

SUBTEST(4)
;   <op>.8  a,u8
    ld.16   a,d4
    lea	    b,-15(a)
    ld.8    a,15(b)
    or.8   a,0x81
    push    msw
    cmpb.eq.8	a,15+2(b),next6
    FAIL
next6:
    pop	    a
    and.8   a,0x5
    cmpb.eq.8	a,15+3(b),next7
    FAIL
next7:

SUBTEST(6)
;   <op>.8  a,1
    ld.8    a,0x31
    or.8   a,1
    push    msw
    cmpb.eq.8	a,0x31,next10
    FAIL
next10:
    pop	    a
    and.8   a,0x5
    cmpb.eq.8	a,0,next11
    FAIL
next11:

SUBTEST(7)
;   <op>.8  a,b
    ld.8    a,-5
    ld.8    b,-5
    or.8   a,b
    push    msw
    cmpb.eq.8	a,-5,next12
    FAIL
next12:
    pop	a
    and.8   a,0x5
    cmpb.eq.8	a,4,next13
    FAIL
next13:

SUBTEST(8)
;   <op>.8  a,b
    ld.8    a,11
    ld.8    b,10
    or.8   a,b
    push    msw
    cmpb.eq.8	a,11,next14
    FAIL
next14:
    pop	a
    and.8   a,0x5
    cmpb.eq.8	a,0,next15
    FAIL
next15:



;   Finally, when done branch to pass
    END_TEST
