Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2020
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tom Hammarkvist
e7020e_2020
Commits
4bf86dcd
Commit
4bf86dcd
authored
5 years ago
by
Hammarkvast
Browse files
Options
Downloads
Patches
Plain Diff
bare0 almost done
parent
eaf154ae
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/bare0.rs
+9
-10
9 additions, 10 deletions
examples/bare0.rs
with
9 additions
and
10 deletions
examples/bare0.rs
+
9
−
10
View file @
4bf86dcd
...
...
@@ -26,8 +26,8 @@ extern crate panic_semihosting;
use
cortex_m_rt
::
entry
;
// a constant (cannot be changed at run-time)
const
X_INIT
:
u32
=
10
;
//
const X_INIT: u32 = core::u32::MAX;
//
const X_INIT: u32 = 10;
const
X_INIT
:
u32
=
core
::
u32
::
MAX
;
// global mutable variables (changed using unsafe code)
static
mut
X
:
u32
=
X_INIT
;
...
...
@@ -39,11 +39,10 @@ fn main() -> ! {
let
mut
x
=
unsafe
{
X
};
loop
{
x
+
=
1
;
// <- place breakpoint here (3)
x
=
x
.wrapping_add
(
1
)
;
// <- place breakpoint here (3)
unsafe
{
X
+=
1
;
Y
=
X
;
assert!
(
x
==
X
&&
X
==
Y
);
X
=
X
.wrapping_add
(
1
);
Y
=
X
;
}
}
}
...
...
@@ -79,7 +78,7 @@ fn main() -> ! {
// What happens when `x` wraps
// (Hint, look under OUTPUT/Adopter Output to see the `openocd` output.)
//
//
** your answer here **
//
The programs starts to panic.
//
// Commit your answers (bare0_2)
//
...
...
@@ -87,10 +86,10 @@ fn main() -> ! {
//
// Change (both) += operations to use wrapping_add
// load and run the program, what happens
//
** your answer here **
//
The program does not panic this time, and instead x wraps to 0, as it should.
//
// Now continue execution, what happens
//
** your answer here **
//
The program goes to the breakpoint every time we press continue, and 1 is added to x, every time.
//
// Commit your answers (bare0_3)
//
...
...
@@ -99,7 +98,7 @@ fn main() -> ! {
//
// 4. Change the assertion to `assert!(x == X && X == Y + 1)`, what happens?
//
//
** place your answer here **
//
The programs starts to panic.
//
// Commit your answers (bare0_4)
//
...
...
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