Question: Assume that some processor (which uses multiplication very seldom and must use as less energy as possible) does not have hardware implementation of multipli-

Assume that some processor (which uses multiplication very seldom and must use as less energy as possible)

Assume that some processor (which uses multiplication very seldom and must use as less energy as possible) does not have hardware implementation of multipli- cation. Instead, when needed, it uses the following procedure (written in an easily understood pseudocode, for easier proof of correctness): procedure multiply(m.n : integers, return product: integers) if n < 0 then a := -n else a:= n; k:= 0; x := 0; while k < a do begin x :=x+m;k :=k+1; end; if n < 0 then product := -x else product :=x end of procedure Prove the correctness (i.e. product = m - n) and termination using Hoare triples.

Step by Step Solution

3.41 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Hoare triples can help us formally prove the correctness and termination of this multiplication proc... View full answer

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