XORO32 scrambler output
evanh
Posts: 15,915
in Propeller 2
Chip,
A couple of times now I've wanted to feed another operation directly with a random number. But in both cases it has been a D operand so XORO32 couldn't do it without an intermediate MOV.
A variation of XORO32 that feeds the D port instead of the S port would be nice to have.
A couple of times now I've wanted to feed another operation directly with a random number. But in both cases it has been a D operand so XORO32 couldn't do it without an intermediate MOV.
A variation of XORO32 that feeds the D port instead of the S port would be nice to have.
Comments
Okay. Let me look into it....
It could be done. Could you give me an example of how you would use it?
That's a really neat idea.
As far as having XORO32 report to D, can you give me a more compelling case? It takes more logic, so it needs to be worth it. XORO32 is an oddball instruction in how it works and it's really nice that it reports to one of D or S. I think S is way more useful if you could pick only D or S, and the S circuit exploits the same path that SCA/SCAS use. An alternate D path would take a whole new set of circuitry.
But, then you couldn't do a multiply-accumulate:
SCA X,Y
ADD A,B
The multiply result would get added to B and then written to A.
The way it works now, B is ignored and the multiply result gets added into A.
Am I missing something?
where ANYDS is any D,S instruction (not just a MOV) with S replaced by XORO32 PRN output.
It might be possible to skip PRNs as follows:
One of the C or Z opcode bits in XORO32 could be used to specify which of S or D is replaced by the PRN in the next instruction, but is it really worth it?
Wouldn't it stay as ADD A,B?
Replacing the S field has at least two drawbacks:
1. D must be set to something beforehand for many D,S instructions, probably most, requiring an extra instruction.
2. An immediate or register constant cannot be used, again adding an extra instruction for these cases.
It's not clear cut that replacing S is better than D. In fact, replacing D might be the best option overall, assuming that not reading D but writing D is no more complicated than not reading S.
GET/SET/ROLxxxx wouldn't work as they do now, however.
As for why I said "ADD A,A", that is because SCA is intended for multiply-accumulate function, and the ADD is the accumulate part. To do that the register to be accumulated to has to be both the input and output. D would normally provide exactly that. But if SCA overrides D input, leaving D output intact, then S input can be pointed to the same register to achieve an accumulator.
ALTxx + GET/SET/ROLxxxx are their own case. Same for all ALTx instructions.
SCA, since it'll create the three operand arrangement, might even gain a new ability by changing to overriding the next instruction's D input.
EDIT: Correction, overriding the D input destroys the fastest case of self-recursion only when it's a single operand instruction like XORO32.
EDIT2: Hmm, was just trying to picture recursing ADD with an override D but that doesn't have any advantage over a regular ADD, it's too simple an instruction. XORO32 is unique in this way I think.
My change of mind has probably caused some of the confusion and apologies if so.
Skipping PRNs by following one XORO32 with another was not intended as a serious practical suggestion.
I now think that P2 rev B would be improved if the SCA/SCAS/XORO32 instructions were changed so that the output is used as the next instruction's D value.
SCA/SCAS would work just as well as now (better actually) and XORO32 would benefit even more. Code would be smaller and faster for most cases. No need for both S and D options, just the latter.
If it's too late or D is too difficult, we could live with S.
At some point the P2 needs to be labelled as "done"!!
I wouldn't have raised the topic if I thought it would have a significant impact on libraries. Or any impact for that matter. I'd be surprised if anyone has built a library around XORO32 or SCA yet.
Yes and the D way would give you the extra functionality of ADD A,B. SCA/SCAS could have identical code for P2 revs A and B, but that would not apply to XORO32, e.g. writing the PRN to cog RAM:
However, the D way would allow writing the PRN to LUT/HUB RAM or to DACs or bit testing with the minimum possible coding and often XORO32 would be only a net two cycle instruction.
I'm a bit sceptical that a future P3 would cater for both S and D, so the decision made now is likely to be permanent.
But would MOV x,x actually work as intended after XORO32 if the PRN is in the D field?
ADD dest, #0 would do the equivalent job. Of course this scrappy looking code line makes Electrodudes point more urgent.
If it's OK for it to compile differently for different chips, the alias could translate to `MOV x, #0` on the current chip and `ADD x, #0` if it's changed.