Calculate the harmonic mean of two numbers

Assignment Help C/C++ Programming
Reference no: EM132583610 , Length: 6 pages

Problem Set

Question 1. Give the op code and number of bytes of code for each of these instructions.

(a) mov ecx, 984 Op Code______ Number of Bytes _____

(b) xchgeax, ecx Op Code______ Number of Bytes _____

(c) add eax, ecx Op Code______ Number of Bytes _____

(d) add eax, value Op Code______ Number of Bytes _____
(assume value references a doubleword in memory)

(e) incedx Op Code______ Number of Bytes _____

(f) inc DWORD PTR [edx] Op Code______ Number of Bytes _____

(g) neg value Op Code______ Number of Bytes _____
(assume value references a doubleword in memory)

(h) neg edx Op Code______ Number of Bytes _____

(i) neg DWORD PTR [edx] Op Code______ Number of Bytes _____

(j) add ecx, 894 Op Code______ Number of Bytes _____

(k) imuleax, ecx Op Code______ Number of Bytes _____

(l) div value Op Code______ Number of Bytes _____
(assume value references a doubleword in memory)

(m) div DWORD PTR [edx] Op Code______ Number of Bytes _____

(n) cdq Op Code______ Number of Bytes _____

Question 2. Each of these problems gives "before" conditions and an instruction. Give the indicated "after" state of the indicated registers and flags as appropriate.

Before Instruction executed After
(a) ECX: 00 00 BF 7A mov ecx, -89 ECX

(b) ECX: 00 00 BF 7A mov ecx, 984 ECX

(c) EAX: 12 34 56 78
EDX: 9A BC DE F0 xchg ax, dx EAX

EDX

(d) EAX: FF FFFF C8 add eax, 56 EAX
SF __ ZF__ CF__ OF__

(e) EDX: 00 00 02 E9 incedx EDX
SF __ ZF__

(f) EBX: FF FFFF 3B neg ebx EBX
SF __ ZF__

(g) EAX: 01 23 45 67
ECX: 89 AB CD EF sub eax, ecx EAX
SF __ ZF__ CF__ OF__

(h) AX: 12 34
CX: 7A BC
CF:1 adc ax, cx AX

CX
SF __ ZF__ CF__ OF__

(i) EAX: 00 00 00 0A
EBX: FF FFFF FC
EDX: FF 03 FF 01 imulebx EAX

EDX
CF,OF __
(j) EAX: 00 00 00 10
ECX: FF FFFF FD
EDX: FF 03 FF 01 mulecx EAX

EDX
CF,OF __
(k)
EAX: 00 00 00 0A
EBX: 00 00 00 0C
EDX: FF 03 FF 01 imuleax,ebx EAX

EDX
CF,OF __

(l) EAX: 00 00 0E AA
ECX: 00 00 00 1B
EDX: 00 00 00 00 div ecx EAX

EDX


(m) EAX: 00 00 0F CA
EBX: 00 00 00 0D
EDX: 00 00 00 00 idivebx EAX

EDX

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

2xy/(x+y)

Complete the following windows32program to input two numbers and calculate and display their harmonic mean in dddd.dd format. The boxed areas indicate where code is missing.

; student's name here
; program to input two numbers,
; then calculate and display their harmonic mean
; current date here

.586
.MODEL FLAT

INCLUDE io.h ; header file for input/output

.STACK 4096

.DATA
x DWORD ?
y DWORD ?
prompt1 BYTE "First number", 0
prompt2 BYTE "Second number", 0
inArea BYTE 20 DUP (?)
mean BYTE 11 DUP (?), 0
meanLbl BYTE "Harmonic mean", 0
meanOut BYTE 4 DUP(?), '.', 2 DUP (?), 0

.CODE
_MainProc PROC
input prompt1, inArea, 20 ; read ASCII characters
atod inArea ; convert to integer
mov x, eax ; store in memory

; repeat for second number

; calculate 100*(harmonic mean)in EAX

