flat assembler
Message board for the users of flat assembler.
Index
> Main > struc offsets |
Author |
|
Tomasz Grysztar 17 Mar 2006, 15:39
For the structures with fixed size fields (and I guess you don't many any other), you can do it with the quite old trick:
Code: virtual at 0 xyz xyz ; defines offsets like xyx.x, xyz.z etc. end virtual and then do things like: Code: mov eax,[ebx+xyz.z] However I often recommended the other method, like declaring the dedicated virtual instance of structure for your appliance: Code: virtual at ebx myxyz xyz end virtual mov eax,[myxyz.x] ; generates the mov eax,[ebx+0] instruction |
|||
17 Mar 2006, 15:39 |
|
lazer1 17 Mar 2006, 18:19
thanks for the explanation!
both ideas will be useful for me, sometimes I need just the offsets where the first suggestion will be useful and sometimes I need to use struc fields where the second suggestion is what I need, I think I will use the second suggestion like this: Code: virtual at ebx ebx_xyz xyz end virtual that way whenever I want ebx to be a pointer to a struc ebx I can use it as ebx_xyz, I'll name it like this so I dont forget its via ebx, question on this: will ebx_xyz then be the same as ebx? eg is the following code: Code: mov eax,ebx_xyz
the same as: Code: mov eax,ebx
? |
|||
17 Mar 2006, 18:19 |
|
Tomasz Grysztar 17 Mar 2006, 18:26
No, not really.
Funny that this question was already asked today: http://board.flatassembler.net/topic.php?t=4959 |
|||
17 Mar 2006, 18:26 |
|
Patrick_ 18 Mar 2006, 01:41
I have a (somewhat) similar question, so I thought I would ask it here.
I have a structure declared like so: Code: struc dirent { .d_ino: rd 1 ... } However, I'm not sure how I would put the address of the structure (so I can, say, pass it as a system call argument) into a register. How would I do this? |
|||
18 Mar 2006, 01:41 |
|
RedGhost 18 Mar 2006, 01:52
Patrick_ wrote: I have a (somewhat) similar question, so I thought I would ask it here. address of the first variable would be the same as the address of the structure there is probably some trick but i would just build it manually: Code: dirent: .d_ino rd 1 size.dirent = $-dirent you could pass 'dirent' or 'dirent.d_ino' (no brackets) as the address actually come to think of it, you can do the same with 'struc' Code: struc abc { .wutang dd ? } hi abc ..... mov eax, hi that should also be fine, since 'abc' wont actually be anywhere in your code unless you declare a structure like 'hi' as it _________________ redghost.ca |
|||
18 Mar 2006, 01:52 |
|
Patrick_ 19 Mar 2006, 14:55
Thank you! This works.
|
|||
19 Mar 2006, 14:55 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.