Question: Example 7 . 1 0 Use right shifts to divide the unsigned number 6 5 1 4 3 by 4 . Put the quotient in

Example 7.10 Use right shifts to divide the unsigned number 65143
by 4. Put the quotient in Ax.
Solution: To divide by 4, two right shifts are needed. Since the divi-
dend is unsigned, we use SHR. The code is
Example 7.11. If AL contains -15, give the decimal value of L after
SAR AL.,1 is performed.
Solution: Execution of SAR AL,1 divides the number by 2 and rounds
down. Dividing -15 by 2 yields -7.5, and after rounding down we get -8.
In terms of the binary contents, we have -15=11110001b. After shifting,
we have 11111000b=-8.
Example 9.7 Write a procedure FACTORIAL that will compute N! for a
positive integer N. The procedure should receive N in Cx and return N!
in AX. Suppose that overflow does not occur.
Solution: The definition of N! is
N1ifN=1
=N(N-1)(N-2)dots1ifN>1
Here is an algorithm: -
It can be coded as follows:
Here CX- is both loop counter and term; the LOOP instruction automatically
"decrements" it on" each" itratin through the loop. We assume the product
does not overflow 16 bits.
 Example 7.10 Use right shifts to divide the unsigned number 65143

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!