Christian Dorner wrote:
{Quote hidden}>
> Hi everyone!
>
> Currently i try to write a little training program to learn more about
> jumping between page boundaries. (inspirated by a Msg from Olin who do this
> with linker sections ...)
>
> But when i try my code in MPLAB-SIM the jumps/calls between the pages work
> fine just the return dosn't work like documented in the PIC-Datasheets. The
> problem seems to be that MPLAB-SIM dosn't restore the PCLATH (from the
> stack).
>
> Is this a known Bug in MPLAB-SIM or do i something wrong?
>
> TIA
>
> Christian
>
> --
>
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
> email
EraseMElistservspam_OUT
TakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body
MPLAB or the processor does not restore the PCLATH after a CALL or GOTO
instruction.
Here is a little snippet I use to demonstrate ROM addressing. This one
will not work because the PCLATH register is not set for the call...
Title "mICros PCLATH Program 2"
list p=16f873 ; processor type
;
; The purpose of this program is to demonstrate the PCLATH register
; jumping over a page boundary
;
PCLATH equ 0x0A ; define PCLATH register
;
; -------------
; PROGRAM START
; -------------
;
org 0000h ; code starts at address 0
Loop call Delay ; execute Delay subroutine
goto Loop ; repeat forever
nop
nop
Error1 goto Error1
;
; Delay subroutine starts at 0800h
;
org 0800h
Error2 goto Error2
nop
nop
nop
Delay nop ; very small delay subroutine
nop
return
end
This one will not work either because the PCLATH is not restored after
the call...
Title "mICros PCLATH Program 3"
list p=16f873 ; processor type
;
; The purpose of this program is to demonstrate the PCLATH register
; jumping over a page boundary
;
PCLATH equ 0x0A ; define PCLATH register
;
; -------------
; PROGRAM START
; -------------
;
org 0000h ; code starts at address 0
Loop movlw High(Delay)
movwf PCLATH
call Delay ; execute Delay subroutine
goto Loop ; repeat forever
nop
nop
Error1 goto Error1
;
; Delay subroutine starts at 0800h
;
org 0800h
Error2 goto Error2
nop
nop
nop
Delay nop ; very small delay subroutine
nop
return
end
This one will work because PCLATH was set before the call and restored
after the call...
Title "mICros PCLATH Program 4"
list p=16f873 ; processor type
;
; The purpose of this program is to demonstrate the PCLATH register
; jumping over a page boundary
;
PCLATH equ 0x0A ; define PCLATH register
;
; -------------
; PROGRAM START
; -------------
;
org 0000h ; code starts at address 0
Loop movlw High(Delay)
movwf PCLATH
call Delay ; execute Delay subroutine
clrf PCLATH
goto Loop ; repeat forever
nop
nop
Error1 goto Error1
;
; Delay subroutine starts at 0800h
;
org 0800h
Error2 goto Error2
nop
nop
nop
Delay nop ; very small delay subroutine
nop
return
end
There is a more detailed explanation in the project file at...
http://www.bubblesoftonline.com/projects.zip
--
Best regards
Tony
mICros
http://www.bubblesoftonline.com
sales
spam_OUTbubblesoftonline.com
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspam
mitvma.mit.edu with SET PICList DIGEST in the body