Tasks Overall Requirements Write two programs encode.toy and decode.toy. Each TOY instruction must have corresponding pseudocode. (This is auto-generated by Visual X-Toy – see below.) It's also good practice to add line breaks between logically related "sections" of TOY code and write a comment above each "section" explaining what that code does. encode.toy

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter11: Operating Systems
Section: Chapter Questions
Problem 29VE
icon
Related questions
Question

Implementation Tasks

Overall Requirements

  • Write two programs encode.toy and decode.toy.
  • Each TOY instruction must have corresponding pseudocode. (This is auto-generated by Visual X-Toy – see below.) It's also good practice to add line breaks between logically related "sections" of TOY code and write a comment above each "section" explaining what that code does.

encode.toy

Write a TOY program encode.toy to encode a binary message using the scheme described above. Repeatedly read four (4) bits m1m2m3m4 from TOY standard input and write the seven (7) bits m1m2m3m4p1p2p3 to TOY standard output. Stop upon reading FFFF from standard input.

  • p1 = m1 ^ m2 ^ m4
  • p2 = m1 ^ m3 ^ m4
  • p3 = m2 ^ m3 ^ m4

Recall that ^ is the exclusive or operator in Java and TOY. This captures the parity concept described above.

decode.toy

Write a TOY program decode.toy to decode and correct a Hamming encoded message. Repeatedly read seven (7) bits m1m2m3m4p1p2p3 from TOY standard input and write the four (4) correct bits m1m2m3m4 to TOY standard output. Stop upon reading FFFF from standard input. Recall, to determine which one, if any, of the message bits is corrupted, perform the parity checks:

  • p1 = m1 ^ m2 ^ m4
  • p2 = m1 ^ m3 ^ m4
  • p3 = m2 ^ m3 ^ m4

Compare the parity bits you computed with the parity bits you received. If they don't match, then some bit was flipped. Here's what to do with the results:

  • If exactly zero or one of the parity checks fail, then all four message bits are correct.
  • If checks 1 and 2 fail (but not check 3), then bit m1 is incorrect.
  • If checks 1 and 3 fail (but not check 2), then bit m2 is incorrect.
  • If checks 2 and 3 fail (but not check 1), then bit m3 is incorrect.
  • If all three checks fail, then bit m4 is incorrect.

Flip the corrupted message bit (if necessary) and write (only) m1m2m3m4 to standard output.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Assembly Language
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning