add mul, disable slow mode

floats
Ondřej Hruška 4 years ago
parent 88a4d77b8f
commit f7e0998696
Signed by untrusted user: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 21
      crsn/src/main.rs
  2. 13
      runtime/src/exec/mod.rs
  3. 3
      runtime/src/run_thread.rs

@ -21,7 +21,7 @@ fn main() {
) )
) )
";*/ ";*/
/*
let program = " let program = "
( (
(main (main
@ -38,6 +38,25 @@ fn main() {
(ret r0) (ret r0)
) )
) )
";*/
let program = "
(
(main
(call fibo 5)
(ld r0 res0)
)
(fibo
(cmp arg0 2
(eq? (ret 2)))
(ld r0 arg0)
(dec r0)
(call fibo r0)
(ld r0 arg0)
(mul r0 res0)
(ret r0)
)
)
"; ";
let parsed = asm::assemble(program).unwrap(); let parsed = asm::assemble(program).unwrap();

@ -166,8 +166,17 @@ impl RunThread {
// TODO carry? // TODO carry?
frame.write(*dst, val)?; frame.write(*dst, val)?;
} }
Op::Mul(_, _) => { Op::Mul(dst, src) => {
unimplemented!() frame.status.clear();
let mut a = frame.read(dst.as_rd())?;
let mut b = frame.read(*src)?;
let val = a.wrapping_mul(b);
frame.status.zero = (val == 0);
frame.status.positive = is_positive(val);
frame.status.negative = is_negative(val);
//frame.status.overflow = b > a; // TODO detect overflow
frame.write(*dst, val)?;
} }
Op::Div(_, _) => { Op::Div(_, _) => {
unimplemented!() unimplemented!()

@ -10,7 +10,8 @@ use crate::frame::StackFrame;
use crate::program::Program; use crate::program::Program;
use crate::exec::EvalRes; use crate::exec::EvalRes;
const CYCLE_TIME : Duration = Duration::from_millis(100); const CYCLE_TIME : Duration = Duration::from_millis(0);
//const CYCLE_TIME : Duration = Duration::from_millis(100);
#[derive(Clone, Copy, Eq, PartialEq, Debug, Ord, PartialOrd)] #[derive(Clone, Copy, Eq, PartialEq, Debug, Ord, PartialOrd)]
pub struct ThreadToken(pub u32); pub struct ThreadToken(pub u32);

Loading…
Cancel
Save