Question: I have the following code however if you run it you can see the output is not correct. additionally my instructor has left some feedback

I have the following code however if you run it you can see the output is not correct. additionally my instructor has left some feedback which i will paste in here along with the desired output. this is in ARMv7 assembly.
INSTRUCTOR FEEDBACK:
This not from this class:
PUSH / POP
MOVEQ r4, #+43
MOVNE r4, #45
"%c1.%023b E%+d
"
POP {r4-r11, pc}we use BX LR for a return.
Do not waste a protected register to carry an index..R12 is a much better choice.
LDR r5,=float_input
LDR r6,[r5]
You used protected registers in other cases unnecessarily.
Only read the value from memory once into a protected register (you did R6). Then MOV or VMOV it from R6 when you need it. When it is sitting in R6 it already is a floating point number. You don't need to run it through VFP registers unless you need to VPF math!
The function call
BL decode_float
should have 1 parameters. It is held in R0. Or if you want to also print the string, that address could be held in R1. And skip the multiple format support. Just alwaysdo single.
S0 is not a protected registers:
VMOV r7, s0
CMP r7, #0
BUT you have the value in R6...so use it from there. just
CMP R6, #0
decode_float is about displaying the bits. Do the math in main and pass the value into this function to be displayed.
Save protected registers. Then save the inout parameter R0 in a protected registers.
Then check the sign bit and print "+1." or "-1."
Then extract the 23 bits for the fraction. Shift and print each bit.
Then extract he exponent, sub tract the offset. The print with a %d format string "E%d"
DESIRED OUTPUT: This program will input and decode an IEEE-754 Floating Point Numbers.
It will square the number and decode it. Next, if possible, it will take
the square root of the number and decode it. This will repeat until the
user enters Zero.
Enter the single precision floating point value (0 to exit): 0.75
The initial value is: +1.10000000000000000000000 E-1
The value squared is: +1.00100000000000000000000 E-1
The root of the value is: +1.10111011011001111010111 E-1
Enter the single precision floating point value (0 to exit): 4
The initial value is:+1.00000000000000000000000 E2
The value squared is: +1.00000000000000000000000 E4
The root of the value is: +1.00000000000000000000000 E1
Enter the single precision floating point value (0 to exit): -256
The initial value is: -1.00000000000000000000000 E8
The value squared is: +1.00000000000000000000000 E16
Enter the single precision floating point value (0 to exit): 0
FloatDecode > Asm FloatDecode.s
1.global main
.extern printf
.extern scanf
.section .data
.align 4
prompt: .asciz "Enter the single precision floating point value (0 to exit): "
initial_msg: .asciz "The initial value is: %c1.%023b E%+d
"
squared_msg: .asciz "The value squared is: %c1.%023b E%+d
"
root_msg: .asciz "The root of the value is: %c1.%023b E%+d
"
fmt: .asciz "%f"
.section .bss
.align 4
float_input: .skip 4 @ Allocate 4 bytes, aligned to 4 bytes
.section .text
main:
// Main program loop
// Displays prompt, reads input, processes and displays results
// Input: None
// Output: Displays formatted results based on user input
// Exits when 0 is entered.
PUSH {r4-r11, lr}
\vee input_loop:
// Display the input prompt
// Input: None
// Output: Displays "Enter the single precision floating point value (0 to exit): "
LDR r0,=prompt
BL printf
// Read floating-point input
// Input: User input in floating-point format
// Output: Stores input value in float_input
LDR r\theta,=fmt @@ Load format string
LDR r1,=float_input @ Load address of float_input
BL scanf
// Check input value for exit condition (0 to exit)
// Input: Value stored at float_input
// Output: Exits if value is 0, else continues processing
LDR r5,=float_input
LDR r6,[r5] @@ Load value from float_input into r6
CMP r6, #0
BEQ end_program @ Exit if zero entered
// Load the input value to floating-point register (s0)
I have the following code however if you run it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!