Size Specifier Place in Operations

9 views
Skip to first unread message

Fabio D'Alfonso

unread,
Jul 24, 2014, 4:51:06 AM7/24/14
to linu...@googlegroups.com
Hi,
As far as I can understand the  instructions:

mov dword [HexStr],  'G'

mov [HexStr], dword  'G'

mov dword [HexStr], dword  'G'

work and do the same.

Are this corrects ? And what could the better representing (the 3rd is just to overload more) 

I will check but I think they will end up to the very same opcode.

Thanks

--
Fabio D'Alfonso
cell. 348.059.40.22
email: fabio.d...@gmail.com

Fabio D'Alfonso

unread,
Jul 24, 2014, 2:39:03 PM7/24/14
to jeff, linu...@googlegroups.com
Hi Jeff,
that was just playing to see that I am altering more than I am actually putting (explicitly) , so the reason for the size specifier to be there.

While the instructions above produce the same opcode with specifier on the right or the left, Frank Kotler was pointing at this

movzx eax, byte [ebx] where the size specifier needs to be at the source operand.

This with

mov  eax, byte [ebx]

gives an error as the size comes from the destination register.

This:
movzx byte eax, [ebx]

gives a warning for byte and error for missing size specifier (on the source op)

this works
mov  eax, [ebx]

Any way, as of my minimal knowledge, if the destination is a register, you are using the register size to tell how much you are storing. That works for mov while is the opposite for movzx where there is a need to put the size specifier before the source operand, where in mov is an error.

I will try to figure myself what is that requires movzx a size specifier on the source operand.

Thanks
Fabio


On Thu, Jul 24, 2014 at 6:54 PM, jeff <linu...@gmail.com> wrote:
On 07/24/2014 01:51 AM, Fabio D'Alfonso wrote:
Hi,
As far as I can understand the  instructions:

mov dword [HexStr],  'G'

mov [HexStr], dword  'G'

mov dword [HexStr], dword  'G'

work and do the same.

Are this corrects ?

This is a confusing way to put a 4 byte literal (ascii values) in memory. Better would be
to define the dword completly. Example:


mov [HexStr], dword 'G   '

or

mov [HexStr], dword 'xxxG'

Probably what  you want is to only store a byte value: mov [HexStr], byte 'G'

all the best, Jeff


Reply all
Reply to author
Forward
0 new messages