I am required to write a program in ARM assembly language that takes an integer as input and returns the integer value of that integer times 6.985. For example, if 36 is entered as input then the result will be 251.
I can only use the built in function add (which adds two integers), mul (which multiplies two integers), divide (which divides two integers), getnum (which gets an integer as input from user), and printnum (which prints the output into the screen). My approach is to first multiply by 6985 and then divide by 1000.
Here's my code for the mul function:
bl getnum
mul r0, r0, #6985
bl printnum
Here's my code for the divide function:
bl getnum
mov r1, #1000
bl divide
mov r4, r0
mov r5, r1
bl printnum
mov r0, r5
bl printnum
My question is how can I combine the two method so that it performs multiplication and division at once? I am still new to this language so I don't know how to get rid of the getnum in the divide function and combine it with the mul function.
mul
for division part. (and if you go with the powers of 2, try what max number can be multiplied before it overflows) – Ped7g