problem to start the cog at a defined RAM adress
ImmNek
Posts: 29
Hi,
please don't worry about my really bad english. I'm a Swiss and I don't mastered the English language yet.
My problem is, that I want to start some assembly code in a cog from a self defined RAM adress using the org statement.
This is a symple code starting at the adress 0:
This code work properly.
But when I use an ohter RAM address, the code doesn't work:
This code doesn't work. I don't have any idea, why this code doesn't work properly and I realy hope someone can help me.
regards
Immanuel
please don't worry about my really bad english. I'm a Swiss and I don't mastered the English language yet.
My problem is, that I want to start some assembly code in a cog from a self defined RAM adress using the org statement.
This is a symple code starting at the adress 0:
org 0 '------------------------------------------------------------------------------- 'assembly code entry point asmEntry mov dira, #$FF mov asmTime, cnt add asmTime, asmCycles '------------------------------------------------------------------------------- 'toggle P0...P7 :loop waitcnt asmTime, asmCycles xor outa, #$FF jmp #:loop fit '------------------------------------------------------------------------------- 'constants asmCycles long 80_000 '------------------------------------------------------------------------------- 'momory reservation for symbols asmTime res 1
This code work properly.
But when I use an ohter RAM address, the code doesn't work:
org $FF '------------------------------------------------------------------------------- 'assembly code entry point asmEntry mov dira, #$FF mov asmTime, cnt add asmTime, asmCycles '------------------------------------------------------------------------------- 'toggle P0...P7 :loop waitcnt asmTime, asmCycles xor outa, #$FF jmp #:loop fit '------------------------------------------------------------------------------- 'constants asmCycles long 80_000 '------------------------------------------------------------------------------- 'momory reservation for symbols asmTime res 1
This code doesn't work. I don't have any idea, why this code doesn't work properly and I realy hope someone can help me.
regards
Immanuel
Comments
mycogroutine is a symbol with two addresses, one use inside the DAT (that later will be loaded to COG RAM via cognew) and one "public" used in the spin code and accessed via the @ operator. cognew starts to load from mycogroutine into COG RAM at address 0, so it is useful to have a match between the location of the symbols as defined in your program and the real position within COG memory. For that it is important that the address you give cognew is the zero address in what will be your COG program, ORG is useful exactly for that.
echte_routine has also two addresses, but only one is used here (in the jmp instruction)
I hope it is clear...
Post Edited (Ale) : 9/9/2008 2:18:10 PM GMT
As Ale guessed I want to use some space in the RAM for data. In Ale's code this is done with a jump to the "real" routine. I hope I'm right, when I think, that the first 4 bytes in the cog RAM are used for the jmp command. Then you reserve 4 longs (16 bytes) for data and initialize this longs with 0, is this right? The "real" (in German: echte) routine is placed after this 4 longs and you jump directly to this routine. I hope I understood it correct, please tell me, if I understood something wrong.
@Ale: Do you speak German?
Thanks a lot for this tip.
LONG 0[noparse][[/noparse] 4 ]
This reserves 4 longs and initializes them to 0.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
JMP #start
LONG 0[noparse][[/noparse]15]
start 'your code here
Just be aware that the first address will be junk at startup
(I have actually used this technique myself [noparse]:)[/noparse] )
LONG 0[noparse][[/noparse]16]
start 'your code here
Welcome ImmNek
I'm glad to see that other Swiss works with the Propeller chip!
Do you know the German Forum for the Propeller: propellerforum.sps-welt.de/portal.php ?
And here can you find my tools for the Propeller: www.insonix.ch/propeller
Andy
Yes, i know about this forum, but i decided to ask here, because here we have som Ingeneers from Parallax.
Are you the developer of PASD?
If somebody is a beginner, this forum isn't very helpful.
So, I tried to write a assembly code which toggles all IO-pins with a frequency of 1kHz.
And, as you guess, I didn't it well.
This is my code:
This code is runing on the Propeller DEMO REF F
I hope somebody can explain me my mistake in this code.
Thanks a lot
Immanuel
Post Edited (ImmNek) : 9/10/2008 1:21:12 PM GMT
This code works:
What I have done is using labels instead of the addresses from the cog RAM.
But why doesn't work my code with the direct RAM adresses? Can someone explaine it to me?
Thanks a lot
Immanuel
Post Edited (ImmNek) : 9/10/2008 1:56:26 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."
- Bjarne Stroustrup
The first long (data1) is at address 1, not 4. Addresses in cogs refer to 32-bit cells, not bytes.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Michael Park
PS, BTW, and FYI:
To search the forum, use search.parallax.com (do not use the Search button).
Check out the Propeller Wiki: propeller.wikispaces.com/
Yes I'm the author of PASD, and I think that would be the right tool for you to test your assembly code.
You can see what addresses the data1/data2 have and you see also every change in the asmData and outa register (CogRAM Viewer,
Pin Viewer), if you single step thru the code.
The included example makes something very similar to your Blink test code.
Andy
Thank you for you answer, I will test ist with the address you told me.
I thougt the cogRAM is like the hubRAM and the cells refer to bytes (8-bit cells). Now it is clear, why this code toggled the IO's in such a strange way.
But is it right, that the cells are physical 8-bit cells?
@Ariba:
You have done a greate work with PASD and now I'm using this tool.
But when I using the PASD, I have to insert the debug kernel at the begin of my ASM-code
and this effects, that my addresses are wrong.
What I think is a pity in PASD, is that you cant debug selfmodifieing code
(I guess this is in cause of your debug kernel), because such code is
very useful.
But anyway, your tool PASD is a greate software, thanks a lot.
Yes you can't use the first 12 longs with PASD, but normally one reserve the memory for variables and tables at the end
of the code anyway.
PASD is able to debug selfmodifying code, and shows also the modified value at single stepping. You only can not set a Breakpoint
on an address which will be modified. (Set it one instruction before and make an additional single step).
The CogRAM is organized as 512 x 32 bits, you can not access single bytes or words direct. For that you have to read the full long
and extract the byte or word with shifts and masks. Thats why you work normally only with long variables in assembly.
Andy