Spin and asm code using the same cog
Patrick1ab
Posts: 136
Hi everyone!
Is it somehow possible to call an assembler function without using another cog?
If yes, please let me know how to do this? If not, please try to tell me why it isn't possible?
Thanks
Patrick
Oops, seems I've found the answer in the manual:
But why can't the Spin interpreter "pass it on"?
Post Edited (Patrick1ab) : 4/18/2010 6:14:50 PM GMT
Is it somehow possible to call an assembler function without using another cog?
If yes, please let me know how to do this? If not, please try to tell me why it isn't possible?
Thanks
Patrick
Oops, seems I've found the answer in the manual:
Propeller Manual said...
Spin code is executed from Main RAM by a cog running the Spin Interpreter, however, Propeller Assembly code is executed directly from within a cog itself. Because of this nature, Propeller Assembly code and any data belonging to it must be loaded (in its entirety) into a cog in order to execute it. In this way, both assembly code and data are treated the same during the cog loading process.
But why can't the Spin interpreter "pass it on"?
Post Edited (Patrick1ab) : 4/18/2010 6:14:50 PM GMT
Comments
The reason it's not possible is your SPIN code is being executed by a COG, running the SPIN intrepeter. That takes the whole COG. PASM only executes in a COG, not the HUB. SPIN is actually a PASM program, that gets loaded onto a COG, which then "runs" your SPIN byte code, residing in the HUB.
When you call a PASM function, another COG must be loaded with the program, as that's where PASM runs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
8x8 color 80 Column NTSC Text Object
Safety Tip: Life is as good as YOU think it is!
It's a pity that it isn't possible.
Perhaps this could be a feature of future chips (maybe too late for Prop II)
If you've a few PASM things you need to get done, pack them into one COG, which then loops, checking HUB memory. Have a defined start value for each procedure, and shared memory locations to get results back to the SPIN program. The graphics library does this kind of thing. You have your SPIN program set the memory values up, pass them to the "library cog', which then waits. When it sees the value it needs to go off and do something, it does it, then resets the value back to the "waiting" value. Your SPIN program can then, just set a value, knowing something is going to get done, then it watches for the value to be reset, knowing the task is complete, with the data in the HUB.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
8x8 color 80 Column NTSC Text Object
Safety Tip: Life is as good as YOU think it is!
... and assuming you still have a free COG
Okay, I still have three, but maybe I'm going to need them later.
This is made in several objects I included in my program.
· That is an excellent idea, and should be possible.
· The LMM loop is really small (although in most implementations it is unrolled to make it faster).
· Here is the PropBasic LMM loop (I removed the unrolled loop to make is smaller).
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
There is only one unused spincode in the table -- $3C.· This code could be used to call the LMM interpreter.· When the LMM interpreter is done it would return back to the Spin interpreter.· It seems like it should work.
Dave
Actually thinking further, I handle jumps in a different way altogether.
@Dave:
Not only does there have to be room for the LMM execution but room for variables will also be required. Only $3C is unused, but there are other 2 byte codes that are not fully utilised. Doing a minimised LMM within the spin interpreter actually works as that is how my debugger runs on top of spin in shaddow ram. The debugger can trace all the pasm instructions of the interpreter and even single step them.
I said elsewhere that I initially used overlays so I could work on the Interpreter. This works well too if there is any loops in the code.
@Patrick1ab: PropII will not solve the problem as it is still limited to 496 (well actually it increases to about 508 IIRC) longs. Using a kludge with the current PropI I think we can actually squeeze 496 + about 6-7 = about 502-503 longs.
However, the moment we add inline pasm to spin, the requirement for variables will become apparent and that is when the fun begins (or ends!!!).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
When you are talking about variables in reference to inline pasm I assume you are referring to cog variables, correct?· In my previous post I suggested allowing for 16 cog variables and 32 longs for overlay space.· However, if the LMM code doesn't use the overlay it could use the 32 longs for variables.· Or maybe another way to look at it is that there would be 48 longs available for overlays and variables, which could be used in any combination that the programmer wants.
Are there spincodes that copy from hub ram to cog memory?· If there are, then the interpreter could be patched by overwritting a method with a small spincode program that would splice the LMM interpreter into the Spin interpreter.
Do you have a link for your debugger?· I'd like to take a look at it.
Dave
There is no spincodes that copy hub to cog, other than the normal byte read.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
I havent tried·out·but I think you could restart the current cog with a PASM section. When it's done you could reload the same cog with the spin interpreter and pass the spin routine to execute as argument. This should theoretically work as you can self-reload the curent cog with the COGINIT command. Reloading the cog takes a lot of cycles from the ASM point of view because it has to fetch 496 longs from cog memory. But it doesn't take longer as a few spin commands as spin is relatively slow.
Cheers
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
· Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz