flat assembler
Message board for the users of flat assembler.
Index
> Main > (REQ) sizeof (data) |
Author |
|
vid 01 Jun 2004, 10:55
about times x structname - this doesn't work, because structure must be preceded by label <url=http://www.decard.net/tajga.php?chapter=preproc#struc>.
Only solution i see for your problem is to overload all data definiton directives (db, dd, dq, rb, rw etc.) with structure to produce this constant (sizeof.data). They should be overloaded in struct macro, but then you would have to end definition with some "ends" or another macro, not only with "}", because overloaded directives must be purged there. But I can't see reason for doing this, would it be worth of all that time loss? |
|||
01 Jun 2004, 10:55 |
|
Daemon 02 Jun 2004, 10:36
can i get an example of overloading db,dd,etc.. directives?
|
|||
02 Jun 2004, 10:36 |
|
zjlcc 02 Jun 2004, 13:29
you can:
Code: struc db [data] { common local zzz label zzz db data .size=$-zzz } struc dd [data] { common local zzz1 label zzz1 dd data .size=$-zzz1 } struc rb [data] { common local zzz2 label zzz2 rb data .size=$-zzz2 } macro DB field,var { field db var field#.#size=$-field } macro DD field,var { field dd var field#.#size=$-field } macro RB field,var { field rb var field#.#size=$-field } struc S1 { .data1 db ? .data2 dd ? .data3 rb 128 } s1 S1 struc S2 { DB .data1,? DD .data2,? RB .data3,128 } s2 S2 ............ mov eax,s1.data1.size mov ecx,s1.data2.size mov ecx,s1.data3.size nop mov ecx,s2.data1.size mov ecx,s2.data2.size mov ecx,s2.data3.size |
|||
02 Jun 2004, 13:29 |
|
Daemon 08 Jun 2004, 03:30
And what about
Code: mov eax,s1.size i think sizeof directive must be added as a preprocessor directive; then we'll have every data size defined. Greetz,
|
|||
08 Jun 2004, 03:30 |
|
vid 08 Jun 2004, 16:59
surely not preprocessor directive, preprocessor does only string manipulation, nothing with directives (only it's own), size of data, expressions (5*sizeof.data) etc.
I don't like that idea, it would produce too much unneeded overhead. Why do you need to have size of dword variable defined (in assembly, where you must know if to put it into dword register)? And how many structure definitions you have, is it that problem to write sizeof. constant yourself for every "rb" in strucutre? Remember, trying to save *typing* usually isn't right solution. |
|||
08 Jun 2004, 16:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.