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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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