Spin, PASM, and a table in there too
Timothy D. Swieter
Posts: 1,613
I am working on a driver. The driver code is located in its own file - it is an object. There are SPIN routines at the top to start/stop the PASM driver that runs in its own cog. The driver is structured like the LM9033A driver: http://obex.parallax.com/objects/389/. So that means there are also SPIN routines that send commands to the PASM driver portion. Now, in addition to the DAT section having a PASM code, there is also a table. The table however is only accessed by the SPIN commands, that is there PASM routine does not access the table at all. That means there is no need to load the table into the COG when the PASM routine is launched.
What is the best way to include this table in the file? Should there be a DAT section with the table, then another DAT section with an ORG and the start of the program? I read that when a PASM code is launched it starts at the ORG and always loads the next 496 longs. That would mean it loads part of the table into the COG, which isn't really needed, if the table was after the ASM code. Am I right?
Thank you for the help,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
www.tdswieter.com
What is the best way to include this table in the file? Should there be a DAT section with the table, then another DAT section with an ORG and the start of the program? I read that when a PASM code is launched it starts at the ORG and always loads the next 496 longs. That would mean it loads part of the table into the COG, which isn't really needed, if the table was after the ASM code. Am I right?
Thank you for the help,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
www.tdswieter.com
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
· Prop Tools under Development or Completed (Index)
· Emulators (Micros eg Altair, and Terminals eg VT100) - index
· Search the Propeller forums (via Google)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
If however you're wanting to save memory, ( if you already have SD code in there, you could just have an empty file with with the PASM in, and load the binary into a buffer and start the cog that way. )
have the proggy for the pasm object like this
then compile that file, and save the binary,
the code will start $18 bytes into the binary, so when you load the file into a buffer, skip the first $18 bytes, or do cognew(@buffer+$18,parameter)
hope this helps.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
www.tdswieter.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
Cheers!
Paul Rowntree
When I have variables or parameters to pass to an ASM routine on startup (like pin configuration or timing values) I first setup variables in SPIN. Those variables are populated before launching the ASM cog. When the ASM cog is launched, it is passed the first variables address. Then in the ASSM routine, using Par. I learned to do it this way by studying code done by others. It makes sense to me, you can see an example of how I did this in the LCD LM9033A driver in the object exchange.
Now - I had a though. If there is a data table or buffer that changes often in HUB RAM, but the ASM code needs to know about it, would it be faster to design the ASM code such that it could be started and stopped each time when the table/buffer needs to be updated? In other words, is it faster to load the COG with 496 longs then to go through a loop to load the table of say 100 or 200 longs (assuming a short ASM program that can handle starting/stopping)?
I can probably study the data sheet to determine this.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
www.tdswieter.com
For short asm programs, i use the starting and stopping method to send data to a Nokia LCD that i ripped out of a cellphone.
The Nokia LCD has a cool feature where you can write to a specific section of the display that you can set. Because the entire screen is not refreshed, the amount of pixels sent changes depending on how big of an area is needed to be refreshed. The asm program reads the image buffer, sends the data to the LCD, and then writes a non zero number to the byte after the last pixel
sent. The spin cog waits until it reads a non zero value at this location. When this condition is met, the spin program stops the asm cog and move on to other things. The jump loop at the end of the asm program is just to keep that cog idle until it is stopped. With this part of this program in asm, I get a full screen refresh of about 40 hz, which is faster than the LCD can handle. In complete spin, I got a refresh rate of about .125 hz. PASM is my new friend!!!
Yes, I understand and use the initial stuffing of PASM values from spin in normal code; what I was referring to was the use of independently compiled cog codes (this is what launched this thread), such that the top-level spin does not know the addresses within the cogcode to be used as variable spaces.
I was wondering what the best way to stuff data into these systems. sorry about the imprecision ...
Cheers!
Paul Rowntree
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
www.tdswieter.com