flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Borsuc 01 May 2008, 11:32
Many different ways. If you need a 'default' structure, it's better if you keep it a global pre-initialized one. In this way you won't need any instructions to initialize it because it'll be initialized. It's (usually IMO) not a good idea to keep structures on the stack.
If it's very big you can initialize it with 0s by using the string instructions (rep & all those). it all depends on what you want from the app. However I recommend a global structure but don't take my word for it. or did I misunderstand you? |
|||
![]() |
|
asmrox 01 May 2008, 11:35
if i dynamicly load memory, i always use heap. On stack i use static elements, like global structures.
rep? never heard, ill read about it. |
|||
![]() |
|
Borsuc 01 May 2008, 11:55
i thought the procedure you call required a pointer to this structure, so a global one would have been fine.
here's a short description of the string instructions i was referring to: Quote: REP - Repeat String Operation You can then use the string instructions (e.g STOS) to set the bytes to 0. Quote: STOS - Store String (Byte, Word or Doubleword) Something like this: Code: mov eax, 0 mov ecx, SIZE_STRUCT / 4 ; size of structure divided by 4 ; because we write 4 bytes at a time mov edi, STRUCT_OFFSET ; pointer to struct start rep stosd I just made up this code, dunno if there are typos or something of course in an actual code you should use "xor eax, eax" instead of "mov eax, 0" (sorry tom) but this was only an example |
|||
![]() |
|
Mac2004 02 May 2008, 06:14
I use virtual structures to access structures through registers like this:
Code: struc FRAME_STRUC { .x dd 0 ;start x-coordinate .y dd 0 ;start y-coordinate .x_length dd 0 ;x length .y_length dd 0 ;y length .color dd 0 ;color };end of structure virtual at 0 local_frame FRAME_STRUC ; define a local virtual instance end virtual frame1 FRAME_STRUC ; Define a test sructure And this is how I access the structure: Code: mov esi,frame1 mov dword[esi+local_frame.x],200 mov dword[esi+local_frame.y],300 ;..... regards, Mac2004 |
|||
![]() |
|
asmrox 02 May 2008, 09:57
structures in file? interesting
![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.