flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > How to transfer MASM macro SADD to FASM macro? |
Author |
|
habran 08 Nov 2008, 00:48
Hi Everyone!
Would anybody be able to show me how to transfer MASM macro "SADD" to FASM macro? _________________ down under |
|||
08 Nov 2008, 00:48 |
|
habran 08 Nov 2008, 01:02
invoke wsprintf,addr buff,SADD(" Page %i/%i"), nCurrentPage, nCountPage
|
|||
08 Nov 2008, 01:02 |
|
habran 08 Nov 2008, 01:05
; **********************************************
; The original concept for the following macro * ; was designed by "huh" from New Zealand. * ; ********************************************** ; --------------------- ; literal string MACRO ; --------------------- literal MACRO quoted_text:VARARG LOCAL local_text .data local_text db quoted_text,0 align 4 .code EXITM <local_text> ENDM ; -------------------------------- ; string address in INVOKE format ; -------------------------------- SADD MACRO quoted_text:VARARG EXITM <ADDR literal(quoted_text)> ENDM |
|||
08 Nov 2008, 01:05 |
|
revolution 08 Nov 2008, 01:08
If you are using the standard macro package in the Windows download of fasm then use this:
Code: invoke wsprintf,buff," Page %i/%i",[nCurrentPage],[nCountPage] |
|||
08 Nov 2008, 01:08 |
|
LocoDelAssembly 08 Nov 2008, 01:11
Well, if you include win32{a|w}x.inc you can do 'invoke wsprintf,addr buff," Page %i/%i", nCurrentPage, nCountPage', which gets translated into the following code:
Code: push nCountPage ; Note that in fasm this and push [nCountPage] has different meaning push nCurrentPage ; Same as above call @f db " Page %i/%i", 0 @@: lea edx, [buff] push edx call dword [wsprintf] But if you use the same strings N times then it will be placed in the executable N times, maybe MASM macro prevents repeated occurrences of the same string. I think that Fresh had some macros to do this but can't check it myself now. PS: BTW, wasn't this subject discussed less than a month ago? |
|||
08 Nov 2008, 01:11 |
|
habran 08 Nov 2008, 01:13
Thanks a lot revolution, that is what I wanted
|
|||
08 Nov 2008, 01:13 |
|
habran 08 Nov 2008, 01:19
Thanks LocoDelAssembly (I love your pseudonym)
now I have to go but I'll be back! |
|||
08 Nov 2008, 01:19 |
|
vid 08 Nov 2008, 08:09
With FASMLIB macro set, that string would go to data section. But you had to use special macro in data section.
|
|||
08 Nov 2008, 08:09 |
|
baldr 08 Nov 2008, 10:22
User32!wsprintf is a cdecl function, cinvoke it. By the way, cinvoke will properly adjust stack after call.
|
|||
08 Nov 2008, 10:22 |
|
LocoDelAssembly 08 Nov 2008, 12:17
Damn, we both failed to see that mistake. Thanks for noting it baldr.
|
|||
08 Nov 2008, 12:17 |
|
revolution 08 Nov 2008, 14:20
Yep, good catch baldr.
|
|||
08 Nov 2008, 14:20 |
|
alorent 18 Oct 2009, 06:33
Hi guys,
vid wrote: With FASMLIB macro set, that string would go to data section. But you had to use special macro in data section. I have downloaded FASMLIB but I'm not sure of to use that, vid. Is it possible to extract that code from FASMLIB and just put it in a new macro "SADD" which just do that or it's not possible? Thanks! |
|||
18 Oct 2009, 06:33 |
|
vid 18 Oct 2009, 14:35
I haven't touched FASMLIB for quite some time, but if I remember correctly, what you want is: "idata" macro (macro for collecting data definition), "IncludeIData" macro that must be placed in data section (macro that defines "collected" data) and "libcall" macro (equivalent of "stdcall" or "invoke" macro), that encloses string definitions in "idata" block.
If you don't want to rip out macros, other option is to redefine "stdcall", "ccall", "invoke" and other macros to work in same manner as "libcall", but I don't feel like doing so right now |
|||
18 Oct 2009, 14:35 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.