Question: need help to fix my compute function in assembly language the correct calculations suppose to be in the second picture that has those results (3,26,12,4,0,4,6,0,16,67,5,27,115)

need help to fix my compute function in assembly language
the correct calculations suppose to be in the second picture that has those results (3,26,12,4,0,4,6,0,16,67,5,27,115)
.global main
.text
main:
push %rbx
mov $0, %r15 #initialize a counter %r15 to 0, and use this counter to get the element of the array
mov $0, %r14 #reset the counter
repeat:
cmp $13, %r14 #compare the counter to 13
je done
# Load the four elemants into their respective registerers.
mov %r14, %r15
mov array(,%r15,8), %rdi # Move array + (r15 * 8) and save the result in rdi
INC %r15
mov array(,%r15,8), %rsi # Move array + (r15 * 8) and save the result in rsi
INC %r15
mov array(,%r15,8), %rdx # Move array + (r15 * 8) and save the result in rdx
INC %r15
mov array(,%r15,8), %rcx # Move array + (r15 * 8) and save the result in rcx
call compute # Call the compute function
mov %rax, %r9
mov %rcx, %r8
mov %rdx, %rcx
mov %rsi, %rdx
mov %rdi, %rsi
mov $print_calculation, %rdi
mov $0, %rax
call printf
INC %r14
jmp repeat # Jump back to the start of the loop
compute:
#Calculates ((W * X) - (Y / Z)) / 8
# W in %rdi, X in %rsi, Y in %rdx, Z in %rcx
push %rdx # For stake puropse
mov %rdi, %rax # Move W into %rax
mul %rsi # Multiply %rax with X
mov %rax, %r11
mov %rdx, %rax
mov $0, %rdx
div %rcx
mov %rax, %r13
sub %r11, %r13
mov $8, %r12
mov $0, %rdx
mov %r11, %rax
div %r12
pop %rdx
ret # Back to the caller
done:
mov $60, %rax
mov $0, %rdi
pop %rbx
syscall
.data
array: .quad 2,15,14,7,5,2,18,3,3,45,12,4,55,17,108,9
print_calculation: .ascii "((%d * %d) - (%d / %d)) / 8 = %d "
need help to fix my compute function in assembly language the correct
calculations suppose to be in the second picture that has those results

((215)(14/7))/8=3((1514)(7/5))/8=26((147)(5/2))/8=12((75)(2/18))/8=4((52)(18/3))/8=0((218)(3/3))/8=4((183)(3/45))/8=6((33)(45/12))/8=0((345)(12/4))/8=16((4512)(4/55))/8=67((124)(55/17))/8=5((455)(17/108))/8=27((5517)(108/9))/8=115 ((215)(14/7))/8=3((1514)(7/5))/8=26((147)(5/2))/8=12((75)(2/18))/8=4((52)(18/3))/8=1((218)(3/3))/8=4((183)(3/45))/8=6((33)(45/12))/8=1((345)(12/4))/8=16((4512)(4/55))/8=67((124)(55/17))/8=6((455)(17/108))/8=27((5517)(108/9))/8=116

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 Databases Questions!