sndCogLut0 long sndCogLut0 whats up with this
Bob Drury
Posts: 236
in Propeller 2
The following code compiles . The Data declaration "sndCogLut0 long sndCogLut0" I would have thought the address value would be substituted but it something totally different. Using @sndCogLut0
does something different also. Whats' up?
Regards and Thanks
Bob (WRD)
CON _clkfreq = 200_000_000 'system clock CogNum = 1 'Cog to run PUB main() COGINIT(COGEXEC+CogNUM,@CogCode,@HubCode) waitms(5000) debug(udec(HubCode)) debug(udec(HubDataTable)) debug(udec(sndHubLut0)) repeat DAT ORG 0 'COG RAM CogCode nop debug(udec(CogCode)) debug(udec(CogDataTable)) debug(udec(sndCogLut0)) Loop0 nop jmp #Loop0 'Jump to HubCode CogDataTable long CogDataTable sndCogLut0 long sndCogLut0 DAT ORGH 'HUB RAM HubCode nop Loop1 nop jmp #Loop1 HubDataTable long HubCode '@HubCode start of HUBEXEC PASM sndHubLut0 long sndHubLut0
Comments
yeah that is sort of a pitfall.
Spin Code is relocatable and all addresses are relative to some base pointers relative to the object containing the code.
And here comes the dilemma with @ @@ and @@@
At compiletime aka
myAdr LONG @whatever gives you the offset not the actual Hub Address.
At runtime
myAddr:= @whatever gives you the actual HUB address
BST invented @@@ to give you a HUB address at compile time so
myAdr LONG @@@whatever would give a Hub Address, but not supported by PropTool/Pnut, I think FlexProp does it.
I do not really remember what @@ was for, - Offset inside Object, something.
So getting hold of a absolute Hub Address is quite a challenge when using Spin.
Mike
Thanks for Reply. Who is BST?
Regards
Bob (WRD)
http://www.fnarfbargle.com/bst.html
Hello on the other side:
Starting with COGEXEC then HUBEXEC works for loading DAT initial values. But if you need to have the address of HUB values it gets messy. How do you get a second pointer address for using HUB RAM with RDLONG and WRLONG. The following is one way that seems to work but it wouldn't be relocatable as and object. The code requires calculating the HubCode address .
The code is reading HUB RAM variable to COG RAM variable then COG RAM variable LUT RAM then LUT RAM To COG RAM then COG RAM Back to HUB RAM(seems to work).
is there a better way for loading the HubCodeAddress then having to calculate it?
Regards and Thanks
Bob (WRD)
If you use @Label in DAT sections, the hubaddress you get is relative to the object base address. You can get this baseaddress with @@0.
The following code passes this baseaddress in ptra, and has a (single instruction) subroutine to calculate the hubaddress from it.
That would help in determining multiple address locations. I will try out tomorrow. That would then allow code to be relocatable as an object.
Thanks and Regards
Bob (WRD)
Used @@0 and obtaining hubBase address addiing this to the symbol offset value @hubCode gives absolute address of huBCode. Works as stated thanks.
Is there synopsis of how the Propeller Tool compiles program?
By this I mean how the Spin2 code is compiled creating object addresses and how DAT file gets stored. I would think this would contain the definition of @@0 .
What I have found in the documentation is:
The @ ins and the friends @@ and @@@ are usually a Spin-syntax but often used in DAT sections thus also valid for assembler.
So in the case of REP the @ has a complete different meaning. @ instructs the compiler to See how many instructions follow the REP instruction to the symbol pointed to with @Symbol.
Regards and Thanks
Bob (WRD)