Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
a3_decode
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
D7018E-SS-RUST
a3_decode
Commits
2ed631da
Commit
2ed631da
authored
Nov 8, 2017
by
Henrik Tjäder
Browse files
Options
Downloads
Patches
Plain Diff
Added pseudo-code and started to work on the function types
parent
8ed71cd2
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
src/main.rs
+58
-2
58 additions, 2 deletions
src/main.rs
with
58 additions
and
2 deletions
src/main.rs
+
58
−
2
View file @
2ed631da
...
@@ -140,14 +140,70 @@ static CODED: [u32; 132] =
...
@@ -140,14 +140,70 @@ static CODED: [u32; 132] =
0
];
0
];
fn
codgen
()
{
fn
codgen
()
{
}
}
fn
decode
(
coded
:
&
[
u32
],
plain
:
&
mut
[
u8
],
seed
:
&
mut
u32
)
->
u32
{
let
x
=
3
;
x
}
fn
main
()
{
println!
(
"Time to decode!"
);
let
mut
seed
=
0x0e0657c1
;
decode
(
&
CODED
,
&
mut
PLAIN
,
&
mut
seed
);
fn
main
()
{
println!
(
"Hello, world!"
);
}
}
/*
# Group 1's Codeword Generator Subroutine (pseudocode)
# (remember: "seed" is a global variable, UNSIGNED INTEGER;
# you may implement local variables in registers or on the stack;
# result returned in v0; preserve all except t regs)
#
# FUNCTION codgen(): UNSIGNED INTEGER;
# LOCAL SIGNED INTEGER n;
# LOCAL UNSIGNED INTEGER x, y;
# BEGIN
# n := [count the number of 0's in word "seed"];
# x := [rotate "seed" left by 30 bits];
# y := [shift "seed" right-ARITHMETIC by 6 bits];
# seed := x XOR y XOR n;
# RETURN( seed XOR 0x464b713e );
# END;
#
# hint: if "seed" is initialized to 0x3e944b9f,
# the first five calls will generate these values:
# 0x891432f9, 0x4aa1dccc, 0xc54270fa, 0x9885155f, 0xce83d1b8, ...
# your code is to be written farther down (see comment below).
# Group 1's Recursive Decoding Subroutine (pseudocode)
# (for "decode", all four local variables must be implemented ON THE
# STACK, and NOT in registers; implement the code literally,.
# no optimizations. We're trying to teach you something.
# remember: result returned in v0; preserve all except t regs)
#
# FUNCTION decode( wordarr, bytearr ): UNSIGNED INTEGER;
# (wordarr, bytearr passed by reference)
# LOCAL UNSIGNED INTEGER m, r, x, y;
# BEGIN
# x := ONE'S-COMPLEMENT of codgen();
# IF ([contents of word at "wordarr"] = 0) THEN
# [byte pointed to by "bytearr"] := 0;
# r := x;
# ELSE
# y := decode( wordarr+, bytearr+ ); # "k+" means "successor in k"
# m := ( x - y ) - [contents of word at "wordarr"];
# [byte pointed to by "bytearr"] := [the eight bits at "m"<20:13>];
# r := TWO'S-COMPLEMENT OF codgen();
# r := x + y + m + r + 5;
# ENDIF;
# RETURN( r );
# END;
*/
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