Write an assembly program that converts a 32bit integer stor
Write an assembly program that converts a 32-bit integer stored in the memory from little endian to big endian, without using the REV instruction. Make sure the saved back to the memory.
Solution
For 80486 and later, there\'s an instruction called bswap that swaps bytes in a dword.
For older 80386 CPUs I\'d be tempted to use something like this:
For even older CPUs (8086 to 80286) you have to use a pair of 16-bit registers (as there are no 32-bit registers), and it ends up like this:
Note: Instead of using xchg ah,al you could use either ror ax,8 or rol ax,8.
