asgn3

advertisement
CSC 225
Assignment #3 – igPay atinLay
Notes:
You may work with a partner! Turn in one cover page, do one demo, and submit one version of code to
handin.
Objectives:
To learn how to program in the LC-3 assembly language, including:
 assembly language instructions
 psuedo-ops
 traps
 basic I/O
Background:
Your program will translate words from English to Pig Latin. To translate to Pig Latin,
remove the starting letter of the word and put it at the end. Then add "ay" to the word.
Some sample translatons:
Julie translates to ulieJay
Paul translates to aulPay
binary translates to inarybay
Extra Credit (2 points):
A proper Pig Latin translator would check to see if the word started with a vowel and simply
append "way" to the end without removing anything from the front. You may earn 2
points extra credit if you implement this. You only have to handle lowercase letters.
Sample translation:
otay translates to otayway
You can do this any way that you want, but it’s MUCH cooler if you can do it in a loop,
rather than by checking each vowel one by one with separate code.
Description:
Input:
Your program should prompt the user for the word to be translated. Please read the
following requirements and hints carefully.

The user is to input a word of no more than 19 characters, followed by the <enter>
key. Assume the user will not enter a message longer than 19 characters. Checking
for too many characters is NOT necessary.

Store the word one character per location in memory. You must store the word.

Your program may allocate room to store 20 characters, including the <enter>
key. Do not allot space for more than 20 characters in memory.

Hint #1: Using a TRAP x20 (GETC) followed by a TRAP x20 (OUT) will get
keystrokes and echo them back to the console.

Hint #2: The <enter> key is ASCII x0A or ASCII x0D. (It is different on the
Windows and Linux machines. Check to see which one your machine uses.)

Hint #3: For reasons that will become clear to you later, do not use R7 to store
anything for this assignment.
Translation Algorithm:
1.
Remove (do not print) the first letter of the word and put (print) it at the end of the
word.
Add "ay" to the word.
2.
Output:

You must print prompts for the English word and Pig-Latin word (see below).

The translated word should be output to the screen and does not need to be stored.

After outputting the translated word to the screen, the program should prompt the
user again, creating an endless loop.

Your program should then output the translated word to the screen. Following is a
sample run of the program (input shown in bold for clarity only):
English Word: Paul
Pig-Latin Word: aulPay
English Word: Hatalsky
Pig-Latin Word: atalskyHay

Your input/output format should match the above example.
Code Format:
Your code should be a single text file of LC-3 assembly code.

Comment your code. There should be a header block at the top with your name and
a description of the program. Include a description of what you use each register for.
Then comment “blocks” of code underneath. You do not need to comment every
line.
Other Information:

Your program should start at memory location x3000.

Name your assembly file pigLatin.asm. Assemble it using the 'asm' button in
the LC-3 Editor

Your program must loop and run correctly multiple times in a row.
Testing
Test your program thoroughly. Duh.
Demo
Demo your program to your instructor.
Handin
Handin by the end of lab on the day it is due. You may handin early and then simply rehandin if you need to make changes to your code. You must handin to your section.
Replace the XX with your section number. Handin will CLOSE at the end of lab.
handin grader-ph 225-XX-asgn3 pigLatin.asm
Deliverable
Cover page with Demo Signature
Download