Reputation: 15
I need help with assembly codes and page crossing on program memory locations.
ORG 0x500;
BCF pclath,4;
BSF pclath,3;
CALL sub1_p1;
.
.
.
ORG 0x900;
sub1 :
:
RETURN
If I want to cross page boundaries in program memory. For example page 0 to page 3. What code should I write?
Upvotes: 1
Views: 665
Reputation: 10937
Bits 3 and 4 of PCLATH register determine the page number!
Examples:
BCF PCLATH,4 ;Select page0
BCF PCLATH,3 ;Select page0
CALL xpage0
...
BCF PCLATH,4 ;Select page 1
BSF PCLATH,3 ;Select page 1
CALL xpage1
...
BSF PCLATH,4 ;Select page2
BCF PCLATH,3 ;Select page2
CALL xpage2
...
BSF PCLATH,4 ;Select page 3
BSF PCLATH,3 ;Select page 3
CALL xpage3
...
Newer PIC16xxx MCPUs use special instruction MOVLP
.
Example:
MOVLP high HiProc2
CALL HiProc2
...
Upvotes: 1