Question

In: Computer Science

In one instruction scan register BX from left to right for the position of the first...

In one instruction scan register BX from left to right for the position of the first 1 bit and

put the result (the position of the first bit 1) in register CX (only one instruction).

{hint: use from the instructions bsf, bsr, bt, btc, btr}

Solutions

Expert Solution

Answer: BSR CX,BX

Explanation: Since we need to scan the BX register from left to right for the position of the first 1(high) bit and put the result (the position of the first bit 1) in register CX as well, the most appropriate instruction for this process will be the BSR instruction.

This is because the BSR instruction stands for Bit Scan Reverse. The BSR instruction is one of the bits scanning instructions that work on a register and the purpose of BSR instruction is to scan a specific register in reverse manner that is from left to right (from 16th bit towards 0th bit) for the first high bit (1) and also put the position of the first 1 bit into an another register after scanning.

Note: 'Put the position of the bit' here means to simply copy the position of the first 1 bit into an another register.

The syntax for BSR instruction is:

BSR destination register, scan register

In this instruction, the first operand 'destination register' is the register into which we want to put the position of the first high (1) bit, and the second operand 'scan register' is the register that we want to scan for finding the position of the first 1 bit.

So now, as we are required to scan the BX register from left to right (means starting from 16th bit towards 0th bit) and put the position of first 1 bit into the CX register, it means that the BSR instruction will do this required job. The BX register is a 16-bit register with lower 8 bits (0-7) in the BL register and the upper 8 bits (8-15) in the BH register. So, the BSR instruction will scan the BX register from left to right, starting from 16th bit towards the 0th bit.

​​​​​So, the assembly instruction to scan the BX register from left to right for the position of the first 1(high) bit and put the result (the position of the first bit 1) in register CX is:

BSR CX,BX

Thanks!


Related Solutions

4- a) Draw a 4-Bit Shift Register that shifts from right to left instead of left...
4- a) Draw a 4-Bit Shift Register that shifts from right to left instead of left to right using D-Flip flops. b) Draw the serial transfer from shift register A on the right to the shift register B on the left in block form including the timing diagrammes. c) Draw the serial transfer table in the following form, assuming an initial value of 1101 in the register A and 0110 in the register B. Timing Pulse Shift Register B Shift...
A word that reads the same from left to right and right to left is a...
A word that reads the same from left to right and right to left is a palindrome. For example, "I", "noon" and "racecar" are palindromes. In the following, we consider palindromic integers. Note that the first digit of an integer cannot be 0. How many positive palindromic integers are 5-digit long and contain 7 or 8?
Write the Verilog code for a 12-bit shift register with ability to shift left or right,...
Write the Verilog code for a 12-bit shift register with ability to shift left or right, synchronized parallel load, asynchronous reset, and serial output? The register is able to load the 12-bit input value (at the positive edge of the clock) if the load signal is one, shift the value in register one bit to the right (at the positive edge of the clock) if the rss signal is one, shift the value in register one bit to the left(at...
The first ionization energies of the elements __________ as you go from left to right across...
The first ionization energies of the elements __________ as you go from left to right across a period of the periodic table, and __________ as you go from the bottom to the top of a group in the table.
1) Explain the oprerating principle of left-rotating, right rotating shift register by sketching the circuit and...
1) Explain the oprerating principle of left-rotating, right rotating shift register by sketching the circuit and timing diagram for 4-bit register configurations?
Suppose a particle is moving right and left in a straight line. Its position, in centimeters,...
Suppose a particle is moving right and left in a straight line. Its position, in centimeters, at time t seconds is given by the function s(t) = −t3 + 12t2 − 21t. (For the purposes of this problem, assume that t ≥ 0.) (a) At what t-values is the particle stopped (that is, has a velocity of zero)? (b) Over what time interval(s) is the particle moving left? (c) Find the acceleration of the object when t = 4.
Suppose a particle is moving right and left in a straight line. Its position, in centimeters,...
Suppose a particle is moving right and left in a straight line. Its position, in centimeters, at time t seconds is given by the function s(t) = −t^3+ 12t^2 − 21t. (For the purposes of this problem, assume that t ≥ 0.) (a) At what t-values is the particle stopped (that is, has a velocity of zero)? (b) Over what time interval(s) is the particle moving left? c) Find the acceleration of the object when t = 4.
A palindromic number reads the same both ways (left-to-right and right-to-left). The largest palindrome made from...
A palindromic number reads the same both ways (left-to-right and right-to-left). The largest palindrome made from the product of two 2-digit numbers is 9,009 = 91 × 99. The largest palindrome made from the product of two 3-digit numbers is 906,609 = 913 × 993. The largest palindrome made from the product of two 4-digit numbers is 99,000,099 = 9,901 × 9,999. 1. Write a function IN JAVASCRIPT to find the largest palindrome made from the product of two 7-digit...
1.In the human heart, blood is pumped from the left ventricle into the left atrium. right...
1.In the human heart, blood is pumped from the left ventricle into the left atrium. right atrium. pulmonary circuit. systemic circuit. 2.Systolic pressure is Group of answer choices the lowest blood pressure in the aorta. the pressure measured when the left ventricle is relaxed. the peak pressure in the aorta when the left ventricle contracts. the difference between the highest and lowest pressures. an average of high and low pressures. 3.The diastolic pressure for a normal young adult would be...
Choose the one item on the right that best relates to the item on the left....
Choose the one item on the right that best relates to the item on the left. Each answer choice is only used once.       -       A.       B.       C.       D.       E.       F.       G.       H.       I.       J.       K.       L.    Numerous synapses to control which action potentials reach the cortex       -       A.   ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT