flat assembler
Message board for the users of flat assembler.
Index
> Main > size operator |
Author |
|
baldr 15 Jun 2010, 23:05
flat_user,
Overload directives with struc-macro: Code: irps s, b w d f p q t { struc r#s num* \{ . r#s 1 .size = $-. r#s num-1 .length = num \} } mov eax,var.size ;=4 mov eax,var2.length ;=40 mov eax,var2.size * var2.length ;=80 var rd 1 var2 rw 40 Similar technique could be used for db-like directives. |
|||
15 Jun 2010, 23:05 |
|
revolution 15 Jun 2010, 23:05
Code: struc rd val { . rd val sizeof.#. = 4 lengthof.#. = val } struc rw val { . rw val sizeof.#. = 2 lengthof.#. = val } mov eax,sizeof.var ;=4 mov eax,lengthof.var2 ;=40 mov eax,sizeof.var2 * lengthof.var2 ;=80 var rd 1 var2 rw 40 |
|||
15 Jun 2010, 23:05 |
|
flat_user 15 Jun 2010, 23:25
Thanks,
but I would need to include those macros in every project... I also could insert them into FASM's package's includes so they would be easier to use, but then such source code would need to be given out with those include-mods as well means it'd be more extensive to compile... Nevertheless, I'd say such operators are very useful, so I've got the question if there will be native support? Thank you! |
|||
15 Jun 2010, 23:25 |
|
revolution 15 Jun 2010, 23:55
flat_user wrote: I've got the question if there will be native support? Code: BUFFER_LENGTH = 40 ;... buff rd BUFER_LENGTH ;... mov ecx,BUFFER_LENGTH |
|||
15 Jun 2010, 23:55 |
|
flat_user 16 Jun 2010, 11:56
Code: _64BIT equ 1 call ReadProcessMemory,[proc],[addr],var,size var,0 if _64BIT eq 1 var rq 1 else var rd 1 endif I guess this would be the most straightforwarded and most dynamical way without using any extra symbols or additional macros which you would need to distribute... (if there was native support) |
|||
16 Jun 2010, 11:56 |
|
baldr 16 Jun 2010, 12:15
flat_user,
What if var is a structure? FASM knows nothing about structures. No need for feature that can be implemented almost hassle-free using current tools (macros from MACRO\STRUCT.INC for structures, as an example). |
|||
16 Jun 2010, 12:15 |
|
LocoDelAssembly 16 Jun 2010, 18:57
baldr,
Your code fails when the size is zero. I've fixed it: Code: irps s, b w d f p q t { local elemSize virtual at 0 r#s 1 elemSize = $ end virtual struc r#s num* \{ . r#s num .size = elemSize .length = num \} } [edit]Removed the double dots. See the reason below.[/edit] Last edited by LocoDelAssembly on 16 Jun 2010, 19:33; edited 1 time in total |
|||
16 Jun 2010, 18:57 |
|
baldr 16 Jun 2010, 19:24
LocoDelAssembly,
I knew about this. My first variant was similar to yours, only virtual block was inside struc-macro (just in case rx being overloaded again ), then I've simplified it for readability. Numeric constant definition doesn't set new label prefix, you don't need ..elemSize. |
|||
16 Jun 2010, 19:24 |
|
LocoDelAssembly 16 Jun 2010, 19:30
Quote:
|
|||
16 Jun 2010, 19:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.