Chapter3: power2/3/5 & sleep test worked on k210/qemu based on timer.

This commit is contained in:
Yifan Wu 2020-11-29 10:31:15 +08:00
parent adbe671fe1
commit 1cef77eac7
17 changed files with 183 additions and 82 deletions

28
user/src/bin/02power_7.rs Normal file
View file

@ -0,0 +1,28 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
const LEN: usize = 100;
#[no_mangle]
fn main() -> i32 {
let p = 7u64;
let m = 998244353u64;
let iter: usize = 80000;
let mut s = [0u64; LEN];
let mut cur = 0usize;
s[cur] = 1;
for i in 1..=iter {
let next = if cur + 1 == LEN { 0 } else { cur + 1 };
s[next] = s[cur] * p % m;
cur = next;
if i % 10000 == 0 {
println!("power_7 [{}/{}]", i, iter);
}
}
println!("{}^{} = {}", p, iter, s[cur]);
println!("Test power_7 OK!");
0
}