msp430-ish version of rand.c