;
; group u, test 2
;
; from_sys

m4_include(..\tmacros.h)

INIT_TEST(u,0x02)

; declare symbols here
SYM(next0)


SUBTEST(1)

;   set up stack
    ld.16   a,0x7000
    copy    sp,a

;   set things up
    call    setup_page_table

;   set up user ptb
    ld.16   a,2
    copy    ptb,a

;   map page 0 of user space to physical page 10
    ld.16   a,0xc00a
    ld.16   b,0x0000
    wdpte   a,(b)
    wcpte   a,(b)

;   turn paging on
    call    paging_on

; Make sure new page doesn't hold magic value
    ld.16   a,MEM0x7FFF_16
    lea	    a,0x5000(a)
    ld.16   b,0xdead
    st.16   0(a),b

; Now, copy MEM0x7fff to user page
    ld.16   a,MEM0x7FFF_16
    ld.16   b,MEM0x7FFF_16
    ld.16   c,2
    fromsys

; Okay, now see if the right value showed up
    ld.16   b,0x5000+MEM0x7FFF_16
    ld.16   a,0(b)
    cmpb.eq.16	a,0x7fff,next0
    FAIL

next0:

;   Clean up
    call    paging_off
    call    setup_page_table

;   Finally, when done branch to pass
    END_TEST


