Reputation: 179
hi I have this data arr1 WORD 1234h, 0abh, 5678h
, I am trying to set the last 2 elements of this array to 0 so I did this mov BYTE PTR edi+2, 0
, however I get an error saying invalid use of register, why did this eror show up, I did the same thing with the memory operand and there was no error
thank in advance
Upvotes: 0
Views: 1421
Reputation: 58467
You don't mention which assembler you're using, but based on your use of BYTE PTR
I'm going to assume TASM or MASM.
Your array is an array of words, so to set the last 2 elements to zero you need to write 2 words (or 1 dword), rather than 1 byte like you're trying to do.
This ought to work (assuming that EDI
contains the address of arr1
):
mov word ptr [edi+2],0
mov word ptr [edi+4],0
or
mov dword ptr [edi+2],0
Upvotes: 2