Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write an ANNA assembly program (div.ac) to divide two positive (non-zero) numbers and print the quotient, remainder. Your program should take the numbers for
Write an ANNA assembly program (div.ac) to divide two positive (non-zero) 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 non-zero. The first number entered should be the numerator and the second number should be the denominator in the division. E.g., if the user enters 20 and 10 as inputs (in that sequence), then the program should print 2, 0 (the quotient, and the remainder). E.g. 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 (xor.ac) 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 XOR B 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.
Step by Step Solution
★★★★★
3.33 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
Here are the ANNA assembly programs for each of the three tasks Division divac section data numerator space 4 denominator space 4 quotient space 4 remainder space 4 section text global start start Dis...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started