diff --git a/examples/bare2.rs b/examples/bare2.rs index 291bb67bff29cad19c6fd44a7d20113382cf8c7b..ec613c010fb04a7f2684c65d5c37204a3a6ddf39 100644 --- a/examples/bare2.rs +++ b/examples/bare2.rs @@ -98,6 +98,72 @@ fn main() -> ! { // Inspect the generated binaries, and try stepping through the code // for both debug and release binaries. How do they differ? // -// ** your answer here ** +// ** Biggest difference in wait loop + +// -- Debug -- + +// disassemble +// {"token":118,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}} +// Dump of assembler code for function bare2::wait::hfe7ce9f60a404aeb: +// 0x08000746 <+0>: push {r7, lr} +// 0x08000748 <+2>: sub sp, #56 ; 0x38 +// 0x0800074a <+4>: mov r1, r0 +// 0x0800074c <+6>: str r0, [sp, #16] +// 0x0800074e <+8>: ldr r0, [sp, #16] +// 0x08000750 <+10>: movs r2, #0 +// 0x08000752 <+12>: str r2, [sp, #24] +// 0x08000754 <+14>: str r0, [sp, #28] +// 0x08000756 <+16>: ldr r0, [sp, #24] +// 0x08000758 <+18>: ldr r2, [sp, #28] +// 0x0800075a <+20>: str r1, [sp, #12] +// 0x0800075c <+22>: mov r1, r2 +// 0x0800075e <+24>: bl 0x8000a9a <_$LT$I$u20$as$u20$core..iter..traits..IntoIterator$GT$::into_iter::h5a903f40a945694e> +// 0x08000762 <+28>: str r0, [sp, #8] +// 0x08000764 <+30>: str r1, [sp, #4] +// 0x08000766 <+32>: b.n 0x8000768 <bare2::wait::hfe7ce9f60a404aeb+34> +// 0x08000768 <+34>: ldr r0, [sp, #8] +// 0x0800076a <+36>: str r0, [sp, #32] +// 0x0800076c <+38>: ldr r1, [sp, #4] +// 0x0800076e <+40>: str r1, [sp, #36] ; 0x24 +// 0x08000770 <+42>: b.n 0x8000772 <bare2::wait::hfe7ce9f60a404aeb+44> +// 0x08000772 <+44>: add r0, sp, #32 +// 0x08000774 <+46>: bl 0x8000a00 <core::iter::range::_$LT$impl$u20$core..iter..iterator..Iterator$u20$for$u20$core..ops..range..Range$LT$A$GT$$GT$::next::h8a120a1de333cffb> +// => 0x08000778 <+50>: str r1, [sp, #48] ; 0x30 +// 0x0800077a <+52>: str r0, [sp, #44] ; 0x2c +// 0x0800077c <+54>: b.n 0x800077e <bare2::wait::hfe7ce9f60a404aeb+56> +// 0x0800077e <+56>: ldr r0, [sp, #44] ; 0x2c +// 0x08000780 <+58>: cmp r0, #0 +// 0x08000782 <+60>: str r0, [sp, #0] +// 0x08000784 <+62>: beq.n 0x8000790 <bare2::wait::hfe7ce9f60a404aeb+74> +// 0x08000786 <+64>: b.n 0x8000788 <bare2::wait::hfe7ce9f60a404aeb+66> +// 0x08000788 <+66>: ldr r0, [sp, #0] +// 0x0800078a <+68>: cmp r0, #1 +// 0x0800078c <+70>: beq.n 0x8000796 <bare2::wait::hfe7ce9f60a404aeb+80> +// 0x0800078e <+72>: b.n 0x8000794 <bare2::wait::hfe7ce9f60a404aeb+78> +// 0x08000790 <+74>: add sp, #56 ; 0x38 +// 0x08000792 <+76>: pop {r7, pc} +// 0x08000794 <+78>: udf #254 ; 0xfe +// 0x08000796 <+80>: ldr r0, [sp, #48] ; 0x30 +// 0x08000798 <+82>: str r0, [sp, #52] ; 0x34 +// 0x0800079a <+84>: ldr r0, [sp, #52] ; 0x34 +// 0x0800079c <+86>: str r0, [sp, #40] ; 0x28 +// 0x0800079e <+88>: bl 0x8000af6 <cortex_m::asm::nop::he6ee95faef743e38> +// 0x080007a2 <+92>: b.n 0x80007a4 <bare2::wait::hfe7ce9f60a404aeb+94> +// 0x080007a4 <+94>: b.n 0x8000772 <bare2::wait::hfe7ce9f60a404aeb+44> +// End of assembler dump. +// +// -- Release -- +// disassemble +// {"token":172,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}} +// Dump of assembler code for function bare2::wait::h0be3841658d4de56: +// 0x0800065c <+0>: movw r0, #16960 ; 0x4240 +// 0x08000660 <+4>: movt r0, #15 +// 0x08000664 <+8>: subs r0, #1 +// 0x08000666 <+10>: nop +// 0x08000668 <+12>: bne.n 0x8000664 <bare2::wait::h0be3841658d4de56+8> +// => 0x0800066a <+14>: bx lr +// End of assembler dump. +// +// ** // // commit your answers (bare2_2)