The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: jj2007 on May 26, 2011, 08:41:39 PM

Title: stosd
Post by: jj2007 on May 26, 2011, 08:41:39 PM
Just for fun :bg

include \masm32\include\masm32rt.inc

.data
MyDwords dd 123, 456, 789

.code
start: mov edi, offset MyDwords[4]
mov eax, 111
stos MyDwords
MsgBox 0, str$(MyDwords), "Surprise...:", MB_OK
exit
end start


More (http://www.google.com/search?q=%22explicit-operands+form+is+provided+to+allow+documentation%22)
Title: Re: stosd
Post by: dedndave on May 26, 2011, 10:12:51 PM
yes - stos, lods, movs, scas, and cmps can all get a size from a label
it can be any appropriately sized label - does not matter if it is the one pointed to by the index regster   :P
Title: Re: stosd
Post by: jj2007 on May 26, 2011, 10:31:22 PM
Even this works:
stos dword ptr GetTickCount
And yes, it's a simple stosd under the hood, mov [edi], eax/add edi, 4 - has nothing to do with GetTickCount.
That can be a cute feature, but on the other hand it's a nightmare to chase a bug caused by a wrong value in edi...
Title: Re: stosd
Post by: dedndave on May 26, 2011, 10:59:20 PM
as i remember, you can do something similar with XLAT
of course, it always wants a byte table   :P
Title: Re: stosd
Post by: FORTRANS on May 27, 2011, 12:08:43 PM
Quote from: dedndave on May 26, 2011, 10:59:20 PM
as i remember, you can do something similar with XLAT
of course, it always wants a byte table   :P

Hi,

   Yeah, I tried these "label" tricks out once.  Lasted almost
15 minutrs.  Noted the string opcodes actually tried the
XLAT trick.  Oh well.

Cheers,

Steve N.