The assignment will be graded out of 100 points. Submit your source code for each task, in files called task1.s, task2.s, and so on. Submit your solutions to Blackboard before the deadline. You will be able to revise your answers until the deadline with no penalty.
For all tasks of this assignment you should follow these general guidelines.
- For each task, you are provided with a partial solution. In this partial solution there is a line that says "Your code starts here" and a line that says "Your code ends here". You are only allowed to place your code between those lines. You are not allowed to modify any other part of the partial solution.
- The partial solution that you are provided for each task starts by waiting for the user to enter one or two integers (depending on the task). To enter an integer, you should type an optional minus sign at the beginning, followed by decimal digits, followed by <ENTER>. There should be no spaces or other characters. Do not worry about what the program does if spaces or other characters are placed here.
- Each task specifies the ranges of legal integer values that you should worry about. Do not worry about what your program will do for values outside those ranges.
- Each task specifies exactly what each character of the output should look like. Your solution needs to match the output specifications character by character (no differences in capitalization, more or fewer spaces, more or fewer empty lines).
Task 1 (10 points)
Complete this task1.s code to produce an assembly program that:
- Waits for the user to enter two integers (this part is already coded in).
- Places the first integer at r5, and the second integer at r6 (this part is already coded in).
- (This is what you need to code in) Prints out the character for each ASCII code from the first integer up to (and including) the second integer, assuming that:
- The integer at r5 is not smaller than 32 and not larger than 127.
- The integer at r6 is not smaller than the integer at r5, and not larger than 127.
Each character should be on its own line.
For example, if the first integer is 80 and the second integer is 86, your output should look exactly like this:
80
86
P
Q
R
S
T
U
V
END
Task 2 (20 points)
Consider the following code in C:
int i;
for (i = r5; i <= r6; i++)
{
if (i == 24) printf("24\n");
else if (i == 27) printf("27\n");
else printf("z\n");
}
Complete this task2.s code to produce an assembly program that:
- Waits for the user to enter two integers (this part is already coded in).
- Places the first integer at r5, and the second integer at r6 (this part is already coded in).
- (This is what you need to code in) Produces the exact same output as the C code would produce, assuming that:
- The integer at r5 is not smaller than 15 and not larger than 32.
- The integer at r6 is not smaller than the integer at r5, and not larger than 32.
- Variables r5 and r6 in the C code have the same values as the registers r5 and r6 have received.
For example, if the first integer is 20 and the second integer is 30, your output should look exactly like this:
20
30
z
z
z
z
24
z
z
27
z
z
z
END
Task 3 (10 points)
Complete this task3.s code to produce an assembly program that:
- Waits for the user to enter two integers (this part is already coded in).
- Places the first integer at r5, and the second integer at r6 (this part is already coded in).
- (This is what you need to code in) Prints out in hexadecimal all multiples of 7, starting from (and including) the first integer up to (and including if needed) the second integer, assuming that:
- The integer at r5 is a multiple of 7, is not smaller than 0 and not larger than 255.
- The integer at r6 is not smaller than the integer at r5, and not larger than 255.
Each number should be printed in hexadecimal, on a separate line, with no leading zeros. For example, if the first integer is 0 and the second integer is 45, your output should look exactly like this:
0
45
0
7
E
15
1C
23
2A
END
Task 4 (20 points)
Complete this task4.s code to produce an assembly program that:
- Waits for the user to enter two integers (this part is already coded in).
- Places the first integer at r5, and the second integer at r6 (this part is already coded in).
- (This is what you need to code in) Prints out in hexadecimal all multiples of 345, starting from (and including) the first integer up to (and including if needed) the second integer, assuming that:
- The integer at r5 is a multiple of 345, is not smaller than 0 and not larger than 3000.
- The integer at r6 is not smaller than the integer at r5, and not larger than 3000.
Each number should be printed in hexadecimal, on a separate line, with no leading zeros. For example, if the first integer is 345 and the second integer is 2000, your output should look exactly like this:
345
2000
159
2B2
40B
564
6BD
END
Task 5 (40 points)
Complete this task5.s code to produce an assembly program that:
- Waits for the user to enter one integer (this part is already coded in). For this task, any valid 32-bit integer (positive or negative) can be entered.
- Places the integer at r1 (this part is already coded in).
- (This is what you need to code in) If r1 holds a value between -299 and 299, the program prints out that value in decimal. If r1 holds a value less than -299, your program should print "< -299". If r1 holds a value greater than 299, your program should print "> 299".
For example:
- If the user types in -5402, your output should look exactly like this:
-5402
< -299
END
- If the user types in -52, your output should look exactly like this:
-52
-52
END
- If the user types in 2, your output should look exactly like this:
2
2
END
- If the user types in 5402, your output should look exactly like this:
5402
> 299
END
Back to the list of assignments.