Can CogInit only start PASM at ORG 0 ?
Bean
Posts: 8,129
I'm working on some LMM code under BST.
This works:
But I wanted to get rid of the jmp after _LMM_JUMP, so I changed the code to this:
·But now it doesn't work, and I don't understand why ? Does the COGINIT address MUST be at ORG 0 ?
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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you choose not to decide, you still have made a choice. [noparse][[/noparse]RUSH - Freewill]
This works:
CON 'DEVICE P8X32A, XTAL1, PLL16X
_ClkMode = XTAL1 + PLL16X
_XInFreq = 5000000 'XIN 5_000_000
PUB __Program 'PROGRAM Start LMM
__PC := @Start
CogInit(0, @_LMM_LOOP, 0)
DAT
org 0
Start mov __temp1,#1 ' TOGGLE 15
shl __temp1,#15
or dira,__temp1
xor outa,__temp1
mov __temp2,#500 ' PAUSE 500
mov __temp1,_1mSec
add __temp1,cnt
__L0001
waitcnt __temp1,_1mSec
djnz __temp2,#_LMM_JUMP
long @@@__L0001
jmp #_LMM_JUMP ' GOTO Start
long @@@Start
DAT
ORG 0
_LMM_LOOP rdlong __INSTR1,__PC
add __PC,#4
__INSTR1 nop ' Placeholder for LMM instruction
jmp #_LMM_LOOP
_LMM_JUMP rdlong __PC,__PC
jmp #_LMM_LOOP
__PC LONG 0 ' Program counter
_1mSec LONG 80000
__temp1 RES 1
__temp2 RES 1
FIT $1F0
But I wanted to get rid of the jmp after _LMM_JUMP, so I changed the code to this:
CON 'DEVICE P8X32A, XTAL1, PLL16X
_ClkMode = XTAL1 + PLL16X
_XInFreq = 5000000 'XIN 5_000_000
PUB __Program 'PROGRAM Start LMM
__PC := @Start
CogInit(0, @_LMM_LOOP, 0)
DAT
org 0
Start mov __temp1,#1 ' TOGGLE 15
shl __temp1,#15
or dira,__temp1
xor outa,__temp1
mov __temp2,#500 ' PAUSE 500
mov __temp1,_1mSec
add __temp1,cnt
__L0001
waitcnt __temp1,_1mSec
djnz __temp2,#_LMM_JUMP
long @@@__L0001
jmp #_LMM_JUMP ' GOTO Start
long @@@Start
DAT
ORG 0
_LMM_JUMP rdlong __PC,__PC
_LMM_LOOP rdlong __INSTR1,__PC
add __PC,#4
__INSTR1 nop ' Placeholder for LMM instruction
jmp #_LMM_LOOP
__PC LONG 0 ' Program counter
_1mSec LONG 80000
__temp1 RES 1
__temp2 RES 1
FIT $1F0
·But now it doesn't work, and I don't understand why ? Does the COGINIT address MUST be at ORG 0 ?
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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you choose not to decide, you still have made a choice. [noparse][[/noparse]RUSH - Freewill]

Comments
ORG 0 only tells the compiler where in the code a COG RAM address = 0 is.
In other words: If you give a different address in the COGINIT/COGNEW than an ORG 0 location, all addresses inside this dat block will be wrong later on in the COG-RAM.
Since the second parameter is where you load the ASM from?
Bill
coginit(0, @_LMM_JUMP, 0 ) .... DAT ORG 0 _LMM_JUMP mov _LMM_JUMP,__readlong _LMM_LOOP rdlong __INSTR1,__PC add __PC,#4 __INSTR1 nop ' Placeholder for LMM instruction jmp #_LMM_LOOP __PC LONG 0 ' Program counter _1mSec LONG 80000 __temp1 RES 1 __temp2 RES 1 __readlong rdlong __PC,__PCYes, a cog can only be started at address 0. The address you specify is where in hub the cog data starts from. 496 longs will be loaded from there into the cog and then the cog will start from location 0. You may put a jump there if you wish. The cog code must therefore start at 0 (org 0) otherwise the compiler will use incorrect addresses for the cog when resolving labels. e.g. If you had the start at org $10 then all the jumps would be offset by $10 so the code would crash.
What are you trying to achieve? Perhaps there is another way?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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
Yeah, I'll just put a jump there, I was just not understanding why it didn't work.
I understand now.
Thanks all.
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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you choose not to decide, you still have made a choice. [noparse][[/noparse]RUSH - Freewill]