2014-03-26 07:08 AM
I have a jump table currently set-up like this
ProcTable DCD Proc1 DCD Proc2 DCD Proc3EndTableAnother part of my program that is acting as a processes manager which needs to keep track of the number of the process so it can calculate a stack pointer (PSP) for it so that each program has it's only section of the stack. I'm trying to use some sort of 'global variable' like this ''ProcCount DCD 0'' I then want to increment the value stored in ProcCount although I'm having trouble getting this to work, most examples I can find involve reading the value of ProcCount but never writing/updating the other way. I was trying to do something like this: LDR r2,=ProcCount ADD r4,r4,#1 STR r4, [r2] NOP LDR r5,ProcCount NOPI'm trying to add #1 to ProcCount then reading it back into r5 to check that it has changed (Nothing changes r5 stays at 0x0)2014-03-26 10:12 AM
LDR r2,=ProcCount
LDR r4, [r2] ADD r4,r4,#1 STR r4, [r2] NOP LDR r5,ProcCount NOP Might want to ensure that ProcCount is placed in a RAM/DATA section2014-03-26 11:44 AM
Hi Clive that's great,
I still don't get anything back into r5 when loading from ProcCount. I'm in Handler mode with Privilege using the MSP stack. Maybe the way I have set it up means I can't write back to it. How would I ensure it is placed in the RAM/DATA section as you mentioned?Thanks!2014-03-26 12:05 PM
I've just realised when fetching the address for ProcCount its in the 0x8 range which I believe is ROM, I know 0x2 is RAM. How do ensure ProcCount is in RAM so I can write back to it?
Thanks!2014-03-26 12:36 PM
;...
AREA |.data|, DATA, READWRITE, ALIGN=3
ProcCount DCD 0
;...
AREA |.text|, CODE, READONLY
2014-03-26 01:23 PM
Great thanks Clive, I had just about figured out what you were getting at after looking through the ARM setup files but couldn't quite get it working, your example worked.
I get an error ''.\file.axf: Error: L6286E'' when running the program now. If I comment out the line from the example given earlier ''LDR r1, ProcCount'' the error goes away, which I did to be able to run the program to try to debug it.When loading the address into r2 I now get something in the 0x2 range which is great.However when we get to ''LDR r4, [r2]'' I get ''0x2A001E52'' which I'm not expecting. Shouldn't [r2] dereference the address, which I think should have ''0'' in from our DCD instruction earlier. I'm in Thread mode, privileged, MSP if that makes a difference.Thanks