Skip to content
Snippets Groups Projects
Commit 16f16fd0 authored by Henrik Theolin's avatar Henrik Theolin
Browse files

bare0_3

parent dbe09940
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 = 0xffffffff;
// global mutabale variables (changed using unsafe code)
static mut X: u32 = X_INIT;
......@@ -31,9 +31,9 @@ fn main() -> ! {
let mut x = unsafe { X };
loop {
x += 1; // <- place breakpoint here (3)
x.wrapping_add(1); // <- place breakpoint here (3)
unsafe {
X += 1;
X.wrapping_add(1);
Y = X;
assert!(x == X && X == Y);
}
......@@ -75,10 +75,10 @@ fn main() -> ! {
//
// Change (both) += opertions to use wrapping_add
// load and run the progam, what happens
// ** your answer here **
// ** x value stays at u32 max 4294967295**
//
// Now continue exectution, what happens
// ** your answer here **
// ** X,Y and x = 4294967295 **
//
// Commit your answers (bare0_3)
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment