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 Use right shifts to divide the unsigned number
by Put the quotient in
Solution: To divide by two right shifts are needed. Since the divi
dend is unsigned, we use SHR The code is
Example If contains give the decimal value of after
SAR AL is performed.
Solution: Execution of SAR AL divides the number by and rounds
down. Dividing by yields and after rounding down we get
In terms of the binary contents, we have After shifting,
we have
Example Write a procedure FACTORIAL that will compute N for a
positive integer The procedure should receive in and return
in AX Suppose that overflow does not occur.
Solution: The definition of is
dots
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 bits.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
