labast/src/instructions/random.rs
n3taeli 4fb06f8f34
update v1.0.3
* fixed _unix_random bug
* add custom instruction "random"
* update to spec 1.12
* more cli options
2024-02-06 19:59:43 +02:00

7 lines
202 B
Rust

use fastrand;
use crate::RunError;
pub fn random(memory: &mut Vec<u16>) {
let data = &memory.pop().expect(&format!("{}", RunError::MemoryEmpty));
memory.push(fastrand::u16(..) % (*data - 1));
}