;
; group t, test 2
;
; syscall
;
; Very similar to bkpt and trapo, but advances pc to point to
; next instruction.

m4_include(..\tmacros.h)

INIT_TEST(t,0x02)

; declare symbols here
SYM(following_addr)
SYM(do_syscall)
SYM(resume_addr)
SYM(fail0)

SUBTEST(1)
    ld.16   a,do_syscall
    ld.16   b,v_syscall
    st.16   0(b),a
    ld.16   a,0x7000
    copy    sp,a
    ld.16   a,0x8000
    add.16  a,a
    ld.16   a,0x1111
    copy    dp,a
    ld.16   b,0x2222
    ld.16   c,0x3333
    ld.16   a,0x4444
    syscall 0x88
following_addr:
    br	resume_addr

fail0:
    FAIL

do_syscall:
 
     ld.16    a,0(sp)
    cmpb.ne.16	a,0x1111,fail0
    ld.16   a,2(sp)
    cmpb.ne.16	a,0x3333,fail0
    ld.16   a,4(sp)
    cmpb.ne.16	a,0x2222,fail0
    ld.16   a,6(sp)
    cmpb.ne.16	a,0x88,fail0
    ld.16   a,8(sp)
    cmpb.ne.16	a,following_addr,fail0
    ld.16   a,12(sp)
    cmpb.ne.16	a,0x7000,fail0

    reti
    FAIL

resume_addr:
    ld.16   c,0xbd10

;   Finally, when done branch to pass
    END_TEST
