Skip to content
Snippets Groups Projects
Commit b06929c0 authored by Gustav Hansson's avatar Gustav Hansson
Browse files

bare1

parent 1337defd
Branches
No related tags found
No related merge requests found
......@@ -59,10 +59,16 @@ fn main() -> ! {
// (passing 3 breakpoints)
//
// ** your answer here **
// The program hits the first breakpoint again with a callstack
// with a lot of elements in the callstack pointing to 0x08000424
// local x variable contains various values
//
// What is the `ITM` output.
//
// ** your answer here **
// Program
// received signal SIGTRAP, Trace/breakpoint trap.
// bare1::__cortex_m_rt_main () at examples/bare1.rs:22
// 22 cortex_m::asm::bkpt();
//
// Commit your answer (bare1_1)
//
......@@ -74,16 +80,42 @@ fn main() -> ! {
// What is the output of:
// > disassemble
//
// ** your answer here **
// Please check OUTPUT tab (Adapter Output) for output from openocd
// disassemble
// Dump of assembler code for function bare1::__cortex_m_rt_main:
// 0x0800040a <+0>: sub sp, #8
// 0x0800040c <+2>: mvn.w r0, #1
// 0x08000410 <+6>: str r0, [sp, #4]
// 0x08000412 <+8>: bkpt 0x0000
// 0x08000414 <+10>: mov.w r0, #4294967295 ; 0xffffffff
// 0x08000418 <+14>: add r4, sp, #4
// 0x0800041a <+16>: str r0, [sp, #4]
// 0x0800041c <+18>: bkpt 0x0000
// 0x0800041e <+20>: mov r0, r4
// 0x08000420 <+22>: bl 0x8000400 <core::ptr::read_volatile>
// => 0x08000424 <+26>: bkpt 0x0000
// 0x08000426 <+28>: ldr r0, [sp, #4]
// 0x08000428 <+30>: adds r0, #1
// 0x0800042a <+32>: bcc.n 0x800041a <bare1::__cortex_m_rt_main+16>
// 0x0800042c <+34>: movw r0, #5984 ; 0x1760
// 0x08000430 <+38>: movt r0, #2048 ; 0x800
// 0x08000434 <+42>: movw r2, #5956 ; 0x1744
// 0x08000438 <+46>: movt r2, #2048 ; 0x800
// 0x0800043c <+50>: movs r1, #28
// 0x0800043e <+52>: bl 0x800053a <core::panicking::panic>
// 0x08000442 <+56>: udf #254 ; 0xfe
// End of assembler dump.
//
// How many instructions are in between the two `bkpt` instructions in the loop.
// Notice, the generated code may not be exactly what you expect :)
//
// ** your answer here **
// THere are 6 instrucations inbetween
//
// Which instruction stores the local variable on the stack.
//
// ** your answer here **
// 0x0800041a <+16>: str r0, [sp, #4]
//
// Commit your answers (bare1_2)
//
......@@ -99,15 +131,25 @@ fn main() -> ! {
// What is the output of:
// > disassemble
//
// ** your answer here **
// Dump of assembler code for function bare1::__cortex_m_rt_main:
// 0x08000406 <+0>: sub sp, #4
// 0x08000408 <+2>: mvn.w r0, #1
// 0x0800040c <+6>: str r0, [sp, #0]
// 0x0800040e <+8>: adds r0, #1
// 0x08000410 <+10>: bkpt 0x0000
// 0x08000412 <+12>: str r0, [sp, #0]
// => 0x08000414 <+14>: bkpt 0x0000
// 0x08000416 <+16>: ldr r0, [sp, #0]
// 0x08000418 <+18>: b.n 0x800040e <bare1::__cortex_m_rt_main+8>
// End of assembler dump.
//
// How many instructions are in between the two `bkpt` instructions.
//
// ** your answer here **
// 1
//
// Where is the local variable stored?
//
// ** your answer here **
// 0x08000412 <+12>: str r0, [sp, #0]
//
// Is there now any reference to the panic handler?
// If not, why is that the case?
......@@ -172,9 +214,21 @@ fn main() -> ! {
//
// What is now the disassembly of the loop (in debug/dev mode):
//
// ** your answer here **
//
// commit your answers (bare1_5)
// Dump of assembler code for function bare1::__cortex_m_rt_main:
// 0x0800040a <+0>: sub sp, #8
// 0x0800040c <+2>: mvn.w r0, #1
// 0x08000410 <+6>: str r0, [sp, #4]
// 0x08000412 <+8>: add r4, sp, #4
// 0x08000414 <+10>: bkpt 0x0000
// 0x08000416 <+12>: ldr r0, [sp, #4]
// 0x08000418 <+14>: adds r0, #1
// 0x0800041a <+16>: str r0, [sp, #4]
// => 0x0800041c <+18>: bkpt 0x0000
// 0x0800041e <+20>: mov r0, r4
// 0x08000420 <+22>: bl 0x8000400 <core::ptr::read_volatile>
// 0x08000424 <+26>: b.n 0x8000414 <bare1::__cortex_m_rt_main+10>
// End of assembler dump.
// commit your answers (bare1_4)
//
// Now restore the `.cargo/config` to its original state.
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment