flat assembler
Message board for the users of flat assembler.
Index
> Main > accessing structure fields |
Author |
|
typedef 29 Sep 2011, 00:52
Code: cld lea esi ,[ONE] lodsd lodsd ;esi + 4 ;eax = &TWO2 lea esi,[eax] ; haha, eax = TWO2 lodsd lodsd ;esi + 4, EAX = ONE.TWO2.str Anyone correct me if I missed something. |
|||
29 Sep 2011, 00:52 |
|
Enko 29 Sep 2011, 04:09
you are making wrong the structures I think. You should do it upside down.
Code: struc TWO1 flag, lpstr { .type dd flag .str dd lpstr } struc TWO2 flag, lpstr { .type dd flag .str dd lpstr } struc ONE t1, lpstr1, t2, lpstr2 { .TWO1 TWO1 t1, lpstr1 .TWO2 TWO2 t2, lpstr2 } str4 db 'string 4',0 str3 db 'string 3',0 szstr '%s',0 _ONE ONE 1,str3, 2, str4 ;<<<<<<< section '.code' code readable executable start: cinvoke printf, szstr, [_ONE.TWO1.str] if you want to define an empty ONE: Code: theTWO ONE 0,0,0,0 section '.code' code readable executable start: mov [theTWO.TWO1.str], str4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; or using struct ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; struct _TWO1 type dd ? str dd ? ends struct _TWO2 type dd ? str dd ? ends struct ONE TWO1 _TWO1 TWO2 _TWO2 ends str4 db 'string 4',0 str3 db 'string 3',0 theTWO ONE section '.code' code readable executable start: mov [theTWO.TWO1.str], str4 cinvoke printf, szstr, [theTWO.TWO1.str] |
|||
29 Sep 2011, 04:09 |
|
cod3b453 29 Sep 2011, 07:42
Not tested but this should work:
Code: struct MYENTRY type dd ? str dd ? ends mov eax,1 ; Index of element to get mov esi,dword [ONE+eax*4] ; Pointer to element mov esi,dword [esi+MYENTRY.str] ; Get the pointer "str" in element ; Compare esi with some other string |
|||
29 Sep 2011, 07:42 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.