very confused
Graham Stabler
Posts: 2,510
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 done = 0 VAR long parameter PUB go | x cognew(@entry, @parameter) 'Starts cog, passes pointer to globals DAT ORG entry :loop ' mov state,done ' When commented out jmp does not occur even though state is initialized as zero cmp state,done wz if_z jmp #:b9_5 ' st = done? jmp 9.5 ''' other code here jmp #:loop ' variables state long 0 acc long 900 vel long 0 'some more variables veltemp res 1 dirmask res 1
Even though state is initialized as zero setting it to zero manually makes a difference to the compare with done. I'm confused, any ideas?
Graham
Comments
eg
mov state,#done
cmp state,#done wz
Since done is a CON not a dat variable?
Graham
Baggers.
I converted part of my motion control to 64-bit last night to increase movement range (now 10.7km instead of 30mm) and had to change all of the compares, sums and subractions and it just wasn't working. I checked abd checked and checked and accidentally found this decsions making part was not working by a simple test.
Thanks again
Graham
Though a typo is a type - never mind.
But:
# means: "This is an instruction with immediate addressing of the SOURCE operand",
i.e. this is a different instruction than without the #
The Assembler does not distinguish between a numeric notation or "names" used - never!
It's all CONSTANTS for him, very different from SPIN
Sometimes I think it is even misleading to put this # in front of the value,
though it looks now very much as in some other Assembly languages as Motorola..
Found the other problem which was a subs that should have been a subsx, I had tried so many things last night I must have forgotton to change it back.
Graham
As I see it, only these opcodes use immediate addressing:
JMP JMPRET CALL DJNZ TJNZ TJZ
WRLONG WRBYTE WRWORD RDBYTE RDLONG RDWORD
The manual marks this·mode·by the phrase '... or a 9-bit literal whose value is the address ...'
All of the other opcodes·use # to set an immediate literal that gets encoded into the opcode.· Thus:
mov state,done·· ' puts the value contained in location 0 into location state.
mov state,#done ' puts the value 0 into location state. This second version·uses literal value that is encoded into the opcode and has nothing to
······················· ' with·addressing.
·
Whether the operand thus obtained gets copied somewhere else or is used as a jump location is irrelevant. Until the instruction actually executes, it's still just an operand that gets fetched from somewhere.
That said, it's more common among assemblers to omit the "#" from jumps and to call that "direct addressing". When the jump target address is contained at another location, many assemblers that support such a jump prepend a "@" to the label and call it "indirect addressing".
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 10/23/2007 6:35:46 AM GMT
The propeller is register oriented. NORMALY all data elements are stored to registers and fetched from registers.
As a shortcut and to save registers, it is possible to enter data elements immediately, if they are constant and their value is less then 512.
Common microcontroller architecture are not so clean, and now, working with the propeller, simplicity creates confusion.
We just have to throw away the balast called experience and start from the beginning.
By the way: If the cog could use a register as a source of an address, that is, the register in the 511 address range keeps a pointer to a register outside this range, we will have no problem with local data storage, then the memory could have 32 bit addresses. It only takes some cycles to fetch the memory address.
It seems now the time has come for deSilva to just copy things from his previous postngs..
And yes I did intend to revisit it after some sleep.
Graham
p.s. But I do understand where Fred is coming from, the IDE replaces the instance of done with 0 except I did not want the command to use the address zero rather the actual number zero, so it should have the same affect as #0 hence I write #done. However that 0 is stored in the command and as Phil and deSilva say the # ensures that it is used as a value rather than an address to a value.
Post Edited (Graham Stabler) : 10/23/2007 11:51:49 AM GMT
Phil, my wife says that if you're a systems programmer I will always lose an argument. Is she right?
Assuming there are separate internal registers for the instruction, the source operand, and the destination address, I'm guessing that at some point during immediate instruction decoding, the source field is "fetched" from the instruction register and written to the source register. But who knows? It may actually be fetched from memory again, assuming the instruction pointer hasn't already advanced to the next instruction.
I guess the term "immediate addressing" didn't cause a disconnect with me, since I've seen it so many times before. 'Seems like every assembly manual has a chapter that begins, "The XYZ processor has N addressing modes: immediate, direct, indirect, indexed, ..." When I was very young, I accepted the terminology with appropriate wonder and gullibility and haven't questioned it since.
Oh, and tell your wife I've never been a systems programmer.
-Phil