Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2021
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anton Johansson
e7020e_2021
Commits
b436392d
Commit
b436392d
authored
4 years ago
by
Anton
Browse files
Options
Downloads
Patches
Plain Diff
bare1_3
parent
7fec82e2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/rtic_bare1.rs
+7
-5
7 additions, 5 deletions
examples/rtic_bare1.rs
with
7 additions
and
5 deletions
examples/rtic_bare1.rs
+
7
−
5
View file @
b436392d
...
@@ -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)
//
//
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment