Auto link multiple applications in kernel.

This commit is contained in:
Yifan Wu 2020-11-19 04:33:06 +08:00
parent f613fa122c
commit 0d0c7255b6
5 changed files with 64 additions and 9 deletions

27
user/src/bin/power.rs Normal file
View file

@ -0,0 +1,27 @@
#![no_std]
#![no_main]
#[macro_use]
extern crate user_lib;
const SIZE: usize = 10;
const P: u32 = 3;
const STEP: usize = 10000000;
const MOD: u32 = 10007;
#[no_mangle]
fn main() -> i32 {
let mut pow = [0u32; SIZE];
let mut index: usize = 0;
pow[index] = 1;
for i in 1..=STEP {
let last = pow[index];
index = (index + 1) % SIZE;
pow[index] = last * P % MOD;
if i % 10000 == 0 {
println!("{}^{}={}", P, i, pow[index]);
}
}
println!("Test power OK!");
0
}