
Originally Posted by
sayzer
Is this doable?
Hi Sayzer,
No, EXT won't work that way.
The arrays would not be contiguous, and located in different banks.
I've never tried using big arrays on a 16F before, I'd just use an 18F when I need more than 96 bytes.
However, confronted with a challenge ... I have to try.
Here's what I've come up with ...
Code:
Array1Size CON 64
Array2Size CON 96 ; 96 is the largest for 16F877
Array3Size CON 96 ; 96 + 96 + 64 = 256 bytes
MyArray1 VAR BYTE[Array1Size]
MyArray2 VAR BYTE[Array2Size]
MyArray3 VAR BYTE[Array3Size]
Idx VAR BYTE
Abyte VAR BYTE
;---------------------------------------------------------------------------
GetArray: ; Set Idx before calling, result is in Abyte
SELECT CASE Idx
CASE IS < Array1Size
Abyte = MyArray1(Idx)
CASE IS < (Array1Size + Array2Size)
Abyte = MyArray2(Idx - Array1Size)
CASE ELSE
Abyte = MyArray3(Idx - (Array1Size + Array2Size))
END SELECT
RETURN
PutArray: ; set Idx and Abyte before calling
SELECT CASE Idx
CASE IS < Array1Size
MyArray1(Idx) = Abyte
CASE IS < (Array1Size + Array2Size)
MyArray2(Idx - Array1Size) = Abyte
CASE ELSE
MyArray3(Idx - (Array1Size + Array2Size)) = Abyte
END SELECT
RETURN
Then to use it ...
Code:
Idx = 180
Abyte = 123
GOSUB PutArray
Idx = 180
GOSUB GetArray
LCDOUT DEC Idx,"=",DEC Abyte
Or something like this, which sets each element to it's own Idx value, then reads them back and displays the saved value.
Code:
Main:
FOR Idx = 0 to 255
Abyte = Idx
GOSUB PutArray
NEXT Idx
FOR Idx = 0 to 255
GOSUB GetArray
HSEROUT ["G-",IDEC3 Idx," ",IDEC Abyte,13,10]
NEXT Idx
STOP
Not as easy as MyArray(180), but it's an option.
Then if you want, you can add a couple macros to make it look more like what you wanted ...
Code:
ASM
#GetArray macro Idx, Bout
MOVE?BB Idx, _Idx
L?CALL _GetArray
MOVE?BB _Abyte, Bout
endm
#define GetArray(Idx, Bout) #GetArray Idx, Bout
#PutArray macro Idx, Bin
MOVE?BB Idx, _Idx
MOVE?BB Bin, _Abyte
L?CALL _PutArray
endm
#define PutArray(Idx, Bin) #PutArray Idx, Bin
ENDASM
Which then lets you do this...
Code:
MyByte VAR BYTE
@ PutArray(_Idx, _MyByte) ; similar to MyArray(Idx) = MyByte
@ GetArray(_Idx, _MyByte) ; similar to MyByte = MyArray(Idx)
HTH,
Bookmarks