Optional Homework Assignment #3 [0 pts]


How to turn in?

Assignments need to be turned in via Lamaku

What to turn in?

You must turn in a zip archive named ics312_hw3_xxx.zip, where “xxx” is your UH user name (e.g., for me, it would be ics312_hw3_henric.zip). The archive must contain a single top-level directory called ics312_hw3_xxx, where “xxx” is your UH user name (e.g., for me, it would be ics312_hw3_henric). In that directory you must have all the files named exactly as specified in the questions below.

Expected contents of the ics312_hw3_xxx directory:

Solutions

Available upon request to the instructor (only AFTER the due date)


Exercise 1: Warm Up [0pts]

Write an assembly program called hw3_ex1, with source in file hw3_ex1.asm, that prompts the user for one lower-case letter and one integer. Then the program prints out the upper-case version of the letter and the opposite of the integer.

Below are program invocation examples (‘%’ is the command-line prompt, and user input is shown as well), and your program should match that output format:

% ./hw3_ex1
Enter a lower-case letter: a
Enter an integer: 12
The upper-case letter is 'A'
The opposite integer is '-12'
% ./hw3_ex1
Enter a lower-case letter: z
Enter an integer: -43
The upper-case letter is 'Z'
The opposite integer is '43'
% ./hw3_ex1
Enter a lower-case letter: u
Enter an integer: 0
The upper-case letter is 'U'
The opposite integer is '0'

You can assume that the user only enters valid input!

Hints:


Exercise #2: String transformation [0pts]

Write an assembly program called hw3_ex2, with source in file hw3_ex2.asm, that prompts the user for a 3-character string of lower-case letters, s1, and then for a 4-character string, s2. The program then prints, as part of a message, the following “encoded” string: s2[3] S1[0] S1[0] s2[2] S1[1] S1[1] s2[1] S1[2] S1[2] s2[0] (where “S1[i]” means the upper-case version of “s1[i]”).

For instance, if s1=”xyz” and s2=”aBcT”, the output should be “TXXcYYBZZa”.

Below are program invocation examples (‘%’ is the command-line prompt, and user input is shown as well). Your program should match that output format exactly:

./hw3_ex2
Enter a 3-character lower-case string: abc
Enter a 4-character string: #$%^
The encoded string is: ^AA%BB$CC#
% ./hw3_ex2
Enter a 3-character lower-case string: xyz
Enter a 4-character string: qwer
The encoded string is: rXXeYYwZZq
% ./hw3_ex2
Enter a 3-character lower-case string: yup
Enter a 4-character string: 1234
The encoded string is: 4YY3UU2PP1

You may assume that the user will always type exactly 3 lower-case characters for the first string followed by a carriage return (linefeed) and 4 characters for the second string followed by a carriage return (linefeed).

Even with our very limited knowledge of assembly, there are quite a few ways to write this program. And yes, because we can’t do loops yet, sections of code will have to be cut-and-pasted (which is very bad practice but unavoidable for now).

Hints:

EXTRA CREDIT: