Question

One way to calculate the harmonic mean of two numbers x and y is using the...

One way to calculate the harmonic mean of two numbers x and y is using the expression (2xy) / (x + y) Using the windows32 framework, write a complete 80x86 assembly language program to prompt for and input two numbers and then calculate and display their harmonic mean in ddd.d format.

ASSEMBLY LANGUAGE
WINDOWS 32 FRAMEWORK

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Harmonic mean of two numbers x,y is given as 2xy/(x+y) so the basic basic approch for solving in assembly language code is //to calculate the numerator and denominator

//The ASSEMBLY CODE goes as follows

;Assembly function that computes the harmonic mean
;of an array of 64-bit floating-point numbers in 32 framework
;Retrieves input using a C program.
;
;Harmonic mean is defined as Sum(n/((1/x1) + (1/x2) + ... + (1/xn)))
;
;   expects:
;       RDI - address of array
;       RSI - length of the array
;   returns
;       XMMO - the harmonic average of array's values

global harmonicMean

section .data
    Zero dd 0.0
    One dd 1.0

section .text
    harmonicMean:
        push rbp
        mov rbp, rsp              ;C prologue

        movss xmm10, [Zero]       ;Holds tally of denominator
        cvtsi2ss xmm0, rsi        ;Take length and put it into xmm0 register

        .whileLoop:
            cmp rsi, 0            ;Is the length of array 0?
            je .endwhile
            call addDen           ;Compute a denominator value and add it to sum
            add rdi, 4            ;Add size of float to address
            dec rsi               ;Decrease the length
            jmp .whileLoop
        .endwhile:

        divss xmm0, xmm10

        leave
        ret


    ;Calculates a number in the denominator
    addDen:
        push rdi
        movss xmm8, [One]
        movss xmm9, [rdi]
        divss xmm8, xmm9
        addss xmm10, xmm8
        pop rdi
        ret
Add a comment
Know the answer?
Add Answer to:
One way to calculate the harmonic mean of two numbers x and y is using the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest...

    MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest common divisor of two positive numbers. . • Your program should read the two positive integers using dialog boxes. If they are not positive, a message box should be displayed with an appropriate message. • Your program needs to have a procedure that takes two positive integers as parameters. • You need to follow cdecl protocol for parameter passing. • Display the valid...

  • MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the...

    MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest common divisor of two positive numbers. . • Your program should read the two positive integers using dialog boxes. If they are not positive, a message box should be displayed with an appropriate message. • Your program needs to have a procedure that takes two positive integers as parameters. • You need to follow cdecl protocol for parameter passing. • Display the valid...

  • Using Assembly Language Easy68k only 2. Write two subroutines one for (X+Y) and next one is...

    Using Assembly Language Easy68k only 2. Write two subroutines one for (X+Y) and next one is for (X Y) and implement this equation (X+Y)(X*Y) in your program body with those returns received from subroutines

  • Give the solution using Python programming for following with explanations: a. Take two numbers and display...

    Give the solution using Python programming for following with explanations: a. Take two numbers and display which number is positive and which number is negative. b. Take two numbers divide and display quotient and reminder. c. Take two numbers and check if they are same or not same. a. Write four differences between high level language and low level language? b. Write all the rules of naming any variables in python and provide at least one example for each rule?...

  • Write a program in C++ to calculate the average (mean) and the standard deviation of a...

    Write a program in C++ to calculate the average (mean) and the standard deviation of a list of numbers using vectors. Your program should... Prompt for the number of values the user wishes to enter Prompt the user to enter the values one at a time for the number of requested values into a vector Calculate and display the Mean and Standard Deviation The flow of your code should be similar to: int main() { /** Prompt the user and...

  • a. write a program that calculates the sum of two numbers x and y and then...

    a. write a program that calculates the sum of two numbers x and y and then the program should call the function by address and prints the sum b. write a program that stores 10 integers provided at run time in an array. the program should prompt the user for a random integer exit in the array, the value must be replaced by a-1

  • You must write a C program that prompts the user for two numbers (no command line...

    You must write a C program that prompts the user for two numbers (no command line input) and multiplies them together using “a la russe” multiplication. The program must display your banner logo as part of a prompt to the user. The valid range of values is 0 to 6000. You may assume that the user will always enter numerical decimal format values. Your program should check this numerical range (including checking for negative numbers) and reprompt the user for...

  • 1. Write a C programme by using visual Studio: a) Write a function with parameters that...

    1. Write a C programme by using visual Studio: a) Write a function with parameters that returen the largest of three integer arguments. So users could call your function (name: max3) to output the maximum of three input values. b) Make a function outside of the main routine. And in the main routine, please call this function and print the harmonic mean. The harmonic mean of two numbers is obtained by taking the inverses of the two numbers, averaging them,...

  • Prompt the user for two numbers, call them "x" and "y". "x" must be less than...

    Prompt the user for two numbers, call them "x" and "y". "x" must be less than "y" or reject the entry and stop the program. Otherwise, add up all of the numbers between "x" and "y" and display the result. For example: Enter x: 10 Enter y, larger than x: 20 Total + 10 = 10 Total + 11 = 21 Total + 12 = 33 Total + 13 = 46 Total + 14 = 60 Total + 15 =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT