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. Each task specifies whether you should include only functions, or submit the entire program. Submit your solutions to Blackboard before the deadline. You will be able to revise your answers until the deadline with no penalty.
IMPORTANT: By submitting your answers, you are certifying that you have followed the UTA standards of academic integrity, and that these answers have been exclusively your own work. All students enrolled in this course are expected to adhere to the UT Arlington Honor Code:
I pledge, on my honor, to uphold UT Arlington's tradition of academic integrity, a tradition that values hard work and honest effort in the pursuit of academic excellence. I promise that I will submit only work that I personally create or contribute to group collaborations, and I will appropriately reference any work from other sources. I will follow the highest standards of integrity and uphold the spirit of the Honor Code.
/* ASCII-based comparison of the two strings. * Return values: * 0, if the two srings have the same contents. * less than 0, if the ASCII code of s1 is less than the ASCII code * of s2 at the first position where s1 and s2 differ. * greater than 0, if the ASCII code of s1 is greater than the ASCII code * of s2 at the first position where s1 and s2 differ. */ int strcmp(char * s1, char * s2) { int counter = 0; while (s1[counter] != 0) { if (s1[counter] != s2[counter]) { break; } counter++; } return s1[counter] - s2[counter]; }Implement this function in assembly. Submit a file task1.s that includes ONLY your definition of the function (and possibly other functions that you are using), but NOT the main program.
string_to_int
that takes as argument a string (i.e., the argument is the memory address to the first character of the string), and, assuming that the string is a valid representation of an integer in decimal, converts that string into the corresponding integer. This function returns two values, in registers r0 and r1:
Remember, all strings are terminated with the null character (which has ASCII code 0).
Submit a file task2.s that includes ONLY your definition of the function (and possibly other functions that you are using), but NOT the main program.
+ N
- N
* N
/ N
^ N
% N
q
get_line
: This function gets a line of input from the user. Note how function get_line
is called, by passing as an argument an address that holds enough space for 1000 characters.
div
(author: Brandon Lawrence): This function takes two numbers M and N as arguments (M goes to r0, N goes to r1) and produces two results: r0 = M/N, r1 = M mod N. For simplicity, we ignore divisions by zero and we define M/0 = 0.
The following text displays input and output for an example run of my solution. Given the same input as shown here, your program output should match EXACTLY the output shown here (even the white spaces should match).
Starting calculator program Accumulator = 0 +25 invalid string Accumulator = 0 + 25 Accumulator = 25 + -10 Accumulator = 15 - -1 Accumulator = 16 ^ 3 Accumulator = 4096 % 1000 Accumulator = 96 / 30 Accumulator = 3 * 7 Accumulator = 21 ^ -8 Accumulator = 21 * -4 Accumulator = -84 Hello invalid string Accumulator = -84 & 0 invalid string Accumulator = -84 quit invalid string Accumulator = -84 q Exiting calculator
Submit a complete program, that includes all the functions you are using.
Back to the list of assignments.