Is FullDuplexSerial Annotated or Documented Anywhere?
coryco2
Posts: 107
I have been playing with the FullDuplexSerial object recently, and was thinking how useful it would be for coding newbies (e.g. me) to have the function of each line of code documented/annotated in plain English, for the purposes of education and customization. Does anyone know if such an exposition of this object exists anywhere? If not, would anyone else be interested in seeing this done?
Comments
It is kind of a problem that we don't have any good high level tutorials for this kind of thing, and the classic Parallax objects like TV, VGA, and FDS are very clever, elegant, and sparsely commented so that everyone who wants to write a video or serial driver ends up having to half-way invent it from the ground up.
In PASM there is no such instruction as CALL. CALL is a macro. When you CALL a subroutine, you are actually issuing a JMPRET dest_RET, #dest. What this means is that control is transferred to #dest, but the return address (the address after the JMPRET) is written to the S field of the PASM location dest_RET. That's why if you use CALL you have to label the return instruction of your routine with a label routine_name_RET. That RET is also a macro, which generates a JMP, and when the CALL JMPRET writes its S field it becomes a JMP back to where the CALL occurred.
That's how it works NORMALLY.
In a codestream like FDS, you manually issue a JMPRET that specifies a "return" point other than a "RET" macro. You can use this to pass off control between code streams each of which might need to bail at multiple points to let the other do processing; each process uses JMPRET to write the point at which it must be re-entered when the other process is done. FDS uses this to let its transmit and receive threads each execute asynchronously as if, except for the JMPRETs, each thread has sole control of the Cog.
Thanks, that is great!
Jim
Thanks also to pedward! I was unaware of "Gold Standard" objects until I found http://www.parallaxsemiconductor.com/goldstandard and the much better-documented version of FullDuplexSerial there.