No, that's good info to have in this thread.
Until now, I didn't know it either.
Gotta ask questions.
No, that's good info to have in this thread.
Until now, I didn't know it either.
Gotta ask questions.
DT
Hi DT,
I have a question as follows.
Code:MyArray1 VAR BYTE[200] ' This one won't fit into 16F877.
But instead of one array with 200 elements,
I can create five separate arrays with 40 elements each; in total I get 200.
Example:
Code:MyArray1 VAR BYTE[40] MyArray2 VAR BYTE[40] MyArray3 VAR BYTE[40] MyArray4 VAR BYTE[40] MyArray5 VAR BYTE[40]
However, it requries me to write more code to access them in a line.
Using your ASM magic as swhon in the previous posts, can we put these five arrays into one
array say Arg0 ?
Thus, I can then use something like,
Code:MyArray1 VAR BYTE[40] MyArray2 VAR BYTE[40] MyArray3 VAR BYTE[40] MyArray4 VAR BYTE[40] MyArray5 VAR BYTE[40] ASM ' DT's magical hands come in here ! '.... '...... '........ ENDASM ' Then, Arg0 VAR ' something 'Then, finally I can use Arg0[180], Arg0[120], etc...
Is this doable?
---------------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Hi, Sayzer
Why not use Peekcode and Pokecode ... or simply LOOKUP ( if no change in values ) ??? ... 255 values is the limit for Pic 16F.
With Peekcode/Pokecode, you also can load your data at once including a txt file ...
( No thought to the project section, of course ... !!! )
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Sayzer, are you saying that Using EXT with Labels in post #1 doesn't work? I don't think so![]()
Last edited by mister_e; - 27th May 2009 at 23:19.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
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 ...Then to use it ...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 RETURNOr something like this, which sets each element to it's own Idx value, then reads them back and displays the saved value.Code:Idx = 180 Abyte = 123 GOSUB PutArray Idx = 180 GOSUB GetArray LCDOUT DEC Idx,"=",DEC AbyteNot as easy as MyArray(180), but it's an option.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
Then if you want, you can add a couple macros to make it look more like what you wanted ...Which then lets you do this...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 ENDASMHTH,Code:MyByte VAR BYTE @ PutArray(_Idx, _MyByte) ; similar to MyArray(Idx) = MyByte @ GetArray(_Idx, _MyByte) ; similar to MyByte = MyArray(Idx)
DT
Hi Alain,
Yes, as you mentioned, the values change. I get data from PC into a Mem array.
Hi Steve, I need an array not a table. In post#1, the table is for constants, isn't it?
BTW, Apart from this subject, I have spent so much time working on that table but could not read the correct values back from that table. It was not stable.
Hi DT,
I had made something similar to your first example, but as you mentioned, it is not as easy as using something like Arg0[180].
I must learn this ASM thingie in much upper level to comeup with my own routines.
Thanks very much to all.
----------------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Hi all,
Darrell mentioned in his first post that EXT will not work with arrays,
Can anyone suggest an elegant way to receive serial BYTE data in and convert it to WORD data and then sort it? Obviously, this won't work and to do it straight-line would be a mess.
ThanksCode:ByteData var byte[32] BANK0 ASM Arg0 = _ByteData ; word Arg1 = _ByteData + 2 ; word Arg2 = _ByteData + 4 ; word Arg3 = _ByteData + 6 ; word Arg4 = _ByteData + 8 ; word Arg5 = _ByteData + 10 ; word Arg6 = _ByteData + 12 ; word Arg7 = _ByteData + 14 ; word Arg8 = _ByteData + 16 ; word Arg9 = _ByteData + 18 ; word Arg10 = _ByteData + 20 ; word Arg11 = _ByteData + 22 ; word Arg12 = _ByteData + 24 ; word Arg13 = _ByteData + 26 ; word Arg14 = _ByteData + 28 ; word Arg15 = _ByteData + 30 ; word ENDASM Arg0 VAR WORD EXT Arg1 VAR word EXT Arg2 VAR WORD EXT Arg3 VAR WORD EXT Arg4 VAR word EXT Arg5 VAR WORD EXT Arg6 VAR word EXT Arg7 VAR WORD EXT Arg8 VAR WORD EXT Arg9 VAR word EXT Arg10 VAR WORD EXT Arg11 VAR word EXT Arg12 VAR WORD EXT Arg13 VAR WORD EXT Arg14 VAR word EXT Arg15 VAR word EXT ........... '***Sort Array SUB ** collects 16 readings, sorts, and averages middle 8 ****** SortArray: CounterA=0 SortLoop: ' sorts 16 readings of RawData in order If Arg(CounterA+1) < Arg(CounterA) then DataA=Arg(CounterA) Arg(CounterA)=Arg(CounterA+1) Arg(CounterA+1+0)=DataA If CounterA > 0 then CounterA=CounterA-2 endif CounterA=CounterA+1 If CounterA < 15 then goto SortLoop
Bo
Hi Bo,
You just need to map a WORD variable to the beginning of the BYTE array.
The Arg word array now overlaps the ByteData array.Code:ByteData VAR BYTE[32] Arg VAR WORD EXT @Arg = _ByteData
PBP does not do any bounds checking on arrays, so even though Arg is defined as a single WORD, you can use it as a 16 word Array.
DT
Thank you again, Darrel for going deeper than most could ever go alone!
I'm afraid that the neutrons just didn't thermalize....(when the energy doesn't slow down enough for it to transfer)
I understand the Arg word array now overlapping the ByteData array.
What I'm at a loss with is how to address the Arg words.
I tried: Arg0, Arg1,... Arg0 = Arg + 1, ... Arg0 = _Arg + 1, ... cant get anything to fly.
Compiled this:
and could see in the .lst file that:Code:ByteData var byte[32] BANK0 Arg VAR WORD EXT @Arg = _ByteData CounterB var byte for CounterB = 0 to 31 ByteData[CounterB]= CounterB next CounterB ASM Arg0 = Arg + 2 ; word Arg1 = Arg + 4 ; word ENDASMSo it looks like it assigned addresses. As soon as I added this to the end:Code:Arg 00000080 Arg0 00000082 Arg1 00000084I got a "Bad Expression" error. I would have expected to fill ByteData with sequential numbers 0-31 and be able to send them out to verify that the WORDs were filled with BYTE{0], BYTE[1] and BYTE{2], BYTE[3].Code:hserout[dec Arg0,10,13] hserout[dec Arg1,10,13]
Your humble servant requests more enlightenment....
Bo
Bookmarks