[an error occurred while processing this directive]
|
/*
These C language subroutines implement random number
generation for the runtime library.
The Run Time Library for the C Language.
Gordon A. Sterling (617) 461 - 3076
DSP Development Tools Engineering
Created on 2/14/91
Updated on 5/94 by AS
#include #include "lib_glob.h" #define a_value 1664525 .SEGMENT/CODE Code_Space_Name; .GLOBAL _rand, _srand; _srand: ram_ireg=___lib_rand_seed; _rand: ram_ireg=___lib_rand_seed; restore_state: RETURN (DB); .SEGMENT/RAM_SPACE Ram_Space_Name; .GLOBAL ___lib_rand_seed; .ENDSEG;
E-mail:
info@telesys.ru
void srand(int seed);
int rand(void);
*/
#include "sdl_glob.h"
#define c_value 32767
.FILE RTL_FILENAME;
JUMP (PC, restore_state) (DB);
FETCH_RETURN
rammem(ram_ireg,ram_0)=R4;
R2=a_value; /*Base*/
R0=rammem(ram_ireg,ram_0); /*Read seed value*/
R0=R0*R2 (UUI); /*Compute mod(a*x)*/
R2=c_value;
R0=R0+R2, FETCH_RETURN /*Compute mod(a*x + c)*/
rammem(ram_ireg,ram_0)=R0; /*Write out new seed*/
R0=BCLR R0 BY 31; /*Always return positive*/
RESTORE_STACK
RESTORE_FRAME
.ENDSEG;
.VAR ___lib_rand_seed = 1;
Ответы