mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
rand
This commit is contained in:
parent
47b2677430
commit
d8893823b6
@ -5,7 +5,7 @@
|
||||
; Main function
|
||||
;
|
||||
main:
|
||||
call itoa_test
|
||||
call str_test
|
||||
ret
|
||||
|
||||
showoff:
|
||||
|
17
vm/in/INSTRS
17
vm/in/INSTRS
@ -605,6 +605,23 @@ nop
|
||||
#
|
||||
cpuid
|
||||
|
||||
#
|
||||
# Pseudo-random number generation (RAND32/RAND64)
|
||||
#
|
||||
# RAND32 generates a 32-bit pseudo-random number using
|
||||
# a nonlinear additive feedback pseudo-random number generator
|
||||
# of period 16 * (2^31 - 1).
|
||||
#
|
||||
# RAND64 generates two such numbers, and store them in the destination
|
||||
# operand's higher and lower double words respectively
|
||||
#
|
||||
# The running program does not control the seeding and the processor
|
||||
# may generate numbers from the same generator for other purposes
|
||||
# than this instruction
|
||||
#
|
||||
rand32 rm
|
||||
rand64 rm
|
||||
|
||||
#
|
||||
# Get code/data offset (GCO/GCD)
|
||||
#
|
||||
|
@ -2,10 +2,13 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#include <in/instrs.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#define _NEED_ARCH_I
|
||||
#include <in/arch_i.h>
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
IMPL_START_0(nop)
|
||||
{
|
||||
}
|
||||
@ -13,6 +16,37 @@ IMPL_END;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
IMPL_START_0(cpuid)
|
||||
{
|
||||
}
|
||||
IMPL_END;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
IMPL_START_1(rand32)
|
||||
{
|
||||
v1 = (int)random();
|
||||
}
|
||||
IMPL_OUT;
|
||||
|
||||
IMPL_START_1(rand64)
|
||||
{
|
||||
v1 = (random() << 32) | (int)random();
|
||||
}
|
||||
IMPL_OUT;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
IMPL_START_1(time)
|
||||
{
|
||||
struct timeval time;
|
||||
gettimeofday(&time, NULL);
|
||||
v1 = (time.tv_sec * 1000) + (time.tv_usec / 1000);
|
||||
}
|
||||
IMPL_OUT;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
IMPL_START_1(prn)
|
||||
{
|
||||
if (p1->mlen > 1) {
|
||||
@ -39,10 +73,3 @@ IMPL_START_0(cla)
|
||||
IMPL_END;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
IMPL_START_0(cpuid)
|
||||
{
|
||||
}
|
||||
IMPL_END;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
Loading…
Reference in New Issue
Block a user