Write an assemblylanguage program to reverse the bits in a b

Write an assembly-language program to reverse the bits in a byte. Your program should start by putting a known bit pattern into the low-order byte of DO, then reverse it, and then halt (so the reversed byte should end up in the low-order byte of DO). Hand in a trace of your program as in Assignment 2, and make sure that you dump the register values into the output of your trace before you save the trace into a text file for handing in. Your program must work with any bit pattern, but for the run you hand in your test byte should be 00100111_2. Your trace should not be too long, but if the algorithm you use generates a very long trace, just trace the first three or four dozen instructions and print that out. In any case, you should also hand in a listing of your program.

Solution

how it works: DH is a 1 which travels in the byte like first time: 00000001; second time 00000010and so on. When you make an AND with the AL you get 0 or something like 100or 10000 you have to shift that to the right to get it as 0 or 1. Then, put it in BH and shift to the desired position which is 7for byte 0, 6for byte 1and so on. Then OR to our final result and INC and DEC what is necessary. Do not forget the conditional jumps and to pop AX for the next loop

Result will be in CH.

 Write an assembly-language program to reverse the bits in a byte. Your program should start by putting a known bit pattern into the low-order byte of DO, then

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site