Bryn Mawr College
CS 240: Principles of Computer Organization
Assignment#4
Due before start of class on Friday, April 30. Extra Credit Due on Friday, May 7, 2021.

This exercise describes two LC-3 assembly language programs. For this assignment you can choose to do either one. For extra credit (equivalent to a full assignment credit) you may do both. The deadlines are firm. There will be no extensions.

Description#1: Write an LC-3 assembly language program to compute the day of the year, given a date. For example, Feb 1, 2020 is the 32nd day of the year.

You can place the date in pre-assigned registers. For example: R0/R1/R2 = (mm/dd/yyyy).

```It should output the date and the result on the console:

The date is: 02/01/2020
It is day 32 of the year. ```

Notes:

1. You will be making extensive use of subroutines and system TRAPS to carry out your work.
2. Start by writing the program in pseudocode, choose registers for variables used in psuedocode. Encode the pseudocode in LC-3 instructions.
3. Submit your complete program in its source file (e.g. DayDate.asm).

Description#2: Write an LC-3 assembly language program to play a simple guessing the number game. Assume that the program has stored a number between 0-9 (inclusive). The program gives the user at most 5 chances to guess the number. The user will enter her guesses from the keyboard when prompted (use the TRAP instructions).

If a user's guess is larger than the selected number, the program should output:

`Too big.`

if smaller, it should output:

`Too small.`

If correct, it should output:

`Correct! You took # guesses.`

where # is the number of guesses. If after 5 guesses the user has not guessed the number, the program should output:

`Game over. Correct answer is #.`

where # is the number selected. If the user enters a character other than 0-9, the program should output:

`Invalid guess.`

And count that as a guess, and go on.

Notes:

1. You may pre-select the number to be guessed and code it in your program.
2. Start by writing the program in pseudocode, choose registers for variables used in psuedocode. Encode the pseudocode in LC-3 instructions.
3. Submit your complete program in its source file (e.g. HiLo.asm).