Difference between revisions of "CSC231 Homework 6 Fall 2017"
(→Problem #2) |
(→Problem #2) |
||
Line 25: | Line 25: | ||
b c d a f g h e m n i j k l p o r q t s x y z u v w | b c d a f g h e m n i j k l p o r q t s x y z u v w | ||
− | If you wanted to send a secret message containing the word "hello" to a friend, you would need to ''encode'' it first. For this, you would look up each letter of the word in the first line above (normal alphabet), find the letter directly underneath (in the scrambled alphabet), and make up a new word with the letters from the second line. 'h' would become 'e', 'e' would become 'f', 'l' would become ' | + | If you wanted to send a secret message containing the word "hello" to a friend, you would need to ''encode'' it first. For this, you would look up each letter of the word in the first line above (normal alphabet), find the letter directly underneath (in the scrambled alphabet), and make up a new word with the letters from the second line. 'h' would become 'e', 'e' would become 'f', 'l' would become 'j', and 'o' would become 'p'. So 'hello' would be ''encoded' as 'efjjp'. Your friend then had to decode 'efjjp' back into 'hello' by using a similar process. |
+ | |||
+ | To decode the message, your friend could use the same method you used, but with a different second scrambled alphabet: | ||
a b c d e f g h i j k l m n o p q r s t u v w x y z | a b c d e f g h i j k l m n o p q r s t u v w x y z | ||
Line 31: | Line 33: | ||
d a b c h e f g k l m n i j p o r q t s x y z u v w | d a b c h e f g k l m n i j p o r q t s x y z u v w | ||
− | For this assignment, you are given the executable version of an encoder, which uses the | + | To decode 'efjjp', your friend would look up 'e' in the first alphabet above, and find 'h' just below. 'h' would be the first letter of the encoded message. 'f' is above 'e', so 'e' is the second letter. 'j' is above 'l', so the next letters are 'll'. And finally 'p' is above 'o', so the final letter of the encoded message had to be 'o': "hello." |
+ | |||
+ | For this assignment, you are given the executable version of an encoder, which uses the process illustrated above. Your assignment is to write the decoder that will take words in lowercase and decodes them to their original version. | ||
+ | |||
+ | You can get a copy of the executable version of the encoder as follows: | ||
+ | |||
+ | getcopy hw6code | ||
+ | |||
+ | |||
+ | Call your program '''hw6decode.asm''' and submit it to Moodle when done. | ||
+ | <br /> | ||
+ | ==Examples== | ||
+ | <br /> | ||
+ | The following examples illustrate how your program must work when working | ||
+ | <br /> | ||
+ | [[Image:hw6codedecode.png|center]] | ||
+ | <br /> |
Revision as of 15:41, 5 November 2017
--D. Thiebaut (talk) 12:59, 5 November 2017 (EST)
Problem #1
- Assume that you have a program that uses a loop to compute Fibonacci numbers.
- The Fibonacci terms get stored in an array called Fib as they are computed. The array is an array of dwords.
- In the loop, the program computes
Fib[ i ] = Fib[ i-1 ] + Fib[ i-2 ];
- The program uses some form of addressing mode to store each Fib[i] term in the array.
- If we are not worried about possible overflow of the arithmetic, i.e. we are not worried that the computation might become invalid at some point, and if we assume that the array can be as large as we want (we have a large amount of RAM in our computer), what is a good approximation to the maximum number of Fibonacci terms an assembly program can compute in 1 second, if our computer has a 2.5 GHz Pentium processor?
- Answer the multiple-choice question on Moodle.
Problem #2
When you were a kid, you may have exchanged secret messages with friends. An easy way to do this is to assign a different letter to each letter of the alphabet. For example:
a b c d e f g h i j k l m n o p q r s t u v w x y z | | | | | | | | | | | | | | | | | | | | | | | | | | b c d a f g h e m n i j k l p o r q t s x y z u v w
If you wanted to send a secret message containing the word "hello" to a friend, you would need to encode it first. For this, you would look up each letter of the word in the first line above (normal alphabet), find the letter directly underneath (in the scrambled alphabet), and make up a new word with the letters from the second line. 'h' would become 'e', 'e' would become 'f', 'l' would become 'j', and 'o' would become 'p'. So 'hello' would be encoded' as 'efjjp'. Your friend then had to decode 'efjjp' back into 'hello' by using a similar process.
To decode the message, your friend could use the same method you used, but with a different second scrambled alphabet:
a b c d e f g h i j k l m n o p q r s t u v w x y z | | | | | | | | | | | | | | | | | | | | | | | | | | d a b c h e f g k l m n i j p o r q t s x y z u v w
To decode 'efjjp', your friend would look up 'e' in the first alphabet above, and find 'h' just below. 'h' would be the first letter of the encoded message. 'f' is above 'e', so 'e' is the second letter. 'j' is above 'l', so the next letters are 'll'. And finally 'p' is above 'o', so the final letter of the encoded message had to be 'o': "hello."
For this assignment, you are given the executable version of an encoder, which uses the process illustrated above. Your assignment is to write the decoder that will take words in lowercase and decodes them to their original version.
You can get a copy of the executable version of the encoder as follows:
getcopy hw6code
Call your program hw6decode.asm and submit it to Moodle when done.
Examples
The following examples illustrate how your program must work when working