Question: Objective Through this project, you will practice writing loops to process strings in assembly langauge. Background Atbash is a simple mono-alphabetic substitution cipher where every
Objective
Through this project, you will practice writing loops to process strings in assembly langauge.
Background Atbash is a simple mono-alphabetic substitution cipher where every letter in a
string is substituted with its reverse. From Wikipedia:
Applying Atbash would simply mean taking the alphabet and mapping it to its reverse, so that the first letter becomes the last letter, the second letter becomes the second to last letter, and so on with rollover when Z gets mapped to A.
The transformation can be done using a lookup table, such as the following:
Since Atbash lacks any sort of a key, it barely has any sort of security For example, in the following silly joke, the punchline has been obscured by
Atbash: Why should you take a pencil to bed?
Gl wizd gsv xfigzrmh! Transforming the entire text via Atbash form, the answer to the joke is revealed:
Dsb hslfow blf gzpv z kvmxro gl yvw?To draw the curtains!
Atbash occasionally generates some English words from other English words, consider this:
Slim old tory torn over tilt zipHorn low glib glim levi grog ark
Although, the results may not be meaningful, they are certainly words in English!
Assignment
Your assignment for this project is to write an assembly language program that computes the Atbash of an input. Your program may execute like this:
./atbash Enter string: NoPqRsTuV Original: NoPqRsTuV Convert: MlKjIhGfE ./atbash Enter string: 1+1=Two Original: 1+1=Two Convert: 1+1=Gdl
./atbash Enter string: 1 One 2 Two 3 Three 4 Four 5 Five 6 Six
Original: 1 One 2 Two 3 Three 4 Four 5 Five 6 Six
Convert: 1 Lmv 2 Gdl 3 Gsivv 4 Ulfi 5 Urev 6 Hrc
Implementation Notes
-
Your can assume that no more than 256 characters will ever be input to your program.
-
Remember, all characters input into the system are ASCII values. Refer to an ASCII table when determining how to implement your Atbash cipher.
-
Your code must be case-preserving: if the input is upper-case, then the corresponding output must be upper-case; if the input is lower-case, then the corresponding output must be lower-case, as in the following example (also above):
./atbash Enter string: AbCdEfGhI Original: AbCdEfGhI Convert: ZyXwVuTsR
-
Your code should ignore non-alphabetical characters as in the following example (also above):
./atbash Enter string: arithmetic+-%^&* Original: arithmetic+-%^&* Convert: zirgsnvgrx+-%^&*
-
There are many ways to implement your Atbash cipher, but the two most obvious techniques are to use conditionals and arithmetic, or to use a lookup table. With conditionals and arithmetic, you would need to perform multiple checks on the input value, determine the difference from a lower bound (based on the case) and add 25. If using a lookup table, you would convert the character value input into an offset by subtracting the ASCII value for
a (if lowercase) or A (if uppercase). Then you would use that offset into a table (or in this case, a string), and put that value into the output instead of the original input. Your instructor recommends the lookup table technique (and the contents of your lookup table are provided above).
7. It may be helpful to write the code to perform the Atbash in a higher-level language of your choosing (C, C++, Java, Python, ...). This will help you understand the mechanics of your assembly language program. This is not required and you should NOT submit this if you choose to do it.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
