new instruction rjmp
This commit is contained in:
@@ -38,4 +38,5 @@ pub mod kjz;
|
||||
pub mod print;
|
||||
pub mod println;
|
||||
pub mod insert;
|
||||
pub mod random;
|
||||
pub mod random;
|
||||
pub mod rjmp;
|
||||
@@ -0,0 +1,8 @@
|
||||
use crate::stack::StackVec;
|
||||
|
||||
pub fn rjmp(memory: &mut StackVec, labels: &mut [Option<i16>; 256], program_counter: &mut u16) {
|
||||
let start = memory.pop() as usize;
|
||||
let end = memory.pop() as usize;
|
||||
|
||||
*program_counter = (labels[fastrand::usize(start..end)].unwrap() - 1) as u16;
|
||||
}
|
||||
Reference in New Issue
Block a user