Skip to content
Snippets Groups Projects
Commit 37546139 authored by anttib-5's avatar anttib-5
Browse files

bare0_5

parent cf694534
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ extern crate panic_halt;
use cortex_m_rt::entry;
// a constant (cannot be changed at run-time)
const X_INIT: u32 = 10;
const X_INIT: u32 = u32::max_value();
// global mutabale variables (changed using unsafe code)
static mut X: u32 = X_INIT;
......@@ -31,27 +31,31 @@ fn main() -> ! {
let mut x = unsafe { X };
loop {
x += 1; // <- place breakpoint here (3)
unsafe {
X += 1;
Y = X;
assert!(x == X && X == Y + 1);
}
x = x.wrapping_add(1); // <- place breakpoint here (3)
write_x(1);
write_y(read_x());
}
}
fn readX () {
fn write_x(i: u32){
unsafe{
X = X.wrapping_add(1);
}
fn writeX () {
}
fn readY () {
fn write_y(i: u32){
unsafe{
Y = i;
}
}
fn read_x() -> u32{
unsafe{
X
}
}
// 0. Compile/build the example in debug (dev) mode.
//
// > cargo build --example bare0
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment