Starting Spin-Interpreter with new bytecode
headcrash
Posts: 12
in Propeller 1
Dear members,
I searched the forums really hard, but now I am stuck.
In order to understand how the Spin-interpreter is started from another cog, I wrote following program:
1. Spin-Code to blink on pin 27
- start new cog with pasm-prg
- stop it self
2. pasm-prg to start in another cog and
- copy the spin-byte-code (witch is stored in the DATA area as hex)
- start cog 0 with spin-interpreter
The byte-code stored in the DATA area is another spin-program to blink on Pin 26.
I wanted to avoid all the hassle with serial communication (SD-card, EEPROM) just to see, how to load another SPIN-prg to adress 0 in the Hub and how to start it.
I found some examples in the forums and booter.spin - and tried to strip the information down to the necessary.
In order to verify the steps, I used the Gear emulator. All runs well, until the Interpreter should start.
I saw the new Spin-code in Cog 0, but then nothing happens.
Testing on hardware showed the same result: nothing.
Is there someone out there, who would help me please ?
Thank You !
I searched the forums really hard, but now I am stuck.
In order to understand how the Spin-interpreter is started from another cog, I wrote following program:
1. Spin-Code to blink on pin 27
- start new cog with pasm-prg
- stop it self
2. pasm-prg to start in another cog and
- copy the spin-byte-code (witch is stored in the DATA area as hex)
- start cog 0 with spin-interpreter
The byte-code stored in the DATA area is another spin-program to blink on Pin 26.
I wanted to avoid all the hassle with serial communication (SD-card, EEPROM) just to see, how to load another SPIN-prg to adress 0 in the Hub and how to start it.
I found some examples in the forums and booter.spin - and tried to strip the information down to the necessary.
In order to verify the steps, I used the Gear emulator. All runs well, until the Interpreter should start.
I saw the new Spin-code in Cog 0, but then nothing happens.
Testing on hardware showed the same result: nothing.
Is there someone out there, who would help me please ?
Thank You !
Comments
I think part of the problem you're having is that the second parameter of cognew() is supposed to be the address of a long, and you're providing the address of a byte.
I do not know if your logic is sound. The purpose of cognew() -- when providing a Spin method as the first argument-- is to launch another interpreter and run the target code. My guess is that you're trying obfuscate the code you want to run. This seems counter to the idea the Propeller being very open.
Essentially, you have to have an assembly routine that copies the binary file of the new program (including the 16 byte header) to hub memory beginning at location 0. At this point, you can't have any Spin interpreters going because they're using the information in the program header. Once the copy is done, your assembly routine can start a Spin interpreter as shown.
thank you for the quick answer.
I have found the solution - now it works:
Now led #27 blinks 3 times and then led #26
What a good start in the new year of Propeller-discovery ;-)
Greetings