Skip to content
Snippets Groups Projects
Commit b436392d authored by Anton's avatar Anton
Browse files

bare1_3

parent 7fec82e2
No related branches found
No related tags found
No related merge requests found
...@@ -76,7 +76,7 @@ const APP: () = { ...@@ -76,7 +76,7 @@ const APP: () = {
// //
// Explain in your own words the chain of calls. // Explain in your own words the chain of calls.
// //
// App calls init, init initializes a mutable variable x to int max -1 // App calls init, init initializes a mutable variable x to int max -2
// init loops while adding to x, x goes over max, rust calls panic // init loops while adding to x, x goes over max, rust calls panic
// panic calls panic_format, panic_fmt calls semihosting_panic // panic calls panic_format, panic_fmt calls semihosting_panic
// panic semihosting calls brakpoint. // panic semihosting calls brakpoint.
...@@ -92,11 +92,11 @@ const APP: () = { ...@@ -92,11 +92,11 @@ const APP: () = {
// //
// What is the value of `x`? // What is the value of `x`?
// //
// ** your answer here ** // 4294967294
// //
// Explain in your own words where this value comes from. // Explain in your own words where this value comes from.
// //
// ** your answer here ** // core::u32::MAX = 4294967295 = 2^32-1; we assign x to be MAX-1
// //
// Now continue the program, since you are in a loop // Now continue the program, since you are in a loop
// the program will halt again at line 24. // the program will halt again at line 24.
...@@ -105,7 +105,7 @@ const APP: () = { ...@@ -105,7 +105,7 @@ const APP: () = {
// //
// Explain in your own words why `x` now has this value. // Explain in your own words why `x` now has this value.
// //
// ** your answer here ** // we added 1 to x
// //
// Now continue again. // Now continue again.
// //
...@@ -119,7 +119,9 @@ const APP: () = { ...@@ -119,7 +119,9 @@ const APP: () = {
// //
// Explain in your own words why a panic makes sense at this point. // Explain in your own words why a panic makes sense at this point.
// //
// ** your answer here ** // Since x had the value of MAX which is the maximum value x can't get bigger.
// since the purpose of adding to a variable is to make it bigger,
// and if it can't get any bigger rust has chosen to panic.
// //
// Commit your answer (bare1_3) // Commit your answer (bare1_3)
// //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment