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