[SOLVED] 代写 algorithm LC-3 assembly operating system graph Lab Exercise 3

30 $

File Name: 代写_algorithm_LC-3_assembly_operating_system_graph_Lab_Exercise_3.zip
File Size: 640.56 KB

SKU: 3692389674 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


Lab Exercise 3
CPS2390, Fall 2019
Dept. of CS, WKU
Instructor: Dr. Changjiang Zhang

Due: Nov 25, 2019 11.59 PM

Cryptography

1. Background
There are many ways to keep something secret. One way is to physically hide the document. Another way is to encrypt the text you wish to remain secret. Some people use this to keep others from understanding the contents of the files in their computer. Encrypting a file requires an input message, called the “plain text,” and an encryption algorithm. An encryption algorithm transforms “plain text” into “cipher text.” Just like a door needs a key to lock and unlock it, an encryption algorithm often requires a key to encrypt and decrypt a message. Just like a homeowner can selectively give the key to the front door to only those he wants to allow unaccompanied access, the author of a message can selectively give the encryption key to only those he wants to be able to read the message. In order for someone to read the encrypted message, he has to decrypt the cipher text, which usually requires the key. For example, suppose the plain text message is HELLO WORLD. An encryption algorithm consisting of nothing more than replacing each letter with the next letter in the alphabet would produce the cipher text IFMMP XPSME. If someone saw IFMMP XPSME, he would have no idea what it meant (unless, of course, he could figure it out, or had the key to decrypt it.) The key to encrypt in this case is “pick the next letter in the alphabet,” and the decryption key is “pick the previous letter in the alphabet.” The decryption algorithm simply replaces each letter with the one before it, and presto: the plain text HELLO WORLD is produced.

有很多方法可以保密。一种方法是物理隐藏文档。另一种方法是对您希望保密的文本进行加密。有些人使用它来防止其他人理解他们计算机中文件的内容。加密文件需要输入消息(称为“纯文本”)和加密算法。加密算法将“纯文本”转换为“密文”。就像门需要钥匙来锁定和解锁一样,加密算法通常也需要钥匙来加密和解密消息。就像房主可以选择性地将只有他想要允许无人陪伴进入的人将钥匙提供给前门一样,消息的创建者可以选择性地仅给那些他希望能够阅读消息的人提供加密密钥。为了使某人阅读加密的消息,他必须解密通常需要密钥的密文。例如,假设纯文本消息是“ HELLO WORLD”。仅用字母中的下一个字母替换每个字母的加密算法将产生密文IFMMP XPSME。如果有人看到了IFMMP XPSME,他将不知道它的含义(当然,除非他可以弄清楚它的意思,或者拥有解密它的密钥。)在这种情况下,加密的密钥是“选择密码中的下一个字母”。字母”,解密密钥是“选择字母中的前一个字母”。解密算法只需将每个字母替换为前面的字母,然后即可:产生纯文本HELLO WORLD。

2. Assignment
Implement, in LC-3 assembly language, an encryption/decryption program that meets the following requirements:

以LC-3汇编语言实现满足以下要求的加密/解密程序:

Input
Your program should prompt the user for three separate inputs from the keyboard, as follows:
1. The prompt: IF YOU WANT TO ENCRYPT, TYPE E; IF YOU WANT TO
DECRYPT, TYPE D:
·The user will type E or D. A real world program should also detect any other character typed and respond with THAT IS AN ILLEGAL CHARACTER.
PLEASE TRY AGAIN. We will assume in this assignment that the user can type an E or D correctly.
·Your program will accept that character, store it in x3200, and use it, as we shall see momentarily.
2. The prompt: ENTER THE ENCRYPTION KEY (A SINGLE DIGIT FROM 1 TO 9):
·The user will type a single digit, from 1 to 9. Again, we will assume the user is not an Aggie, and can successfully hit digit keys on the keyboard.
·Your program will accept this digit, store it in x3201, and use it to encrypt or decrypt the message.
3. The prompt: INPUT A MESSAGE OF NO MORE THAN 20 CHARACTERS.
WHEN DONE, PRESS
·The user will input a character string from the keyboard, terminating the message with the key.
·Your program will store the message, starting in location x3202. Since the message is restricted to #20 characters, you must reserve locations x3202 to x3215 to store the message. (Note that #20 = x14.)
·One constraint: Messages must be less than or equal to #20 characters. (Recall: # means the number is decimal.)

Hint: to continually read from the keyboard without first printing a prompt on the screen, use TRAP x20. That is, for each key you wish to read, the LC-3 operating system must execute the TRAP x20 service routine. If you follow TRAP x20 with the instruction TRAP x21, the character the user types will be displayed on the screen.
您的程序应提示用户从键盘输入三个单独的内容,如下所示:
1.提示:如果您想加密,请输入E型;如果你想
解密,D型:
·用户将键入E或D。真实世界的程序还应该检测到其他任何键入的字符,并以“非法字符”作为响应。
请再试一遍。我们将在此分配中假定用户可以正确键入E或D。
·正如我们稍后将看到的,您的程序将接受该字符,将其存储在x3200中并使用它。
2.提示:输入加密密钥(从1到9的单个数字):
·用户将输入一个从1到9的数字。同样,我们将假定用户不是Aggie,并且可以成功按下键盘上的数字键。
·您的程序将接受该数字,将其存储在x3201中,并用它来加密或解密消息。
3.提示:输入消息的字符数不超过20个。
完成后,按
·用户将从键盘输入字符串,并用 键终止消息。
·您的程序将从位置x3202开始存储消息。由于消息限制为#20个字符,因此必须保留位置x3202至x3215来存储消息。 (请注意,#20 = x14。)
·一个约束:消息必须小于或等于#20个字符。 (回想:#表示数字为十进制。)

