ALTB D,S seems to ignor D += sign Extended Code Problem
Bob Drury
Posts: 236
in Propeller 2
I am trying to understand ALTB D,S Instruction using TestB D,S . The code attached I have tried to document what I am doing. It appears to me the there is something I am doing wrong with the Offset
from D += sign extended. Help would be apreciated.
Regards and Thanks
Bob (WRD)
Comments
Ah, it's not really an offset in the normal sense. That += is a second operation that occurs after the main "alt"ering op. It updates the index for quick access to next item so that it's ready for the next iteration when looping.
That's interesting. That debug code fails to produce output from cog1 in FlexSpin.
It's like when you do say
The
index
starts at zero and the first item fetched is item at array position zero. The++
incrementing is a post-increment, so item at array position one is fetched on the second pass.Here's a FlexC version tested and working:
Terminal output is:
EDIT: Added "before" reporting.
Oh, actually, it is acting like a pre-increment rather than the expected post-increment ... the first bit should be bit0 of "data" but is definitely bit1 ... ya, and when removing incrementing parameter from "base" it correctly indexes bit0 of "data".
I think that's another flaw in the prop2.
EDIT: Just tested with ALTGN and it's definitely a post-increment case.
Terminal output is correctly showing the data at index 1 while index is post-incremented to 2:
The instruction only takes 2 clock cycles so you would think that "Alter D field of next instruction to (D[13:5] + S) & $1FF. D += sign-extended S[17:9]. (D = D +S[17.9] )" must happen during the same instruction time. Maybe the (D[13:5] + S)&$1FF occurs first then (D = D +S[17.9] ) is done by having a circuit that clocks within the instruction finnaly generating the D Field result. But there really doesn't seem to be any way to control the instruction sequencing.
Please refer to code originally sent with opening discussion at top of chat:.
Before Instruction ALTB D_ALTB,S_ALTB
'D_ALTB' = %100000 D[13:5] = 1 and 'S_ALTB' S= %10_00110001 with S[17:9] = 1 and S[8:0] = %110001 the BaseAdress =valBit0Address = %110001
this should be Offset = 1 Index =1 BaseAdress = valBit0 = %110001 which I believe should be requesting to test 'valBit2' = %110011
After Insturction ALTB D_ALTB,S_ALTB
'D_ALTB' = %100001 'S_ALTB' = %10_00110001 by testing changing bits in 'valBit1' Bit B9 the correct flag C result is found 1 for bit being 1 and 0 for bit being 0 this is using 'valBit1 = %110010
but the register should be 'valBit2' index + offset + BaseAdress . To me it looks like 'S_ALTB = %10_00110001 is not being added. It must be either this command works differently
then understood ,or not setting up parameters properly, or bug in operand. Help!!
Regards
Bob (WRD)
It was way overly complicated to read at first sitting. Another night of sleep helped ... You've got a significant bug. The "bitindex" register, as named in Chip's example code, has to be the same one in both the ALTB and TESTB instructions. The intended prefixing fails if they aren't arranged in this manner. And the prefixed D field gets overridden therefore no value in having any specific register named there either.
In your case you'd want:
Thanks EVANH will try out
Regards
Bob
Yes this works. The S[17:9] does not contain word offset like the other instructions it contains a bit offset (I thought it was a long offset). Attached program that seems to work.
Need to actually set all of the following for ALTB.thanks for help
OffsetBitIndex long 1 'To be Loaded to OffsetS[17:9]
IndexWord long 2 'To be Loaded to IndexD[13:5]
IndexBit long 9 'To be Loaded to BitIndexD[4:0]
BaseAddress long 0 'BaseAdress of Table S[8:0]
Regards
Bob (WRD)
The whole D operand, D[13:0], is one bit-index that spans the whole of cogRAM.