EE306 Introduction to Computing Lab 5 solution

$30.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

Purpose: The purpose of this assignment is to write a program in the LC-3 assembly language that creates a user interface to determine if a student EID matches a list of student EIDs. The list of student EIDs is organized as a “LINKED LIST” data structure.

Your program must: 1. Prompt the user for the student’s EID (refer to EID description in point 5) by printing on the monitor the string “Type EID and press Enter: ” and wait for the user to input a string followed by (ASCII: x0A). (Assume that there is no case where the user input exceeds or is less than the required number of characters)

2. Your program must then search the student list of EIDs to find a match for the entered EID. The list stores the student EID for each student. You will find a match only if the student’s EID is in the list. It is possible to not find a match in the list.

3. If your program finds a match, then it must print out “ is already in the main room.”. (eg., “XY123 is already in the main room.”)

4. If your program does not find a match, then it must print out “ is not in the main room.”. (eg., “XY123 is not in the main room.”).

5. Unique EIDs are exactly 5 characters long and contains only uppercase alphabets and numbers. For example, XY123. Note: first two characters must be uppercase letters and last 3 characters must be numbers.

6. Head pointer for the main room list is at x4000. In other words, the address of the first node of the list is at x4000. The Linked-List A linked-list is a set of nodes connected to each other via pointers. Each node in the linked-list contains a pointer to (the address of) the next node in the linked-list. This pointer is commonly known as the next-pointer. If the last node contains x0000 as its next pointer, it implies that there is no “next node.”

That is, this is the last node. We call x0000 in this context a NULL pointer. Each node in a linked-list is comprised of k+1 words: one word containing the next-pointer (the pointer to the next node) and k words of data which are being stored by the node. In our case, the database of student IDs is implemented as a linked-list with k+1=2. Each node consists of two words in the following order: 1. The next-pointer.

A pointer to an ASCII string representing the student’s unique EID (5 Characters long+ NULL). Recall that a string consists of ASCII codes stored in consecutive memory locations, one ASCII code per location. The string is null-terminated, i.e., the end of a string is signified by the NULL character which is ASCII code 0. Below is an example database implemented as a linked-list.

When you test your program, you can use a database with a similar structure. The test cases that we will use to test your program will be similar to this example. Figure 1: Example Linked List Structure – Main Room Participants List Address M[Address] X4000 X4002 X4001 … X4002 X4004 (Next pointer) X4003 X4800 (Pointer to EID) X4004 X4006 X4005 X4806 X4006 X0000 X4007 X480C … … X4800 “X” X4801 “Y” X4802 “1” X4803 “2” X4804 “3” X4805 X0000 X4806 “A” X4807 “B” X4808 “7” X4809 “8” X480A “9” X480B X0000 EE306 Introduction to Computing X480C “P” X480D “Q” X480E “5” X480F “6” X4810 “7” X4811 X0000 … …

Figure 2: Contents of Memory If the input were: Type EID and press Enter: MN483 Then the output message would be: MN483 is not in the main room. If the input were: Type EID and press Enter: AB789 Then the output message would be: AB789 is already in the main room.

Input/Output Requirements

Described below are detailed requirements about the Inputs and Outputs of your program. You should adhere to these guidelines to receive full credit for this assignment.

Input: Your program should prompt the user for the last name from the keyboard, as follows: Print a string EXACTLY “Type EID and press Enter: ”. Then wait for the user to input a string followed by . Note that you will get a 0 on the assignment if you do not print this string EXACTLY. The user will input a character string from the keyboard, terminating the EID with the key.

Hint: 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 the linked list lookup. (i) If the EID entered by the user is found in the main room list, print out “ is already in the main room.”. EE306 Introduction to Computing (ii) If the EID entered by the user is not found in the main room list, print out “ is not in the main room.”.

Hint: To output a string to the console display, use TRAP x22 (assembler name PUTS). What needs to go into R0 to use this TRAP instruction? A sample of what your program will produce, when supplied with the input from the user trying to add the course: EXAMPLE 1: Type EID and press Enter: MN483 MN483 is not in the main room. —– Halting the processor —– EXAMPLE 2: Type EID and press Enter: AB789 AB789 is already in the main room. —– Halting the processor —- EXAMPLE 3: Type EID and press Enter: XY123 XY123 is already in the main room —– Halting the processor —–

Notes & Hints: 1. Your program must start at location x3000. 2. The linked lists is an input to your program. The list is loaded in memory before your program begins to run. Your program will search the list. 3. The pointer to the first node to the main room is stored in memory location x4000 before the program execution begins. Further, assume that all the nodes are stored between memory locations x4002 and xFDFF. Make no other assumptions about the location of the nodes. Note that the pointer to the first node may be set to NULL (i.e., 0), indicating that there are no nodes in the list. 4. Your program should NOT make any assumptions about the number of nodes in the list.

You may assume that everyone in the list has a unique EID. IMPORTANT: The file that you will upload to online repository for this assignment must be named youreid.asm. (eg., xy123.asm)