;
; group g, test 3
;
; sbc a,b
;

m4_include(..\tmacros.h)

INIT_TEST(h,0x03)

; declare symbols here
SYM(next0)
SYM(next1)
SYM(next2)

SUBTEST(1)
;   sbc.16  a,b [with carry set]
    ld.16   a,0xffff
    ld.16   b,0x12
    ; set carry
    add.16  a,2
    ; now, sbc
    sbc.16  a,b
    cmpb.eq.16	a,0xffef,next0
    FAIL
next0:

SUBTEST(2)
;   sbc.16  a,a [carry not set]
    ld.16   a,0x0002
    ld.16   b,0x0002
    add.16  a,a
    sbc.16  a,b
    cmpb.eq.16	a,1,next1
    FAIL
next1:

SUBTEST(3)
;   check to make sure sbc is setting flags as well as consuming them
    ; set carry
    ld.16   a,10
    add.16  a,a
    ld.16   b,1
    sbc.16  a,b
    copy    a,msw
    and.8   a,0xf
    cmpb.eq.16	a,2,next2
    FAIL
next2:

;   Finally, when done branch to pass
    END_TEST
