/* Implementation of a 32-bit KISS generator which uses no multiply instructions */
// Initial seed
static unsigned long x = 123456789,
y = 234567891,
z = 345678912,
w = 456789123,
c = 0;
unsigned long JKISS32 ()
{
long t;
y ^= y << 5;
y ^= y >> 7;
y ^= y << 22;
t = z + w + c;
z = w;
c = t < 0;
w = t & 2147483647;
x += 1411392427;
return x + y + w;
} // end of JKISS32
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("ESP32: mul.aa.ll test suite");
int acclo, acchi;
for (int i = 0; i < 1000; i++) {
volatile int a = JKISS32();
volatile int b = JKISS32();
asm("mula.aa.ll %0, %1": : "a"(a), "a"(b) : "memory");
asm("rsr.ACCLO %0":"=r"(acclo));
asm("rsr.ACCHI %0":"=r"(acchi));
Serial.print(i);
Serial.print(" ");
Serial.print(acchi, HEX);
Serial.print(" ");
Serial.print(acclo, HEX);
Serial.print(" (a=");
Serial.print(a, HEX);
Serial.print(", b=");
Serial.print(b, HEX);
Serial.println(")");
}
}
void loop() {
delay(10); // this speeds up the simulation
}