dtoa mean, eax ; convert to ASCII characters

; copy digits, one at a time to meanOut

; output label and mean

mov eax, 0 ; exit with return code 0
ret
_MainProc ENDP
END ; end of source code

Question 4. Starting with the windows32 framework, write a complete program that will input values for a, b and c and display the value of the expression
(a+b*c)/(2*b)

Input and output must be consistent with the samples shown below. Include full source code with comments and screenshots of working program. Expression value can be rounded down to the whole number to avoid fractional outputs. If you are super motivated, challenge youself to print the expression in its more accurate decimal (fractional) format. In the example below, that value would be 8.9 and not 8. That, however, is an optional feature.

Reference no: EM132583610

Questions Cloud

Principles of finance and accounting to healthcare outcomes : Apply principles of finance and accounting to healthcare outcomes, reimbursements, and business operations.
Prepare financial budget : Prepare a financial budget that supports improved business and patient outcomes.
Write a function in R to perform the linear regression : Write a function in R to perform the linear regression. You are not allowed to use any linear regression specific functions or any package
Finance-economics in management of health systems : Compare and contrast the role of finance and economics in the management of health systems in the U.S. and international markets.
Calculate the harmonic mean of two numbers : Calculate the harmonic mean of two numbers x and y is using the expression and calculate and display their harmonic mean in dddd.dd format.
Develop population health plan : Develop a population health plan to address a health concern in the current healthcare industry.
Categorical-hierarchical and relational : Categorical: Comparing categories and distributions of quantities values, Hierarchical: Charting part-to-whole relationships and hierarchies
Discuss the role of the therapist : Discuss the role of the therapist and perceptions of the therapist's responsibility for change when using a strategic family therapy model;
Perform a more in-depth static code analysis : What type of covert launching do you initially suspect of this malware performing (direct injection, dll injection, hook injection, APC injection, or process

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Define how stack template works

Even though the program runs correctly, there is a memory problem somewhere in the program and I can't figure out what I have done wrong.

  Create a job class that holds a job id

Create a Job class that holds a Job ID number and the cost of the Job. Include insertion and extraction operators. Create a JobException class that holds a Job and an error message

  Write a program named averages

Write a program named Averages that includes a method that accepts any number of numeric parameters, displays them, and displays their average.

  C++ program that takes temperature as input

Create a C++ program that takes temperature as input and provides as output your sports decision. Assume that temperatures are only expressed as integers. In the program, include 2 void functions titled getTemp and printActivity, each with an int ..

  Write a program that computes the sum of all the odd numbers

Write a program that computes the sum of all the odd numbers between 1 and 99. Write a program that loads a word into register $8.

  Create two int variables x and y and initialize them

Create two int variables x and y and initialize them to 5 and 10 respectively. Create two int pointers, ptr1 and ptr2, and initialize them to point to x and y.

  Calculate the average of three exams for five students

This program will calculate the average of 3 exams for 5 students. The program will ask the user to enter 5 student names.

  Write a program that creates an arraylist

Write a program that creates an ArrayList and adds a Loan Object, a Date Object, a string, JFrame object, and a circle object to the list, and use a loop to display all the elements in the list by invoking the object's toString() method.

  Program to print out the values and their counts

So we read in each number and add the number to an ordered linked list. If we are adding a number to the list and we find that number, then we will just count it. If we do not find the number in the linked list, then we will add a new node to the ..

  Definition of two queues

Write a code in C language for the definition of two queues, one to hold the process in ready state and one to hold the process in waiting state.

  Searching f and removing certain states from the hash table

use the class hashT, ''Hashing: Implementation Using Quadratic Probing,'' which uses quadratic probing to resolve collision, to create a hash table to keep track of each state's information. Use the state's name as the key to determine the hash addre..

  Create a random sample of size 1000 from the diamonds data

Create a random sample of size 1000 from the diamonds data. Draw the scatterplot of carat vs log(price), color coded by cut.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd