News:

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

Fill Struct

Started by ragdog, February 28, 2010, 09:50:39 AM

Previous topic - Next topic

ragdog

Hi

Can i fill this struct over a Procedur

Example:

MyStruct STRUCT   ; sizeof = 1
   szEnable   BOOLEAN   ?
MyStruct ENDS


MYProc  proc _handle:DWORD,bEnabled:DWORD

mov [pxxx.szEnable],bEnabled
...
..
.
ret
MYProc endp

Greets,

Ghandi


MyStruct STRUCT   ; sizeof = 1
   szEnable   BOOLEAN   ?
MyStruct ENDS


.data
pxxx MyStruct <>

.code
MYProc  proc _handle:DWORD,bEnabled:DWORD
mov eax,bEnabled
mov pxxx.szEnable,al
...
...
...
ret
MYProc endp



This is assuming that you are using pxxx as a global variable. You can't move a value directly from memory to memory, unless you use esi/esi and the string operands (movsb/movsw/movsd) and for a boolean value i dont see any benefits from doing that so it simply places the bEnabled value in eax/al before storing it in the variable member.

If you used a DWORD instead of a BOOLEAN, you could also use push/pop to achieve the same thing.

HR,
Ghandi

ragdog

Thanks for you reply

I have try 1 and 2 solution i have an error messages

error A2070: invalid instruction operands
One or more operands were not valid for the instruction they were specified with.

The first have i allready try it

Edit:

Yes with al Works fine :U