In one part of my application i need read a bytes
invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT, eax; eax = size
mov hMemory,eax
invoke GlobalLock,hMemory
mov pMemory,eax
How can "move" the first 4 bytes of pMemory to eax?? and later move the next 2 bytes to ebx??
Example:
1A5288.... 12 34 56 78 12 34
so
eax = 12345678
ebx = 00001234
According to your example you are fighting with the "little endian" byte order. A byte sequence of
12 34 56 78
is loaded into a 32-bit register as78563412
. You can reverse the byte order in a 32/64-bit register withBSWAP
. In the second case you need to reverse the byte order in the lower two bytes of the 32-bit register. Here isXCHG
orROR 8 | ROL 8
the appropriate instruction.Example: