sign extension in assembly
pgbpsu
Posts: 460
How do I extend the sign of a 24-bit 2's complement number to 32-bits in assembly? I know that assembly has commands for doing signed and unsigned addition, but that's not quite the whole problem. I need to get my high bit dragged all the way out to 32. I'm adding 8 signed 24-bit numbers then dividing (shifting by 3) to get the average.
It took me a long time to figure out why the output was screwed up when the signal crossed zero. I've traced the problem to the sign bit not being the highest bit in the variable's register but don't know how to solve it.
Do any of the seasoned programmers here have suggestions. And of course, since I'm doing all this in assembly it needs to be fast.
Thanks,
Peter
It took me a long time to figure out why the output was screwed up when the signal crossed zero. I've traced the problem to the sign bit not being the highest bit in the variable's register but don't know how to solve it.
Do any of the seasoned programmers here have suggestions. And of course, since I'm doing all this in assembly it needs to be fast.
Thanks,
Peter
Comments
-Phil
There are other possibilities... Look how Beau did it (faster if you had no barrel shifter).: http://forums.parallax.com/showthread.php?p=707546
Finally a question NOT answered by deSilva's tutorial! [noparse];)[/noparse]
Thanks,
pb