May I make a first request?
parsko
Posts: 501
Calling on Paul Baker, the newest member of the Parallax family.· Congrats sir.· I have a request of you that I have been waiting for the right moment to ask, and this seems appropriate.· In the previous post:
http://forums.parallax.com/showthread.php?p=589773
you state.....
-Parsko
http://forums.parallax.com/showthread.php?p=589773
you state.....
Now that it is practically your job to explain this stuff (I know, it's voluntary), would you care to explain what is going on here in more detail??· I have since figured out how to pass an array to an assy COG, but everytime I read this forum post, I keep telling myself to ask about this section of code, cause it looks like some lean clever code...Paul Baker (Parallax) said...
Im not sure whats going wrong with you program, it very well may be the spin code thats misbehaving, I'll share my code but it uses a lot of non-standard tricks which would take a while to explain::hptr mov :hptr, par 'use this loc as ptr to hub mem mov :i, #CogBufSz2 'reinit counter wrlong :d_inc, :hptr 'write non-zero to signal start add :hptr, #1 'inc hub pointer :writeloop wrlong fbufstart, :hptr 'write long to main memory add :writeloop, :d_inc 'inc buffer pointer add :hptr, #4 'inc hub pointer 1 long djnz :i, #:writeloop 'empty entire buffer
-Parsko
Comments
This would be clearer if the HUB RAM pointer were stored in a separate location and if the initialization code at the beginning
also initialized :writeloop like with a "movd :writeloop,#fbufstart" with the instruction at :writeloop written as
"wrlong 0-0,:hptr". That makes it clearer that this instruction is modified, but takes an extra instruction. Unfortunately,
doing any kind of indexing of the destination or source fields requires instruction modification on the Propeller. It works great, but can be confusing if you don't document it carefully.
Post Edited (Mike Green) : 9/7/2006 2:16:28 PM GMT
I·used the code in a digital storage scope object (which should be one of the first objects I release, 1 mode works, I'm working on the other two modes).·So I was trying to squeeze everything into as small of a memory footprint as possible to provide as many memory locations for the data buffer as possible.
Also the code is designed to be executed through once then stop. I employed several tricks such as using an initalization instruction for a working variable as the variable's location as well. This is what I was doing with the :hptr location.
Thanks for pointing out the adding 1 to the hub pointer after first use, I intended it to be declared as a byte variable followed by an array of longs, but looking at the full code, I noticed this wasn't the case. I will have to modify the code either to declare it that way (and use wrbyte) or add 4.
The comments are the working comments and will be expanded before the object's release.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 9/7/2006 4:52:55 PM GMT