I need to divide the sum of two arrays, but it results in a float number (0.73). How would I go about dividing two variables and storing the float number in register. Then multiplying the float number by 100 to turn it into an integer (73). The following results in EAX = 00000000
.386
.model flat, stdcall
.stack 4096
ExitProcess PROTO, dwExitCode: DWORD
.data
AR1 DB 25, 89, 49, 80
AR2 DB 30, 100, 50, 150
AR1_SUM DWORD 0 ; variable to store the sum of AR1 elements
AR2_SUM DWORD 0 ; variable to store the sum of AR2 elements
.code
_main PROC
mov esi, offset AR1 ; set ESI to point to the first element of AR1
mov ecx, 4 ; reset the loop counter
xor edx, edx ;
addloop1:
add dl, [esi] ; add the current byte to the sum
add esi, 1 ; move to the next byte in AR1
loop addloop1 ; repeat until all elements in AR1 have been added
mov AR1_SUM, edx
mov esi, offset AR2 ; set ESI to point to the first element of AR2
mov ecx, 4 ; reset the loop counter
xor edx, edx ; reset the sum register for AR2
addloop2:
add dl, [esi]
adc dh, 0
add esi, 1 ; move to the next byte in AR2
loop addloop2 ; repeat until all elements in AR2 have been added
mov AR2_SUM, edx ; store the sum of AR2 in AR2_SUM
mov eax, AR1_SUM
mov ebx, AR2_SUM
xor edx, edx
div ebx
INVOKE ExitProcess, 0
_main ENDP
END _main