To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 321
320  |  322
Subject: 
Re: random numbers
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Fri, 16 Jul 1999 04:56:39 GMT
Viewed: 
1341 times
  
Luis Villa  <liv@duke.edu> wrote:
I'm most of the way to getting it working myself, but I was curious to
see if anyone has implemented a random number generator in their bot.
Anyone? Anyone?

The firmware supports random numbers using some method that whose name I
can't remember at the moment.  Something about feedback.  Anyways, the
algorithm there boils down to:

int seed;

int
rand (void)
{
    char bit;
    bit = (seed & (1 << 1)) >> 1;
    bit ^= (seed & (1 << 4)) >> 5;
    bit ^= (seed & (1 << 6)) >> 6;
    bit ^= (seed & (1 << 9)) >> 9;
    seed = (seed << 1) | bit;
    return seed;
}

This can be implemented in asm very succinctly.  Something like:

int seed;

extern int rand (void);

__asm__ ("
    .section .text
    .global _rand
_rand:
    mov.w   @_seed,r0
    bld     #1,r0l
    bxor    #4,r0l
    bxor    #6,r0l
    bxor    #9,r0l
    rotxl.b r0l
    rotxl.b r0h
    mov.w   r0,@_seed
    rts
");

... but really, I haven't tested that, and don't even know if it will
compile.

-Kekoa



Message has 1 Reply:
  application termination
 
Hi, what is the magic in LegOS to quit the application so that it can be restarted again? In some demos it works, but the same mechanism (i.e. 1 stopper process that kills the other on [run] button) quits the program, but the display says some (...) (25 years ago, 16-Jul-99, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  random numbers
 
I'm most of the way to getting it working myself, but I was curious to see if anyone has implemented a random number generator in their bot. Anyone? Anyone? -Luis ###...### Profanity is the one language that all programmers understand. -Anonymous (...) (25 years ago, 13-Jul-99, to lugnet.robotics.rcx.legos)

9 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR