This is a 16-bit PRNG function, transcribed from assembly to C for easier reading:
#define LOW(exp) ((exp) & 0x00FF)
#define HIGH(exp) (((exp) & 0xFF00) >> 8)
uint16_t prng(uint16_t v) {
uint16_t low = LOW(v);
uint16_t high = HIGH(v);
uint16_t mul_low = low * 5;
uint16_t mul_high = high * 5;
// need to check for overflow, since final addition is adc as well
uint16_t v1 = LOW(mul_high) + HIGH(mul_low) + 1;
uint8_t carry = HIGH(v1) ? 1 : 0;
uint16_t v2 = (LOW(v1) << 8) + LOW(mul_low);
return (v2 + 0x11 + carry);
}
Original transcription by @sagara, according to @EternisedDragon; minor edits by me. Assembly and some explanations available at https://stackoverflow.com/questions/36745601/how-is-the-carry-flag-being-set-in-this-assembly-code.
I've been trying to identify this PRNG, wanting to find out if it falls under a common classification. I've been going through Wikipedia's list of random number generators, like the Linear feedback shift register algorithms, but all of these seem way more complex than the simple function above.
Does this function look familiar to anyone?
I'd like to research the properties of this PRNG but first wanted to see if there's any existing literature.