From 16f16fd072678f787e789e31af0b591ab94afc55 Mon Sep 17 00:00:00 2001 From: "henthe-5@student.ltu.se" <henthe-5@student.ltu.se> Date: Tue, 19 Feb 2019 12:45:29 +0100 Subject: [PATCH] bare0_3 --- examples/bare0.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/bare0.rs b/examples/bare0.rs index 3be74e1..606ac0f 100644 --- a/examples/bare0.rs +++ b/examples/bare0.rs @@ -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) // -- GitLab