Write a program in assembly language 8086 not 8085 to find t

Write a program in assembly language 8086 not 8085 to find the number of tows can be divisible on 2 of any number entered by the user ? Example: The user enter in register Bx = 80 mov bx, 80 80/2 = 40 40/2 = 20 20/2 = 10 10/2 = 5 5/2 = 2.5 Solution: The number of two is 4 Or can be found directly from equation below: 2^n * 5 = 80 Solution: n = 4

Solution

Solution :

The logic here is if a number is divisible by 2 , it will have 0 in the LSB.

If it is divisible by 2 , 2 times it will have two 0\'s in LSBs.

If it is divisible by 2 , n times it will have n 0\'s in the LSBs.

Examples

To find number of twos that divide the given number using 8086, We right shift the contents of the register in which the number is and the check carry flag for zero. We repeat until we get a one and count the number of times which will be required answer.

The code segment is given below

-----------------------------------------------------------------------------------------------

out_of_loop ------- ; code continues as required from here

----------------------------------------------------------------------------------------------------------------------------------

CX will contain the answer after exiting from loop.

 Write a program in assembly language 8086 not 8085 to find the number of tows can be divisible on 2 of any number entered by the user ? Example: The user enter

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site