提示:要连续从键盘读取而不先在屏幕上打印提示,请使用TRAP x20。也就是说,对于您希望读取的每个键,LC-3操作系统必须执行TRAP x20服务例程。如果在TRAP x20后面加上TRAP x21指令,则用户键入的字符将显示在屏幕上

Algorithm
The encryption algorithm is as follows. Each ASCII code in the message will be transformed as follows:
1. The low order bit of the code will be toggled. That is, if it is a 1, it will be replaced by a 0; if it is a 0, it will be replaced by a 1.
2. The key will be added to the result of step 1 above.
·For example, if the input (plain text) is A and the encryption key is 6, the program should take the ASCII value of A, 01000001, toggle bit [0:0], producing
01000000 and then add the encryption key, 6. The final output character would be
01000110, which is the ASCII value F.

加密算法如下。消息中的每个ASCII代码将按以下方式转换:
1.代码的低位将被切换。也就是说,如果为1,则将其替换为0;否则为0。如果为0,则将其替换为1。
2.该密钥将添加到上述步骤1的结果中。
·例如,如果输入(纯文本)为A并且加密密钥为6,则程序应采用ASCII值A,01000001,切换位[0:0],产生
01000000,然后添加加密密钥6。最终输出字符为
01000110,它是ASCII值F。

The decryption algorithm is the reverse. That is,
1. Subtract the encryption key from the ASCII code.
2. Toggle the low order bit of the result of step 1.
·For example, if the input (cipher text) is F, and the encryption key is 6, we first subtract the encryption key (i.e., we add -6) from the ASCII value of F, 01000110
+ 11111010, yielding 01000000. We then toggle bit [0:0], producing 01000001, which is the ASCII value for A.
·The result of the encryption/decryption algorithm should be stored in locations x3216 to x3229.

解密算法是相反的。 那是,
1.从ASCII码中减去加密密钥。
2.切换步骤1结果的低位。
·例如,如果输入(密文)为F,并且加密密钥为6,我们首先从F的ASCII值01000110中减去加密密钥(即,我们加-6)
+ 11111010,产生01000000。然后切换[0:0]位,产生01000001,这是A的ASCII值。
·加密/解密算法的结果应存储在位置x3216至x3229中。

Output
Your program should output the encrypted or decrypted message to the screen. Note that the encryption/decryption algorithm stored the message to be output starting in location x3216.

您的程序应将加密或解密的消息输出到屏幕。 请注意,加密/解密算法从位置x3216开始存储要输出的消息。

4. Format
Your program must be a text file of assembly code (i.e., a .asm file).

4. Extra Information
– The starting location is to be x3000
– The buffers have been expanded to 21 memory locations each so that
you may store
x3200 <- E/Dx3201 <- Encryption keyx3202 through x3216 <- input bufferx3217 through x322A <- output buffer- The key is mapped to the line feed character on the LC-3
(ASCII x0A)
– Acceptable inputs to be encrypted are any ASCII characters within the range x20 to x5A
– You may assume the user will only type an upper-case E or D
– The prompts have been shortened
Prompt 1: (E)ncrypt/(D)ecrypt:
Prompt 2: Encryption Key:
Prompt 3: Input Message:
For further reading on the subject of cryptography and its role in history, “The Code
Book” by Simon Singh is recommended.

为了进一步了解密码学及其在历史中的作用,“
推荐西蒙·辛格(Simon Singh)的《书》。
Writing and testing your program

Your code should have a comment block at the beginning of the file containing your name, your student number, and a brief description of the program.
Your description should serve as a general summary of your program’s approach to the problem and will aid in grading. It will also serve as a guideline for assigning partial credit. It is in your best interest to make all of your ideas clear through this summary and through commenting within your code.
您的代码应在文件的开头带有注释块,其中包括您的姓名,您的学生编号和对该程序的简短描述。
您的描述应作为程序对问题的处理方法的一般摘要,并有助于评分。 它还将作为分配部分学分的指导原则。 通过此摘要和在代码中进行注释,使您的所有想法清晰明了是您的最大利益。

IMPORTANT NOTE:
The first line of your program must specify the memory address of where you want your program to be placed (using the .ORIG pseudo-op).
We request you place your program at x3000.

What to turn in

Please put all your files (lab3.asm, and lab3_readme.docx) in a zip file (Lab3_youlastname_firstname.zip) and send it to [email protected] before due date.

Good luck.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 algorithm LC-3 assembly operating system graph Lab Exercise 3
30 $