Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this assignment, you will program a simple calculator for the Raspbian OS usi

ID: 3912375 • Letter: I

Question

In this assignment, you will program a simple calculator for the Raspbian OS using ARM assembly. Your program, at a minimum, will consist of the following procedure calls: SUM: Adds registers R1 and R2, returning result in register R0. DIFFERENCE: Subtracts register R2 from R1, returning result in register R0. PRODUCT: Multiplies registers R1 and R2, returning the result in register R0. MIN: Compares registers R1 and R2, returning the minimum of the two values in R0. Your main function will contain a loop that continuously checks for keyboard input in the following pattern: Where can be any of the four characters {+,-,*,m}. Once the 3 lines of input are acquired, the operands should be loaded into the proper registers and the procedure corresponding to should be called. The procedure should return the result in register R0, and the main function should print the value to the console and skip to a new line. You may ignore overflows, underflows, and improperly formatted input. All input test cases will consist of positive numbers only. Below are some example use cases: 5 100 5 50 + m * - 15 200 20 20 20 <-result 100 100 30 Points will be assigned as follows: 1. Main function correctly retrieves 3 input parameters, prints result in a continuous loop 2. SUM, DIFFERENCE, PRODUCT, MIN procedures implemented 3. SUM, DIFFERENCE, PRODUCT, MIN procedures return correct values on all test cases

Explanation / Answer

.data prompt0: .asciz "Please enter number1: operator: (add: +, sub: -, or multiply: *) then number2: " get0: .asciz "%d" get1: .asciz "%s" prompt1: .asciz "%d %c %d = %d " .align 4 .text .global main .extern scanf, printf, exit main: nop

output e.g.: