Department of Electrical and Computer Engineering
The University of Texas at Austin
EE 306, Fall 2008
Programming Assignment 3
Due: 2 November, 11:59 pm
Yale N. Patt, Instructor
TAs: Jeffrey Allan, Arvind Chandrababu, Eiman Ebrahimi, Aravind Jakkani, Khubaib,
Allison Korczynski,
Pratyusha Nidamaluri, Zrinka Puljiz, Che-Chun Su, Christopher Wiley
You must do the programming assignment by yourself. You are
permitted to get help from ONLY the TAs and the instructor.
The file you submit
should be an assembly language file called login.asm. This is the only
file you need to submit.
Create a login program that authenticates input usernames and passwords.
Assignment:
When I login to a Linux machine, the operating system prompts me for my
user id and password. If I am a legitimate user, the operating system gives me
access, displaying on the screen: "Patt, you have successfully logged in."
If I don't have a legitimate UserID/password, the operating system denies me
access, and displays on the screen: "Invalid UserID/Password. Your login
failed."
Your job in this programming lab assignment: write the program in LC-3 Assembly
Language to perform this process.
Your program should start by prompting the user for his/her user ID. It does
so by displaying "Login ID:" on the monitor. It will then sit and wait for
the user to type his/her UserID. Your program must then prompt the user for
his/her password, by displaying "Password:" on the screen.
Your program must then compare your UserID/Password pair with all the
User/ID pairs in the password file. To protect this file from inadvertent
compromise, the passwords are stored in an encrypted form. Thus, you will
also have to encrypt the password the user types before comparing it with
the password for that user in the Encrypted Password File.
The encryption algorithm is simply to subtract x0C from each ASCII code that
makes up the password. Thus if my password was ABC75, my encrypted password
would be 567+).
Suppose we have four users as shown in the table below, along with their
password, and encrypted password:
| UserID | Input Password | Encrypted Password |
| Patt | ee306P | YY’$*D |
| TEXAS08 | ATX2008 | 5HL&$$, |
| Bevo | hookem | \cc_Ya |
| Alec | 100yrs | %$$mfg |
|
A sample of what your program will produce, when supplied with the input
from users trying to log on, is shown below:
Login ID:Patt
Password:ee306P
Patt, you have successfully logged in.
----- Halting the processor -----
Login ID:Patt
Password:ee
Invalid UserID/Password. Your login failed.
----- Halting the processor -----
Login ID:Bevo
Password:hookem
Bevo, you have successfully logged in.
----- Halting the processor -----
Login ID:Bevo
Password:horns
Invalid UserID/Password. Your login failed.
----- Halting the processor -----
Login ID:Aggie
Password:123
Invalid UserID/Password. Your login failed.
----- Halting the processor -----
The Encrypted Password File
===========================
To do your job you will need to know how the Encrypted Password File is stored
in memory.
We store in successive memory locations, starting with x4000, pointers to
the UserID/password of each legitimate user.
| x4000 | x6002 |
| x4001 | x600E |
| x4002 | x601E |
| x4003 | x602A |
| x4004 | x0000 |
|
Note that the pointer of the first user Patt is stored at locations starting
with x4000. Note that x4004 contains x0000, the NULL pointer, indicating that
there are only four legitimate users. You can assume that the number of users
is less than x0100, and that table terminates with x0000.
Note that the pointer of the first user is x6002, indicating that the
user name for that user "Patt" is stored at memory locations starting
with x6002.
For each user, the UserID/Encrypted_Password is stored as a consecutive
sequence of ASCII codes, one ASCII code per memory location. In order for
you to check UserID and Password correctly, we will store x0000 after each
UserID and x0000 after each password. Since Patt/YY’$*D consists of 10 ASCII
characters + the two x0000, the UserID/Password occupies 12 words of memory,
from locations x6002 to x600D.
The second user, TEXAS08 is stored, starting at location x600E.
The table below shows the contents of memory starting at x6002 for the four
legitimate users. You can assume that this table starts at some address greater than
x6000 (as indicated by the value in location x4000) and terminates before location
xEFFF.
| Address: | Memory: |
| x6002 | x0050 |
| x6003 | x0061 |
| x6004 | x0074 |
| x6005 | x0074 |
| x6006 | x0000 |
| x6007 | x0059 |
| x6008 | x0059 |
| x6009 | x0027 |
| x600A | x0024 |
| x600B | x002A |
| x600C | x0044 |
| x600D | x0000 |
| x600E | x0054 |
| x600F | x0045 |
| x6010 | x0058 |
| x6011 | x0041 |
| x6012 | x0053 |
| x6013 | x0030 |
| x6014 | x0038 |
| x6015 | x0000 |
| x6016 | x0035 |
| x6017 | x0048 |
| x6018 | x004C |
| x6019 | x0026 |
| x601A | x0024 |
| x601B | x0024 |
| x601C | x002C |
| x601D | x0000 |
| ... | ... |
|
To test your program on the Simulator, you will need to know the
UserID/Password of all legitimate users. For now, you know this
for the four users Patt, TEXAS08, Bevo, and Alec. The UserID/password for Patt and TEXAS08 are shown above
Here is the test file associated with these four users: Patt, TEXAS08, Bevo, and Alec.
These userID/passwords will be initialized in memory as follows:
Create a new asm file (for example called prgm3test.asm) with the following text in it:
.ORIG x4000
.FILL x6002
.FILL x600E
.FILL x601E
.FILL
x602A
.FILL x0000
.BLKW x1FFD
.FILL x0050
.FILL x0061
.FILL x0074
.FILL x0074
.FILL x0000
.FILL x0059
.FILL x0059
.FILL x0027
.FILL x0024
.FILL x002A
.FILL x0044
.FILL x0000
.FILL x0054
.FILL x0045
.FILL x0058
.FILL x0041
.FILL x0053
.FILL x0030
.FILL x0038
.FILL x0000
.FILL x0035
.FILL x0048
.FILL x004C
.FILL x0026
.FILL x0024
.FILL x0024
.FILL x002C
.FILL x0000
.FILL x0042
.FILL x0065
.FILL x0076
.FILL x006F
.FILL x0000
.FILL x005C
.FILL x0063
.FILL x0063
.FILL x005F
.FILL x0059
.FILL x0061
.FILL x0000
.FILL x0041
.FILL x006C
.FILL x0065
.FILL x0063
.FILL x0000
.FILL x0025
.FILL x0024
.FILL x0024
.FILL x006D
.FILL x0066
.FILL x0067
.FILL x0000
.END
Assemble the newly created file to produce a prgm3test.obj file. Then, load the prgm3test.obj file into the simulator. Don't forget to set the PC register to x3000 before running your program. Note this is just an example of how to initialize memory for testing your program. This is not the only test case your program should work with and you will not submit this test file to the submission system.
We may give you additional files to test your program later.
Input/Output Requirements
===========================
Described below are detailed requirements about the Inputs and Outputs of your
program.
Input:
Your program should prompt the user for two separate inputs from the keyboard,
as follows:
- The prompt: Login ID:
- The user will input a character string from the keyboard, terminating the UserID
with the <Enter> key. The <Enter> key is not part of the message, but you will need to
echo it onto the console.
- You may assume that only alphanumeric characters will be used.
- You may assume that the username is typed correctly without using backspace or delete and that the
length of the username string is bound to a minimum of 4 and a maximum of 10 characters.
- The prompt: Password:
- The user will input a character string from the keyboard, terminating the message
with the <Enter> key. Again, the <Enter> key is not part of the message, but you
will need to echo it to the console.
- You may assume that only alphanumeric characters will be used.
- You may assume that the password is typed correctly without using backspace or delete and that the
length of the password string is bound to a minimum of 6 and a maximum of 10 characters.
- The password input from the keyboard is the decrypted password. It the program’s
job to encrypt the entered password and then check to see if it matches the encrypted password
in the input array list.
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.
Output:
Your program should output one of two strings depending on the outcome of checking
username and encrypted password, and then HALT.
- Output to Screen: Invalid UserID/password. Your login failed.
for the following cases:
- A non-valid input ID (not found in UserID array)
- An incorrect password (does not match up with user ID) if and only if UserID is already valid
- Output to Screen: <UserID>, you have successfully logged in.
for the following case:
- A valid user ID and its associated password match the input UserID and the encrypted password.
Hint 2: To output a string to the console display, use TRAP x22 (assembler name PUTS). What needs to go into R0 in order to use this TRAP instruction?
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 .
-
When using a Windows machine, use the LC3Edit program to type in your programs.
Your program file needs to be in plain text format. Please ask any TA if
you have any questions.
- Look in the
Software and Documentation
section for more help on how to use the simulator.
- The file that you will submit for this assignment must be named login.asm.
- To submit program 3, follow the submission instructions.
- You should check out the software and documentation and the submission
instructions for submitting your program well before deadline, so
that you can get help from a TA if you can not figure out the mechanics by
yourself.