flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > .sizeof for local variable arrays? |
Author |
|
vid 02 Sep 2008, 19:19
qood idea for Tomasz, IMHO
|
|||
02 Sep 2008, 19:19 |
|
revolution 03 Sep 2008, 02:20
The way Tomasz has the macros for the proc related things makes it a little tricky to properly make the sizeof.var truly act like a local label. It would be easy to make a normal global label with just a few simple changes.
Someone with a little time to spare may like to go through the whole proc macro code and do the necessary changes. I'm sure they would also learn much about how these macros work in the process. |
|||
03 Sep 2008, 02:20 |
|
hopcode 03 Sep 2008, 23:40
Hallo all,
i have tried to add the following line sizeof.\#varname = $ - varname to the "local" macro in PROC32.inc after the line ~247 ... ... line 243... match , done@local \\{ virtual varname vartype end virtual rb count*sizeof.\#vartype restore done@local \\} sizeof.\#varname = $ - varname ;<--so,add this line \} ... ... And it works good !!! (locals/endl are not affected by this modification) But i am afraid this is not the right way to do it. .. hopcode |
|||
03 Sep 2008, 23:40 |
|
revolution 04 Sep 2008, 00:59
Yes, that it a global label, that was the easy part I mentioned. Just be aware of it if you get a duplicate label error when assembling.
If you want a genuine local label then you will need another solution. |
|||
04 Sep 2008, 00:59 |
|
hopcode 05 Sep 2008, 10:08
Hallo all,
Here a solution applied only to the datatype local name[xxx]:BYTE It could be easily extended to any type. It is also interesting the fact that this mechanism is similiar to the mechanism in PROC302.inc. So it could be easily integrated in PROC32.inc, without the need of wrapping with the _x macro. It is to say, direct in the well kwnown proc/local/endp etc. macro. I have had no time to do it. But first I wanted submit to you this idea, in order to have from it a feedback. FASM FASM FASM Code: format PE CONSOLE 4.0 entry start include '%fasminc%\win32a.inc' section ".data" data readable writeable dd 0 section ".code" code readable executable macro _x arg { match =proc rest,arg \{ all@sizes equ \\proc rest \} match =local rest,arg \{ match varname[count]:vartype, rest \\{ match =BYTE, vartype \\\{ ;display_decimal count ;display \\\`varname match vars, all@sizes \\\\{ all@sizes equ all@sizes, \\\\} all@sizes equ all@sizes varname\\#.size varname\\#.size equ count \\\} \\} \\local rest \} match =endp,arg \{ \\endp match vars,all@sizes \\{ restore vars \\} restore all@sizes \} } start: call p1 nop nop ; display_decimal alfa.size ;decommenting gives error ; display_decimal beta.size ;decommenting gives error _x proc p1 _x local alfa[256]:BYTE _x local beta[100]:BYTE lea eax,[alfa] mov eax,alfa.size ; display_decimal alfa.size ;OK, known label ; display_decimal beta.size ;OK, known label ret _x endp ; display_decimal alfa.size ;decommenting gives error ; display_decimal beta.size ;decommenting gives error hopcode[mrk] |
|||
05 Sep 2008, 10:08 |
|
madmatt 05 Sep 2008, 12:46
Thanks hopcode, your stuff looks good . I'll see if I can take this further, and find a truly transparent solution.
|
|||
05 Sep 2008, 12:46 |
|
hopcode 05 Sep 2008, 15:12
Hallo all,
/to madmatt/ thanks . Try this PROC32.INC attached. It allows varname.size on all types of local. I have but tested it not extensively.It should be complete for all all the types. Less than 10 lines in addition to the Priva-code. .. FASM FASM FASM hopcode[mrk] _________________ ⠓⠕⠏⠉⠕⠙⠑ Last edited by hopcode on 05 Apr 2011, 16:38; edited 1 time in total |
|||
05 Sep 2008, 15:12 |
|
madmatt 06 Sep 2008, 10:42
Hey, thanks hopcode, I'll give it a try sometime today or tommorrow.
|
|||
06 Sep 2008, 10:42 |
|
madmatt 06 Sep 2008, 13:34
Thanks a bunch hopcode, I've tried it and it works good, but one small change and a small problem. I made a change to the code so the variable will be just like a struct sizeof.xxx variable (see below). also, DQWORD doesn't work right, I'll see if I can find what the problem is.
Code: ;--------------------X--lines by hopcode ;--------------------------- ;display_decimal $-..var ;display `name ;----------------------- match vars, all@sizes \{ all@sizes equ all@sizes, \} all@sizes equ all@sizes name#.size ..var#.size = $ - ..var sizeof.#name equ ..var#.size ;CHANGED: name#.size equ ..var#.size ;--------------------X--lines by hopcode |
|||
06 Sep 2008, 13:34 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.