;
; group u, test 5
;
; ldcode.8, stcode.8

m4_include(..\tmacros.h)

INIT_TEST(u,0x05)

; declare symbols here
SYM(next0)
SYM(next1)
SYM(next2)


SUBTEST(1)

;   set up stack
    ld.16   a,0x7000
    copy    sp,a

;   set things up
    call    setup_page_table

;   remap code page 10 to physical page 11
    ld.16   a,0xc00b
    ld.16   b,0x5000
    wcpte   a,(b)

;   turn paging on
    call    paging_on

; Use test location 0x5000, stuff 0x1234 in data, 0x4321 in code
    ld.16   b,0x5000
    ld.8   a,0x12
    st.8   0(b),a
    ld.8   a,0x43
    stcode.8	(b),a

; Test data ref - should be 0x1234
    ld.8   a,0(b)
    cmpb.eq.8	a,0x12,next0
    FAIL
next0:

; Test code ref using data load at 0x5000+2048
    ld.16   b,0x5000+2048
    ld.8   a,0(b)
    cmpb.eq.8	a,0x43,next1
    FAIL
next1:

; Test code ref using ldcode
    ld.16   a,0x0000
    ld.16   b,0x5000
    ldcode.8  a,(b)
    cmpb.eq.8	a,0x43,next2
    FAIL
next2:




;   Clean up
    call    paging_off
    call    setup_page_table

;   Finally, when done branch to pass
    END_TEST


