flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How to transfer MASM macro SADD to FASM macro?

Author
Thread Post new topic Reply to topic
habran



Joined: 31 Aug 2008
Posts: 82
Location: South Australia
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
Post 08 Nov 2008, 00:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 08 Nov 2008, 01:00
It would help if you showed us the macro! Or at the very least, gave a description of it's intended function.

BTW: Would this not come under the "Macroinstructions" section? Perhaps a friendly mod could move it.
Post 08 Nov 2008, 01:00
View user's profile Send private message Visit poster's website Reply with quote
habran



Joined: 31 Aug 2008
Posts: 82
Location: South Australia
habran 08 Nov 2008, 01:02
invoke wsprintf,addr buff,SADD(" Page %i/%i"), nCurrentPage, nCountPage
Post 08 Nov 2008, 01:02
View user's profile Send private message Reply with quote
habran



Joined: 31 Aug 2008
Posts: 82
Location: South Australia
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
Post 08 Nov 2008, 01:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
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]    
Although it is not exactly the same since the string will appear in the code section rather than the data section. If you need your string in the data section then a different technique is required, I can post a link on request if you need it.
Post 08 Nov 2008, 01:08
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
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?
Post 08 Nov 2008, 01:11
View user's profile Send private message Reply with quote
habran



Joined: 31 Aug 2008
Posts: 82
Location: South Australia
habran 08 Nov 2008, 01:13
Thanks a lot revolution, that is what I wanted
Post 08 Nov 2008, 01:13
View user's profile Send private message Reply with quote
habran



Joined: 31 Aug 2008
Posts: 82
Location: South Australia
habran 08 Nov 2008, 01:19
Thanks LocoDelAssembly (I love your pseudonym)

now I have to go but I'll be back!
Post 08 Nov 2008, 01:19
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
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.
Post 08 Nov 2008, 08:09
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 08 Nov 2008, 10:22
User32!wsprintf is a cdecl function, cinvoke it. By the way, cinvoke will properly adjust stack after call.
Post 08 Nov 2008, 10:22
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 08 Nov 2008, 12:17
Damn, we both failed to see that mistake. Thanks for noting it baldr.
Post 08 Nov 2008, 12:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 08 Nov 2008, 14:20
Yep, good catch baldr.
Post 08 Nov 2008, 14:20
View user's profile Send private message Visit poster's website Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 221
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!
Post 18 Oct 2009, 06:33
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
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 Razz
Post 18 Oct 2009, 14:35
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.