flat assembler
Message board for the users of flat assembler.
Index
> Main > proc/public and name mangling |
Author |
|
Vasilev Vjacheslav 19 Sep 2005, 15:55
why just not to use 'dstr_memcpy equ _dstr_memcpy' and define proc in this way 'proc dstr_memcpy stdcall uses ESI EDI, dst:DWORD, src:DWORD, len:DWORD'? or maybe i wrong?
|
|||
19 Sep 2005, 15:55 |
|
Remy Vincent 19 Sep 2005, 17:32
If you don't load the registers yourself, and if you let stdcall macro load the right registers, a lot of your neurones will work hard, only to remind which registers are automaticly used... ????Why are you lowering your brain all alone, so much, so fast, ...
proc dstr_memcpy stdcall dst:DWORD, src:DWORD, len:DWORD or mov EDI , ... mov ESI , ... mov ECX , ... CALL dstr_memcpy ... ... dstr_memcpy: lodsb stosb ... ret _________________ Groups lower your IQ |
|||
19 Sep 2005, 17:32 |
|
f0dder 19 Sep 2005, 19:50
Vasilev, I guess "equ" or "fix" or something might work, but it's still annoying having to do "dummy" work by hand
|
|||
19 Sep 2005, 19:50 |
|
Eoin 19 Sep 2005, 21:15
F0dder, the best way to do it would probably be a modification to the proc macro. I tried it there, but can only get FASM to output the number of parameter bytes required as an 8 digit hex value.
If someone knows how to output decimal digits then the rest would be easy... |
|||
19 Sep 2005, 21:15 |
|
f0dder 19 Sep 2005, 21:19
Eoín, that's where I thought "attacking" the problem would be easiest, too, but the proc macros are a bit more of a mouthful than I care to play with right now - got other projects as well
Thanks for looking into it! |
|||
19 Sep 2005, 21:19 |
|
rea 20 Sep 2005, 03:12
What about for the moment write a little parser that do what you whant??? and include the generated file somewhere in the file; for example: main.asm, main.sig and include in main.asn main.sig.
If it is posible get a number in decimal for example 4*3 = 12 instead of C (like I guess is what say Eoin), should be fair easy modify proc for concatenate if necesary 8at request???) "_" + "name_argument" + "@" + arg_c*4 or any that you whant... |
|||
20 Sep 2005, 03:12 |
|
Tomasz Grysztar 20 Sep 2005, 08:13
Eoin, how did you do it that you were able to get hex digits, but not decimal ones??
Nonetheless, it cannot be done at the assembly stage for this case, because the names for procedures must be completed during the preprocessing stage. The problem of getting the count of arguments as a number during the preprocessing was discussed here: http://board.flatassembler.net/topic.php?t=3980 Here's the modified define@proc macro that uses this trick to obtain the "parmbytes" as a decimal number during the preprocessing. It doesn't work for the parameters of types larger that 4 bytes, though - for this to work the counting would have to be done inside the defargs@proc macro, with checking of the type of parameter to choose the values of increment for the "parmbytes". Code: macro define@proc name,statement { local params,flag,regs,parmbytes,localbytes,current name: match =stdcall args, statement \{ params equ args flag = 11b \} match =stdcall, statement \{ params equ flag = 11b \} match =c args, statement \{ params equ args flag = 10001b \} match =c, statement \{ params equ flag = 10001b \} match =params, params \{ params equ statement flag = 0 \} parmbytes equ 0 virtual at ebp+8 match =uses reglist=,args, params \{ regs equ reglist params equ args \} match =regs =uses reglist, regs params \{ regs equ reglist params equ \} match =regs, regs \{ regs equ \} match =,args, params \{ defargs@proc args irp arg, args \\{ match current,parmbytes \\\{ rept 5 i:current \\\\{ parmbytes equ i \\\\} \\\} \\} \} match =args@proc args, args@proc params \{ defargs@proc args irp arg, args \\{ match current,parmbytes \\\{ rept 5 i:current \\\\{ parmbytes equ i \\\\} \\\} \\} \} end virtual name # % = parmbytes/4 all@vars equ current = 0 match prologue:parmbytes:reglist, prologue@proc:parmbytes:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \} macro locals \{ virtual at ebp-localbytes+current macro label . \\{ deflocal@proc .,:, \\} struc db [val] \\{ \common deflocal@proc .,db,val \\} struc dw [val] \\{ \common deflocal@proc .,dw,val \\} struc dp [val] \\{ \common deflocal@proc .,dp,val \\} struc dd [val] \\{ \common deflocal@proc .,dd,val \\} struc dt [val] \\{ \common deflocal@proc .,dt,val \\} struc dq [val] \\{ \common deflocal@proc .,dq,val \\} struc rb cnt \\{ deflocal@proc .,rb cnt, \\} struc rw cnt \\{ deflocal@proc .,rw cnt, \\} struc rp cnt \\{ deflocal@proc .,rp cnt, \\} struc rd cnt \\{ deflocal@proc .,rd cnt, \\} struc rt cnt \\{ deflocal@proc .,rt cnt, \\} struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} macro endl \{ purge label restruc db,dw,dp,dd,dt,dq restruc rb,rw,rp,rd,rt,rq restruc byte,word,dword,pword,tword,qword current = $-(ebp-localbytes) end virtual \} macro ret operand \{ match any, operand \\{ retn operand \\} match , operand \\{ match epilogue:parmbytes:reglist, epilogue@proc:parmbytes:<regs> \\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 \} } (I've also removed the "if used" checking in the above, since for "public" procedures this doesn't make sense at all). And now it's only a matter of customizing the prologue to do the name mangling: Code: macro prologue_namemangling procname,flag,parmbytes,localbytes,reglist { if flag and 10b ; do mangling only for stdcall public procname as '__'#`procname#'@'#`parmbytes else public procname end if if parmbytes | localbytes push ebp mov ebp,esp if localbytes sub esp,localbytes end if end if irps reg, reglist \{ push reg \} } |
|||
20 Sep 2005, 08:13 |
|
f0dder 20 Sep 2005, 08:51
Thanks, Tomasz - I'll have a look at it once I'm done messing with this windows unattended setup
|
|||
20 Sep 2005, 08:51 |
|
Eoin 20 Sep 2005, 12:42
In fact what I was seeing was something labelname@parmbytes?00065C and mistook it as being the value of parmbytes in hex, instead I guess now its something to do with parmbytes being local to the macro.
My mistake . |
|||
20 Sep 2005, 12:42 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.