newbie question: Inline assembly?
Roger Milne
Posts: 11
I am attempting to optimize some of my code from Spin to Assembly.
I hit the books, and couldn't see any way to inline assembly within my spin method.· Nor could I find a way to call an assembly function stored in a DAT block, without spawning another cog to go execute that code?· Is this true?· Help!· I'm itching to make my code faster!
····
Thanks!!
··· Roger
I hit the books, and couldn't see any way to inline assembly within my spin method.· Nor could I find a way to call an assembly function stored in a DAT block, without spawning another cog to go execute that code?· Is this true?· Help!· I'm itching to make my code faster!
····
Thanks!!
··· Roger
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
Morpheus & Mem+dual Prop SBC w/ 512KB kit $119.95, 2MB memory IO board kit $89.95, both kits $189.95
www.mikronauts.com - my site 6.250MHz custom Crystals for running Propellers at 100MHz
Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
Have your assembly cog looking for a one set in some long somewhere. When it sees it, it loads it's parameters and does it's thing, writing a zero when done.
Your parent cog watches for the 0 while doing it's thing.
Share data between the two with a block of longs in the HUB.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
Safety Tip: Life is as good as YOU think it is!
Not really a problem however as you have 8 cores. Use em.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
*Peter*
Thanks to everyone!
Roger
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Composite NTSC sprite driver: Forum
NTSC & PAL driver templates: ObEx Forum
OnePinTVText driver: ObEx Forum
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
Safety Tip: Life is as good as YOU think it is!
As a new-comer you should probably look at learning PASM the way the Propeller manual describes to do it. A vast majority of PASM code is written that way (this of course includes "Spinning" in a command listener). What Ken suggests is a reasonable and simple method that is usable with normal PASM coding (beat me to the post).
Still, what you have suggested is possible and I do something similar to that in my PASM BMA debugger at some cost in terms of extra HUB memory used. I don't have to restart a cog to do it. Starting a COG takes about 102us at 80MHz (12.5*16*512). Basically, a stub for handling COG maintenance (COG server?) is loaded into a COG, and a Spin object (COG client?) manages what the COG does. A set of PASM instructions ending with a JMP #1 (the COG server reentry) can be sent to the COG as needed from any source (a Coglet?) and run there in real-time. The source is available if you want to have a look in my .signature BMA debugger link. File PASMstub.spin has most of the methods to manage the COG server; the "GO" feature that tells the loaded code to run is in BMAutility.spin for version 1.3.
The LMM or Large Memory Model (as Bill Henning originally called it) is another method which has lots of developer history. LMM is slower than run-time PASM, can run up to 8K longs vs 512 in a COG, and is a little different from PASM. LMM is slower because it uses a COG loop to grab and "interpret" LMM-PASM from hub memory. Since the LMM-PASM code lives in the HUB, near 8K (32KB/4B per instructions) of PASM can be used per program load. The LMM deviations from normal PASM have to do with the way jumps and data are handled and is a little hard to follow at first.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propeller Tools
Now...back to your Inline PASM conversation....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I have not failed. I've just found 10,000 ways that won't work. "
- Thomas A. Edison
Ken, there is nothing short and fully comprehensive that I know of (because different people like different approaches).
Here are some wiki pages:
propeller.wikispaces.com/Large+Memory+Model
propeller.wikispaces.com/LMM+Phil+Pilgrim+(PhiPi)
propeller.wikispaces.com/LMM+Pacito
propeller.wikispaces.com/LMM+AiChip+Industries
Many people have written variations. ImageCraft produced one of the first widely used working implementations of LMM. Bill is morphing LMM into LAS (or has morphed it) which is supposed to make LMM less abstract. The original thread is here: http://forums.parallax.com/forums/default.aspx?f=25&m=154421
Hippy was I think the first to do several projects with LMM and I followed his work as examples. Here is an excerpt from Hippy's AI_Chip LMM version 1 (can't find the thread, but I believe there are later versions) which is an original and well thought description worthy of being included in a book (for royalties). Maybe someone will invite his participation some day.
A small performance enhancement done in ICC is to use "sub/add PC, offset" for jumps ... harder to read but faster.
Now, back to your regularly scheduled program ... brought to you by Ivory Soap!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propeller Tools
- Propalyzer: Propeller PC Logic Analyzer
- BMA: An on-chip PASM Debugger
- SPUD: Spin Source Level Debugger
Post Edited (jazzed) : 9/18/2009 5:47:44 PM GMTYes! I remember this now. Good for passing a parameter, return value, etc....
Funny how I used to think CALL was a separate instruction [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propeller Tools