News:

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

Some oddities with a struct and a local var

Started by cobold, March 20, 2010, 08:17:20 PM

Previous topic - Next topic

theunknownguy

Quote from: cobold on March 21, 2010, 10:29:32 AM
Hello,

first of all, a big thank you for everyone who helped me (qWord, MichaelW and jj2007)!
The program is working now but let me resume to see if I have understood everything:

- if I want to pass a structure to a PROC, I have three possibilites:


  • 1. pass the address of the structure (by reference), address must be in a register
    1.a. qWord:
    assume esi:PTR myStruct
    mov [esi].x, eax
    assume esi:nothing


  • 1.b. MichealW:
    mov [esi], ADDR myStruct
    mov [esi].myStruct.x, eax


  • 2. jj2007: pass the structure itself (by value), address must be in a register
    - parameter is myStruct itself
    mov myStruct.x, eax
    - changes are LOCAL to PROC

brgds

cobold

- Local structure:


LOCAL MyStruct:HEY_STRUCT
mov MyStruct.Hello, 1


- Assumed struct:

assume esi:ptr HEY_STRUCT
lea esi, MyStruct
mov [esi].Hello, 1
assume esi: NOTHING



- Global initialised <>:


.Data
HeyStruct HEY_STRUCT <>
.Code
mov HeyStruct.Hello, 1


- Linked Struct:

COBOLD_STRUCT struct
Hello byte ?

HEY_STRUCT struct
Cobold COBOLD_STRUCT <?>


.Code
assume esi:ptr HEY_STRUCT
lea esi, MyStruct
mov [esi].Cobold.Hello, 1



Interpret "Addr" has: "lea eax, Address" and Offset is calculated by preprocessor if i am not wrong.