I'm used to using memory or a regs. Even the more comples base+scale+index. But this one allows address+reg. All the address parametrs used below are defined by the LOCAL directive. An interesting this is since it is considered local MASM puts ss: stack segemt prefix. I codes it in the db line and it works fine with out the prefix. A curiosity for me since I do not think I've seen this style used often


Stupid code that does nothing:


_stack PROC foo:DWORD,bar:DWORD
00401000 55 push ebp
00401001 8B EC mov ebp,esp
00401003 83 C4 E8 add esp,0FFFFFFE8h

LOCAL _foo:DWORD,_bar:DWORD,_test[16]:byte

mov eax,0
00401006 B8 00 00 00 00 mov eax,0
[COLOR=red]
mov _test[eax],255
0040100B 36 C6 44 28 E8 FF mov byte ptr ss:[_test][eax],0FFh
00401011 C6 44 28 E8 FF mov byte ptr _test[eax],0FFh
db 0C6h,44h,28h,0E8h,0FFh

mov _foo[0],0
00401016 C7 45 FC 00 00 00 00 mov dword ptr [_foo],0

mov _foo[eax],eax
0040101D 36 89 44 28 FC mov dword ptr ss:[_foo][eax],eax

mov eax,4
00401022 B8 04 00 00 00 mov eax,4

mov eax,_foo[eax]
00401027 36 8B 44 28 FC mov eax,dword ptr ss:[_foo][eax]
[/COLOR]
ret
0040102C C9 leave
0040102D C2 08 00 ret 8
_stack ENDP

Or could it be that the address is encoded as an offset?

Thanks.
Posted on 2004-04-24 12:28:15 by ThoughtCriminal
Aren't _foo, _test, etc just ebp+X so [_foo] would really just be which is perfectly ok, if a bit dangerous in the way it plays with the stack.
Posted on 2004-04-24 15:13:46 by Eóin