Flera sidor minne med picbasic
Postat: 14 december 2004, 12:33:38
Har försökt förstå mig på BRANCHL i PicBasic. Har förstått att det är det man ska använda om man vill nyttja mer än en sida av minnet. Pic16F628 ska ju ha 14*2048 byte. Får det inte att fungera, någon som har något tips, eller kan länka till ett bra exempel som ni gärna själva har testat. Det som finns i manualen får jag inte att fungera, går inte att compilera utan fel.
Urklipp ur manualen:
Syntax
BRANCHL Index, [Label1 {,...Labeln }]
Overview
Cause the program to jump to different locations based on a variable index. On a PIC device with more than one page of memory.
Operators
Index is a constant, variable, or expression, that specifies the address to branch to.
Label1,...Labeln are valid labels that specify where to branch to.
Example
DEVICE 16F84
DIM INDEX as BYTE
Start: INDEX = 2 ' Assign INDEX a value of 2
BRANCHL INDEX,[Lab_0, Lab_1, Lab_2] ' Jump to label 2 (Lab_2) because INDEX = 2
Lab_0: INDEX = 2 ' INDEX now equals 2
GOTO Start
Lab_1: INDEX = 0 ' INDEX now equals 0
GOTO Start
Lab_2: INDEX = 1 ' INDEX now equals 1
GOTO Start
The above example we first assign the index variable a value of 2, then we define our labels. Since the first position is considered 0 and the variable index equals 2 the BRANCHL command will cause the program to jump to the third label in the brackets [Lab_2].
Notes
The BRANCHL command is mainly for use with PICmicro devices that have more than one page of memory (greater than 2048). It may also be used on any PIC device, but does produce code that is larger than BRANCH.
Urklipp ur manualen:
Syntax
BRANCHL Index, [Label1 {,...Labeln }]
Overview
Cause the program to jump to different locations based on a variable index. On a PIC device with more than one page of memory.
Operators
Index is a constant, variable, or expression, that specifies the address to branch to.
Label1,...Labeln are valid labels that specify where to branch to.
Example
DEVICE 16F84
DIM INDEX as BYTE
Start: INDEX = 2 ' Assign INDEX a value of 2
BRANCHL INDEX,[Lab_0, Lab_1, Lab_2] ' Jump to label 2 (Lab_2) because INDEX = 2
Lab_0: INDEX = 2 ' INDEX now equals 2
GOTO Start
Lab_1: INDEX = 0 ' INDEX now equals 0
GOTO Start
Lab_2: INDEX = 1 ' INDEX now equals 1
GOTO Start
The above example we first assign the index variable a value of 2, then we define our labels. Since the first position is considered 0 and the variable index equals 2 the BRANCHL command will cause the program to jump to the third label in the brackets [Lab_2].
Notes
The BRANCHL command is mainly for use with PICmicro devices that have more than one page of memory (greater than 2048). It may also be used on any PIC device, but does produce code that is larger than BRANCH.