Question: Computer Organization Homework 5 (100 points) Due: Nov 8, 11:59 PM, on Canvas NOTE: Please code your answers to the following questions and submit it



Computer Organization Homework 5 (100 points) Due: Nov 8, 11:59 PM, on Canvas NOTE: Please code your answers to the following questions and submit it on Canvas by Nov 8. This assignment is to be done individually, you can discuss the questions with your classmates, but you should write your answers independently. This assignment would be 30% of the total assignments prude 1. Division (36 points) Write an ANNA assembly program (div.ac) to divide two positive (non-xoro) numbers and print the quotient, remainder. Your program should take the numbers for division from user input NOTES: You can assume that both the numbers are positive and nonser The first number entered should be the numerator and the second number should be the denominator in the division. . Eg, if the user enters 20 and 10 as inputs (in the sequence), then the program should print 2.0(the quotient, and the remainder). Eg. 2, if the user enters 10 and 20 as inputs (in that sequence), then the program should print 0,10 (the quotient, and the remainder) Note that your program should print the quotient first followed by the remainder 2. XOR (30 points) In this question you will write an ANNA program to compute the XOR of two numbers. The output of XOR is one if and only if both the inputs are different, otherwise it is zero. The truth table for XOR is given below. Write an ANNA assembly program (xorac) that asks the user for two numbers greater than zero and returns the bitwise exclusive-OR (XOR) of the numbers. For instance, if the user types in 64 0000000001000000) and 100 (0000000001100100), the program should print 36 (0000000000100100), the bitwise XOR of the two numbers. Print -1 if the user entered a zero or less Hint: Consider using AND, OR, and NOT instructions for implementing the XOR operation A 0 0 1 1 B 0 1 0 1 A XORB 0 1 1 0 3. The five smallest numbers (40 points) Write an ANNA assembly program (smallest_five ac) that finds the five smallest numbers entered by the user. Initially, the program continually asks the user to enter numbers. As soon as a negative value is entered, compute which numbers are the top five (smallest) numbers. For instance, if the user entered 2,6,7,6,5,7,6, 17, 15.1; the program should print 2, 5,6,6,7 (the five smallest numbers in the sequence). If the user enters a negative number at the beginning, print 0. If the user enters five or fewer numbers, print all the numbers as output Notes: The goal of this problem is to exercise storing, retrieving, and scanning the numbers stored in memory. Therefore, a solution where you keep track of the smallest five numbers in registers as the numbers are entered is not acceptable. Such a solution will receive a maximum of 15 points for this problem. . Do not keep track of everything in the input loop. You will need to store all numbers entered by the user in memory Store all numbers entered into a growing array Note that the array should be the last item in your data section so it can grow as large as necessary. And your data section should be at the end of the code section. You may assume there is enough memory to hold all numbers entered by the user. Grading Requirements: The assignment will be graded on functionality, though students are encouraged to follow recommended programming style as well. For information on proper style, refer to section 5 of the ANNA guide. Programs that fail to assemble will receive a zero Functionality will be based primarily on a suite of tests. A program that fails to successfully pass many of the tests will receive a very low score. Testing and debugging are important part of the programming process. Students who fail to test and debug their programs are handing in incomplete work and their grade will suffer as a result. Submitting your Program Programs will be submitted electronically on Canvas. Please follow the steps carefully 1. Ensure the assembly code files have the proper names: Program 1: div.ac Program 2: xorac Program 3: smallest five.se 2. Submit the three assembly files on Canvas. Please submit all three files in a single zip file. . You may resubmit your assignment. If you do, please resubmit all three files (even if you changed only one). Only the last submission will be graded. Canvas will caly accept zip files. Computer Organization Homework 5 (100 points) Due: Nov 8, 11:59 PM, on Canvas NOTE: Please code your answers to the following questions and submit it on Canvas by Nov 8. This assignment is to be done individually, you can discuss the questions with your classmates, but you should write your answers independently. This assignment would be 30% of the total assignments prude 1. Division (36 points) Write an ANNA assembly program (div.ac) to divide two positive (non-xoro) numbers and print the quotient, remainder. Your program should take the numbers for division from user input NOTES: You can assume that both the numbers are positive and nonser The first number entered should be the numerator and the second number should be the denominator in the division. . Eg, if the user enters 20 and 10 as inputs (in the sequence), then the program should print 2.0(the quotient, and the remainder). Eg. 2, if the user enters 10 and 20 as inputs (in that sequence), then the program should print 0,10 (the quotient, and the remainder) Note that your program should print the quotient first followed by the remainder 2. XOR (30 points) In this question you will write an ANNA program to compute the XOR of two numbers. The output of XOR is one if and only if both the inputs are different, otherwise it is zero. The truth table for XOR is given below. Write an ANNA assembly program (xorac) that asks the user for two numbers greater than zero and returns the bitwise exclusive-OR (XOR) of the numbers. For instance, if the user types in 64 0000000001000000) and 100 (0000000001100100), the program should print 36 (0000000000100100), the bitwise XOR of the two numbers. Print -1 if the user entered a zero or less Hint: Consider using AND, OR, and NOT instructions for implementing the XOR operation A 0 0 1 1 B 0 1 0 1 A XORB 0 1 1 0 3. The five smallest numbers (40 points) Write an ANNA assembly program (smallest_five ac) that finds the five smallest numbers entered by the user. Initially, the program continually asks the user to enter numbers. As soon as a negative value is entered, compute which numbers are the top five (smallest) numbers. For instance, if the user entered 2,6,7,6,5,7,6, 17, 15.1; the program should print 2, 5,6,6,7 (the five smallest numbers in the sequence). If the user enters a negative number at the beginning, print 0. If the user enters five or fewer numbers, print all the numbers as output Notes: The goal of this problem is to exercise storing, retrieving, and scanning the numbers stored in memory. Therefore, a solution where you keep track of the smallest five numbers in registers as the numbers are entered is not acceptable. Such a solution will receive a maximum of 15 points for this problem. . Do not keep track of everything in the input loop. You will need to store all numbers entered by the user in memory Store all numbers entered into a growing array Note that the array should be the last item in your data section so it can grow as large as necessary. And your data section should be at the end of the code section. You may assume there is enough memory to hold all numbers entered by the user. Grading Requirements: The assignment will be graded on functionality, though students are encouraged to follow recommended programming style as well. For information on proper style, refer to section 5 of the ANNA guide. Programs that fail to assemble will receive a zero Functionality will be based primarily on a suite of tests. A program that fails to successfully pass many of the tests will receive a very low score. Testing and debugging are important part of the programming process. Students who fail to test and debug their programs are handing in incomplete work and their grade will suffer as a result. Submitting your Program Programs will be submitted electronically on Canvas. Please follow the steps carefully 1. Ensure the assembly code files have the proper names: Program 1: div.ac Program 2: xorac Program 3: smallest five.se 2. Submit the three assembly files on Canvas. Please submit all three files in a single zip file. . You may resubmit your assignment. If you do, please resubmit all three files (even if you changed only one). Only the last submission will be graded. Canvas will caly accept zip files
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
