Dumb question about "bit 0" in Propeller Manual.
ke4pjw
Posts: 1,155
in Propeller 1
The SHR page (p 348 v1.1 manual) specifies that if the WC effect is specified, the C flag is set to the Value's original bit 0.
Is that the MSB or LSB of the d-field (value)??
Kinda confused on the terminology.
Thanks in advance.
--Terry
Is that the MSB or LSB of the d-field (value)??
Kinda confused on the terminology.
Thanks in advance.
--Terry
Comments
d-field - this is a 9-bit field in the "instruction" specifying the destination of the 32-bit value. The instruction is 32-bits long that has two 9-bit fields that specifies a source and destination.
So it is the destination value that is pointed to by the d-field that is operated on, not the d-field itself.
SHR - shifts the 32-bits of a long right by one or more bits where bit 0 is the least significant bit (least value). Now because SHR can shift multiple bits right and not just one bit then it is necessary to state what sets the carry bit or C flag. For instance, if I performed 4 single SHR operations one bit at a time then finally the carry bit would be equal to the "last" bit 0 that was shifted, that is b3. But that is not what happens when you tell SHR to do so by 4 bits in one operation, it is simply whatever bit 0 of the destination value was before the operation
Assume that destination labeled "dest" is set to this value initially, so we will use a mov op to show this:
mov dest,%0100_1111_1010_0101
shr dest,#1
So C = 1 because the rightmost bit of dest which is bit 0 is 1.
Even if we shifted by #4 instead of #1 the C value would still be equal to the original bit 0, that is 1.
mov dest,%0100_1111_1010_0101
shr dest,#4 ' C = 1 (original bit 0)
But if we had done this instead:
mov dest,%0100_1111_1010_0101
shr dest,#1 ' C = 1 (original bit 0)
shr dest,#1 ' C = 0 (original bit 1)
shr dest,#1 ' C = 1 (original bit 2)
shr dest,#1 ' C = 0 (original bit 3)
You can see that C = the original bit 3 instead which is what some programmers might think C is set to if #4 had been specified in one operation, but that is not the case.
Hope I haven't confused you.
Absolutely, I think I should have formatted any PASM code properly although it was 4 in the morning here
I converted the following code to SPIN, so I could generate a CRC8 using the Maxim algorithm.
The following lines are what I was curious about. Seems that could have been done with an AND, as t1 was no longer used. That's what I did in spin.
As an aside, Jon, I am using this and a slightly modified version (1 stop bit instead of 2) of your IR routines on the Parallax convention badge to control some Disney "Magic Ears" Super fun stuff!