I'm using MASM (although this code is coming from TASM).

In the .data section:
fsize dd ? ;Size of the file
org_val db ? ;The value to search for


In the .code section:
mov ecx,fsize
mov esi, offset org_val
mov al, byte ptr


Is it possible to replace the last two .code lines with mov esi, org_val, then mov al, esi?
Posted on 2010-07-05 13:10:30 by SyWiles
If you do that you'll end up loading in ESI a dword, but org_val is only a byte. the mov al, esi is not possible because the src operand size is smaller than dest. The real equivalent would be this:
mov ecx, fsize
mov al, org_val
(ESI will be no longer loaded with a known value though)
Posted on 2010-07-05 13:27:22 by LocoDelAssembly
Ok, I getcha.  Thanks.


Your second sentence, though, has me a little confused.  Wouldn't al be the dest and esi the source in mov al, esi?  Or am I worse off than I thought? :-)

Posted on 2010-07-05 18:05:05 by SyWiles
Your second sentence, though, has me a little confused.  Wouldn't al be the dest and esi the source in mov al, esi?  Or am I worse off than I thought? :-)
I'm definitely wrong here. Yes, ESI is the source here but the mismatched operands sizes problem still apply, AL is too small for ESI to fit in. Sometimes however, the processor allows mismatched sizes, for instance the MOVZX and MOVSX instructions which both allows a smaller (but not bigger) source.
Posted on 2010-07-05 20:09:52 by LocoDelAssembly
Ok.  Thanks for clearing everything up. :-)
Posted on 2010-07-05 20:32:25 by SyWiles