How much DATA can be used in SX/B
Jim Fouch
Posts: 395
I have a project that I need to send several packets of Bytes using DATA statements to store the packets. These packets contain a starting Byte that says how many bytes are in that packet, followed by the actual packet bytes. Here is are the packets I have to send...
I need to start at the first packet and move through each packet and process each one. My thought was to have a label before the first packet and use a counter index to keep track of which data packet I was on, however I know I have more than 255 data bytes. I'm going to have to break the total packets into 3-4 smaller groups.
I'm wondering if the SX28 will have enough memory. Also, will I have problems with overrunning page boundrys.
Jim
DATA $05,$01,$42,$00,$00,$00 DATA $05,$01,$43,$00,$01,$00 DATA $09,$01,$45,$00,$5A,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$46,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$46,$00,$01,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$47,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$4C,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$4C,$00,$01,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$4D,$00,$FF,$FF,$FF,$FF,$FF,$FF DATA $09,$01,$41,$00,$5A,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$43,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $05,$01,$42,$00,$00,$00 DATA $05,$01,$42,$00,$00,$00 DATA $05,$01,$42,$00,$00,$00 DATA $05,$01,$42,$00,$00,$00 DATA $05,$01,$43,$00,$01,$00 DATA $09,$01,$44,$00,$01,$03,$00,$00,$00,$00 DATA $09,$01,$43,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $05,$01,$42,$00,$00,$00 DATA $05,$01,$42,$00,$00,$00 DATA $09,$01,$43,$00,$01,$00,$00,$00,$00,$00 DATA $09,$01,$45,$00,$5A,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$46,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$46,$00,$01,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$47,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$4C,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$4C,$00,$01,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$4D,$00,$00,$01,$FF,$FF,$FF,$FF DATA $09,$01,$41,$00,$5A,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$43,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $05,$01,$42,$00,$00,$00 DATA $09,$01,$42,$00,$00,$00,$00,$00,$00,$00 DATA $09,$01,$42,$00,$00,$00,$00,$00,$00,$00 DATA $09,$01,$42,$00,$00,$00,$00,$00,$00,$00 DATA $09,$01,$43,$00,$01,$00,$00,$00,$00,$00 DATA $09,$01,$44,$00,$01,$03,$00,$00,$00,$00 DATA $09,$01,$43,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$42,$00,$00,$00,$00,$00,$00,$00 DATA $09,$01,$42,$00,$00,$00,$00,$00,$00,$00 DATA $09,$01,$43,$00,$01,$00,$00,$00,$00,$00 DATA $09,$01,$4F,$00,$FF,$FF,$03,$00,$00,$00 DATA $09,$01,$40,$00,$00,$02,$00,$00,$00,$00 DATA $09,$01,$40,$00,$01,$02,$00,$00,$00,$00 DATA $09,$01,$40,$00,$02,$02,$00,$00,$00,$00 DATA $09,$01,$40,$00,$03,$02,$00,$00,$00,$00 DATA $09,$01,$40,$00,$04,$02,$00,$00,$00,$00 DATA $09,$01,$40,$00,$05,$02,$00,$00,$00,$00 DATA $09,$01,$40,$00,$06,$02,$00,$00,$00,$00 DATA $09,$01,$40,$00,$07,$02,$00,$00,$00,$00 DATA $09,$01,$40,$00,$08,$02,$00,$00,$00,$00 DATA $09,$01,$40,$00,$09,$02,$00,$00,$00,$00 DATA $09,$01,$40,$00,$0A,$02,$00,$00,$00,$00 DATA $09,$01,$40,$00,$0B,$02,$00,$00,$00,$00 DATA $09,$01,$43,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$42,$00,$00,$00,$00,$00,$00,$00 DATA $05,$01,$42,$00,$00,$00 DATA $15,$01,$43,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DATA $09,$01,$45,$00,$5A,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$46,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$46,$00,$01,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$47,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$4C,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$4C,$00,$01,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$4D,$00,$00,$01,$FF,$FF,$FF,$FF DATA $09,$01,$41,$00,$5A,$5A,$5A,$5A,$5A,$5A DATA $09,$01,$43,$00,$00,$5A,$5A,$5A,$5A,$5A DATA $05,$01,$42,$00,$00,$00 DATA $15,$01,$42,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DATA $15,$01,$42,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DATA $15,$01,$43,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DATA $09,$01,$4D,$00,$00,$01,$FF,$FF,$FF,$FF DATA $09,$01,$43,$00,$00,$5A,$5A,$5A,$5A,$5A
I need to start at the first packet and move through each packet and process each one. My thought was to have a label before the first packet and use a counter index to keep track of which data packet I was on, however I know I have more than 255 data bytes. I'm going to have to break the total packets into 3-4 smaller groups.
I'm wondering if the SX28 will have enough memory. Also, will I have problems with overrunning page boundrys.
Jim
Comments
As of version 1.4 the READ command can use two variables (as base and offset) to read data from large tables.
See the help file under "READ", the base and offset basically form a 16-bit pointer to the data being read.
I didn't count all the bytes in the data lines, but they use program space. So you have 2K for data and program.
[noparse][[/noparse]edit] Okay it looks like you have about 720 bytes of data, so that's going to use about 35% of your program space.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Forget about the past, plan for the future, and live for today.
Post Edited (Bean (Hitt Consulting)) : 12/14/2005 6:25:56 PM GMT
Thanks,
Jim
Using "READ base+offset" you data block can be as large as you want.
See the help file. When the offset "rolls-over" from 255 to zero you simple add 1 to the base.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Forget about the past, plan for the future, and live for today.
·
Determine the packet number needed (Lets call this pnum)
Read the pnum'th entry of the offset table (Lets call this offset)
Shift offset to the left once (same as multiply by 2)
If carry bit is set goto UpperHalf else
· Read data at packet data base address + offset
· Continue to process the data by incrementing the offset number until packet data is exhausted
End of algorithm branch
UpperHalf branch:
· Read data at packet data base address + 256 + offset
· Continue to process the data by incrementing the offset number until packet data is exhausted
End of algorithm branch
By using double indirection, you can eliminate duplicate packets. Since the first packet is the same as the 12th-15th packets, the 12th-15th entries in the offset table would also be $00 and 24 bytes will be saved, because it is processed as though that data was stored for each of the packets. This method is more robust than the run length encoded that you are thinking about because it removes all duplicate packets, not just the identical ones that are adjacent.
This is a fairly advanced method of data encoding so dont be afraid to ask for clarification on anything you don't fully understand.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 12/14/2005 8:29:24 PM GMT
This is a great Idea!!! I'll give it a try. Thanks...
Jim
Now get this, I just recalculated your packets using both double indirection (eliminating duplicate packets), and removing the two constant bytes, and guess what I calculate the total number of bytes are? 256! Here is the packet data table Ive made:
This means you dont need to do the divide by 2 trick to accomodate all of the table! The algorithm would look something like this:
Determine the packet number needed (Lets call this pnum)
Read the pnum'th entry of the offset table (Lets call this offset)
Output $01 for the first packet data byte
Read data at packet data base address + offset·and output
Output $00 for the third packet data byte
Increment offset
Read data at packet data base address + offset and output
Continue to process the data by incrementing the offset number until packet data is exhausted
End of algorithm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 12/14/2005 9:04:47 PM GMT
Your idea worked great. It's amazing the the talent on this forum!
Strange how numbers work out. I was also amazed to see the Packet·data worked out to be 256 bytes.· LOL
Jim
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 12/15/2005 2:40:01 PM GMT
And just as important.
Great work Paul.
-cbmeeks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://metroidclassic.com
=========
DMCA Sucks
RIAA Sucks