News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

stosd

Started by jj2007, May 26, 2011, 08:41:39 PM

Previous topic - Next topic

jj2007

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

dedndave

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

jj2007

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...

dedndave

as i remember, you can do something similar with XLAT
of course, it always wants a byte table   :P

FORTRANS

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.