From b0f554ff207cefd5dd73b243b3fb9699fcce72b9 Mon Sep 17 00:00:00 2001
From: Grumme2 <agh@live.se>
Date: Wed, 15 Apr 2020 15:15:49 +0200
Subject: [PATCH] bare1_4

---
 examples/bare1.rs | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/examples/bare1.rs b/examples/bare1.rs
index 4c548ce..18c75d5 100644
--- a/examples/bare1.rs
+++ b/examples/bare1.rs
@@ -24,9 +24,9 @@ fn main() -> ! {
         cortex_m::asm::bkpt();
 
         // prevent optimization by read-volatile (unsafe)
-        unsafe {
-            core::ptr::read_volatile(&x);
-        }
+        // unsafe {
+            // core::ptr::read_volatile(&x);
+        // }
     }
 }
 
@@ -205,15 +205,28 @@ fn main() -> ! {
 //    > disassemble
 //
 //    ** your answer here **
+// 
+//      Dump of assembler code for function bare1::__cortex_m_rt_main:
+//     0x0800040a <+0>:     bkpt    0x0000
+//      => 0x0800040c <+2>:     bkpt    0x0000
+//     0x0800040e <+4>:     b.n     0x800040a <bare1::__cortex_m_rt_main>
+//      End of assembler dump
 //
 //    How many instructions are in between the two `bkpt` instructions.
 //
 //    ** your answer here **
-//
+//      0
+// 
 //    Where is the local variable stored?
 //    What happened, and why is Rust + LLVM allowed to do that?
 //
 //    ** your answer here **
+// 
+//     0x0800040e <+4>:     b.n     0x800040a <bare1::__cortex_m_rt_main>
+//      
+//      In release mode the program is the most optimized 
+//      which means that the compiler can remove instructions that arent necessary
+//     
 //
 //    commit your answers (bare1_4)
 //
-- 
GitLab