Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 18th, 2008, 12:42 PM   #1
SandroDeFigueiredo
Newbie
 
Join Date: Dec 2008
Posts: 6
Rep Power: 0 SandroDeFigueiredo is on a distinguished road
Assembly - LC3

hello... i have a big problem...

i have to do program, for avaliation, in LC3, but i don't understand nothing about assembly, my teach don't learning us how use or programing assembly...: S

so i need help....

the work is....


Cryptography, from the Greek word kryptos, meaning "hidden", deals with the science of hiding a message from eyes you do not want to understand the contents of the message. The desire to do this has existed ever since humankind was first able to write. 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/she wants to allow unaccompanied access, the author of a message can selectively give the encryption key to only those he/she wants to be able to read the message. In order for someone to read the encrypted message, he/she 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/she would have no idea what it meant (unless, of course, he/she 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".
Assignment:
Implement, in LC-3 assembly language, an encryption program that meets the following requirements:

Input:
Your program should prompt the user for input from the keyboard, as follows:
The prompt: Input a message, when done press the <Enter> key:
o The user will input a character string from the keyboard, terminating the message with the <Enter> key. The <Enter> key is not part of the message, but you will
need to echo it onto the console.
o You may assume that the message that the user enters will be at most 20
characters long (including spaces).
Hint 1: To continually read from the keyboard without first printing a prompt on the screen, use TRAP x20 (assembler name GETC). 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 (assembler name OUT), the character the user types will be displayed on the screen as we showed in class on Wednesday.
Encyption Algorithm:
Each ASCII code in the message will be transformed as follows:

1. The low 5 bits of the ASCII code will be left rotated by 3 bit positions. The high bits will remain the same.

2. For example, if the input (plain text) is the letter A, the program should replace the low five bits of the ASCII code for A, with the five bits obtained by rotating them three bit positions to the left. In this case, since the ASCII code for A is 01000001, the low five bits are 00001. Rotating them three bit positions to the left yields 01000. Putting this into the low five bit positions yields the encrypted code 01001000. Since this is the ASCII code for H, we have thus encrypted A as H.

Hint 2: To extract the low 5 bits of the ASCII code, think about using a MASK.

Hint 3: Shifting by 1 to the left is equivalent to multiplication by 2.

Hint 4: There are several ways to rotate a field that is smaller than eight bits with the LC-3. One way is to start by placing the field in both the high bits and low bits of a word. If the field is five bits, the high bits are Bits[15:11] and the low bits are Bits[4:0].
Output: Your program should output the encrypted message to the screen, and then HALT.
Notes:
• The first line of your program must specify the memory address of the first instruction of your program. The LC-3 simulator will place your program starting at that address. For this assignment, you should place your program starting at x3000 (i.e. the first line of your program should be .ORIG x3000).
• If you are using a Windows machine, use the LC3Edit program to type in your programs.
On the Linux workstations, pico, emacs (or xemacs), and vi (or gvim) are several of the text editors you can use. Your program file needs to be in plain text format. Please ask any TA if you have any questions.
SandroDeFigueiredo is offline   Reply With Quote
Old Dec 18th, 2008, 3:58 PM   #2
Grich
Professional Programmer
 
Grich's Avatar
 
Join Date: Sep 2007
Location: Sydney - Australia
Posts: 424
Rep Power: 8 Grich is on a distinguished road
Re: Assembly - LC3

Do your own homework Dude.
__________________
SYNTAX ERROR ...
Grich is offline   Reply With Quote
Old Dec 18th, 2008, 4:17 PM   #3
Arla
Expert Programmer
 
Arla's Avatar
 
Join Date: Mar 2005
Posts: 777
Rep Power: 10 Arla is on a distinguished road
Re: Assembly - LC3

This line

Quote:
Please ask any TA if you have any questions
Would seem to apply, follow the instructions.
Arla is offline   Reply With Quote
Old Dec 19th, 2008, 10:37 AM   #4
SandroDeFigueiredo
Newbie
 
Join Date: Dec 2008
Posts: 6
Rep Power: 0 SandroDeFigueiredo is on a distinguished road
Re: Assembly - LC3

yes you have reason but... i have search... but is difficult....
SandroDeFigueiredo is offline   Reply With Quote
Old Jan 1st, 2009, 8:07 PM   #5
lonewolff
Indie Game Developer
 
lonewolff's Avatar
 
Join Date: Sep 2008
Location: Australia
Posts: 196
Rep Power: 7 lonewolff is on a distinguished road
Re: Assembly - LC3

Is this homework for school?
lonewolff is offline   Reply With Quote
Old Jan 7th, 2009, 11:04 AM   #6
SandroDeFigueiredo
Newbie
 
Join Date: Dec 2008
Posts: 6
Rep Power: 0 SandroDeFigueiredo is on a distinguished road
Re: Assembly - LC3

Quote:
Originally Posted by lonewolff View Post
Is this homework for school?

yes, it is.
SandroDeFigueiredo is offline   Reply With Quote
Old Jan 8th, 2009, 9:02 PM   #7
SandroDeFigueiredo
Newbie
 
Join Date: Dec 2008
Posts: 6
Rep Power: 0 SandroDeFigueiredo is on a distinguished road
Re: Assembly - LC3

Well, the program was done... So if you think if you can change anything, try.
I appreciate your help...




; KRYPTO PROGRAM


.ORIG x4000

LD R1, IFILE
LD R2, IKRIP

LEA R0, MENSAGEM
PUTS

SE_1 GETC
OUT

NOT R3, R0

ADD R3, R3, #10
ADD R3, R3, #1

BRz FIM_SE_1

STR R0, R1, #0


VAL_1 LD R3, MASCARA_1
AND R4, R0, R3
LD R5, MEMORIA_1
STR R4, R5, #0

VAL_2 LD R3, MASCARA_11
AND R4, R0, R3

ADD R4, R4, R4
ADD R4, R4, R4
ADD R4, R4, R4
LD R5, MEMORIA_2
STR R4, R5, #0

VAL_100 LD R3, MASCARA_CEM
AND R4, R0, R3
BRz VAL_1000
ADD R4, R4, #-3

VAL_1000 LD R5, MEMORIA_3
STR R4, R5, #0

LD R3, MASCARA_MIL
AND R4, R0, R3
BRz VAL_10000
ADD R4, R4, #-6

VAL_10000 LD R5, MEMORIA_4
STR R4, R5, #0

LD R3, MASCARA_10MIL
AND R4, R0, R3
BRz SOMA

ADD R4, R4, #-12


SOMA LD R5, MEMORIA_5
STR R4, R5, #0




AND R5, R5, #0

LD R3, MEMORIA_1
LDR R4, R3, #0
ADD R5, R5, R4

LD R3, MEMORIA_2
LDR R4, R3, #0
ADD R5, R5, R4

LD R3, MEMORIA_3
LDR R4, R3, #0
ADD R5, R5, R4

LD R3, MEMORIA_4
LDR R4, R3, #0
ADD R5, R5, R4

LD R3, MEMORIA_5
LDR R4, R3, #0
ADD R5, R5, R4

STR R5, R2, #0



ADD R1, R1, #1
ADD R2, R2, #1

BR SE_1

FIM_SE_1

AND R0, R0, #0
ADD R0, R0, x04
STR R0, R1, #0
STR R0, R2, #0


AND R0, R0, #0
AND R1, R1, #0
AND R2, R2, #0
AND R3, R3, #0
AND R4, R4, #0

LD R2, IKRIP

LEA R0, MEN_CRIPTADA
PUTS


SE_2 LDR R4, R2, #0
ADD R2, R2, #1

NOT R0, R4
ADD R0, R0, #1

ADD R0, R0, X04

BRz FIM_SE_2

SENAO_2 AND R0, R0, #0

ADD R0, R0, R4
OUT

BR SE_2

FIM_SE_2 HALT


IFILE .FILL x5000
IKRIP .FILL x6000
MENSAGEM .STRINGZ "Insira uma mensagem. Quando acabar prima <Enter>: "
MEN_CRIPTADA .STRINGZ "Mensagem encriptada: "
EOF .FILL #04
CHEX .FILL x-30
MASCARA_1 .FILL xE0
MASCARA_2 .FILL x1F
MASCARA_11 .FILL x03
MASCARA_CEM .FILL x04
MASCARA_MIL .FILL x08
MASCARA_10MIL .FILL x10
MEMORIA_1 .FILL x5500
MEMORIA_2 .FILL x5501
MEMORIA_3 .FILL x5502
MEMORIA_4 .FILL x5503
MEMORIA_5 .FILL x5504
.END
SandroDeFigueiredo is offline   Reply With Quote
Old Jan 8th, 2009, 9:14 PM   #8
Benoit
Security Specialist
 
Benoit's Avatar
 
Join Date: Sep 2004
Posts: 1,053
Rep Power: 12 Benoit will become famous soon enough
Re: Assembly - LC3

Be sure to add comments to your code so people who read it know whats going on
Benoit is offline   Reply With Quote
Old Jan 9th, 2009, 11:32 AM   #9
SandroDeFigueiredo
Newbie
 
Join Date: Dec 2008
Posts: 6
Rep Power: 0 SandroDeFigueiredo is on a distinguished road
Re: Assembly - LC3

Quote:
Originally Posted by Benoit View Post
Be sure to add comments to your code so people who read it know whats going on

yes but the comments are in portuguese...
SandroDeFigueiredo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Assembly, Assembler? v0id Assembly 16 Feb 26th, 2009 1:31 PM
OOP in assembly? titaniumdecoy Coder's Corner Lounge 6 Dec 19th, 2007 12:54 AM
quick assembly question jbo423 Assembly 4 Nov 12th, 2007 8:21 AM
Assembly Language DaWei Coder's Corner Lounge 0 Apr 26th, 2007 11:15 PM
High Level Assembly? Gink Assembly 3 Apr 20th, 2005 12:34 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:22 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC