$Mod52

AUXR EQU 08Eh

;testing P0 state after MOVX
;if MOVX goes to internal ERAM then it should not modify P0


Main:
;"prologue" - one slow blink with the non-P0 LED only
    mov  P1, #0FFh
    call Delay
    call Delay
    call Delay
    call Delay
    call Delay
    mov  P1, #0
    call Delay
    call Delay
    call Delay
    call Delay
    call Delay


    mov  auxr, #0       ;use ERAM
    mov  dptr, #0022h   ;
    mov  r3, #5
LoopX1:
    mov  P0, #0FFh
    mov  P1, #0FFh
    movx @dptr, a
    call Delay
    mov  P1, #0
    mov  P0, #0
    movx @dptr, a
    call Delay
    djnz r3, LoopX1

    mov  auxr, #2       ;don't use ERAM
    mov  dptr, #0022h
    mov  r3, #5
LoopX2:
    mov  P0, #0FFh
    mov  P1, #0FFh
    movx @dptr, a
    call Delay
    mov  P1, #0
    mov  P0, #0
    movx @dptr, a
    call Delay
    djnz r3, LoopX2

    mov  auxr, #2       ;switch on ERAM but access high address (i.e. XRAM)
    mov  dptr, #2222h
    mov  r3, #5
LoopX3:
    mov  P0, #0FFh
    mov  P1, #0FFh
    movx @dptr, a
    call Delay
    mov  P1, #0
    mov  P0, #0
    movx @dptr, a
    call Delay
    djnz r3, LoopX3


    jmp  Main


;cca 300ms delay
Delay:
    mov r5, #3
DelayX1:
    djnz r7, DelayX1
    djnz r6, DelayX1
    djnz r5, delayx1
    ret



    end
