I posted this squarely where I felt both sp00k and synfire would see it quickly.
I need to see some simple examples of the manipulation of string constants under nasm(x).

I have seen this:
%define CatStr(a,b) a %+ b

Now lets say for example, I wrote three procs called proc1 proc2 and proc3, and I wanted to issue a call to one of them, at buildtime, via a macro.

How can I write a macro that will append the input string constant to a base string constant, and emit a call to the procedure I desire?

%define CallX(a,b) call a %+ b

Surely not?

Manipulation of string constants is the underpinning of much of OA32, and solving these problems is the core of the issue.

TIA :)

sp00k - I'll remove this post and any more like it, as soon as each issue is resolved.. in the meanwhile, I see no reason why these exchanges can't be made in public.. unless you object, of course.
Posted on 2008-02-11 23:57:26 by Homer
It wouldn't necessarily be an "input strint constant" as much as it would be concatenation of two tokens prior to preprocessing it as a single token.

Take a look at the following example...


global _main

extern _MessageBoxA@16
extern _ExitProcess@4

%define CallX(a,b) call a %+ b


_main:
;MessageBox()
push DWORD 0
push DWORD Caption
push DWORD Message
push DWORD 0
CallX(_Message,BoxA@16)
add esp,16

;ExitProcess()
push DWORD 0
CallX(_Exit,Process@4)
add esp,4

;Program shouldn't be running anymore... check taskmgr...
jmp $


    Caption:    db  'Test', 0x0
    Message:    db  'Testing!!!', 0x0


HtH ;)

PS: Leave these posts up here, as I am sure some of them will actually help/inspire others :)
Posted on 2008-02-12 09:02:00 by SpooK