Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NASM macro for call w/ params

0 views
Skip to first unread message

J. Argasiński

unread,
Oct 1, 1999, 3:00:00 AM10/1/99
to

like in topic: i'm looking for macro for NASM which would
allow me to call procedure with parameters in TASM fashion,
i.e.
call my_proc,[param1],[param2],[param3]

how to declare such a macro? basically we have only
a number of parameters (%0) - four in this case and
macro should push all the parameters in reverse order
as a dwords, so above call would expand to something
like this:

push dword [param3]
push dword [param2]
...
call my_proc

I need this because my routines requires 5 or more
parameters passed by stack and all of them pushed
in reverse order work, but the source is completly
unreadable; sometimes I have to comment all of them
in order to remember what I'm currently pushing
onto the stack... :|

Of course macro doesn't have to be called "call",
but I know it is possible to define macros using
names which are normally thought as "restricted".

--
Argasek/IPL
The ImPLosion. To my zbudowaliśmy jelcz.
http://www.argasek.z.pl/ arg...@ipl.z.pl


kisda

unread,
Oct 2, 1999, 3:00:00 AM10/2/99
to
hi,

> like in topic: i'm looking for macro for NASM which would
> allow me to call procedure with parameters in TASM fashion,
> i.e.
> call my_proc,[param1],[param2],[param3]

...try this :

%imacro CALL 2-* ; accepts 'call','CaLL',cALL'...
%rotate -1 ; rotate left...rotates 'my_proc'
%rep %0 - 1 ; number of paras...
push %1 ; 1st time, 1 st parameter....
%rotate -1 ; next para..
%endrep
call %1 ; and now, the real call...
%endmacro

NASM decides on the number of parameters, if 'call' will be the function
or macro...
paramcount 2+ -> macro
paramcount 1 -> function

Use it like this:

my_text db 'Hello World',0

call my_proc, my_text, dword [my_var], eax, dword 0123h, my_text

good luck...

kisda


Peter Johnson

unread,
Oct 2, 1999, 3:00:00 AM10/2/99
to
I wrote a clone of MASM's invoke/proc/endproc mechanism for the C
calling convention using NASM's macro facility. If anyone's
interested in this, I'll post it on the web somewhere.

Peter Johnson
lo...@mcs.net

On 1 Oct 1999 21:06:09 GMT, "J. Argasiński" <arg...@ipl.z.pl> wrote:

>
>like in topic: i'm looking for macro for NASM which would
>allow me to call procedure with parameters in TASM fashion,
>i.e.
> call my_proc,[param1],[param2],[param3]
>

J. Argasiński

unread,
Oct 2, 1999, 3:00:00 AM10/2/99
to

Thank you! It really helped me a lot.

wayne

unread,
Oct 8, 1999, 3:00:00 AM10/8/99
to

I am using NASM, and I want to write some useful macros
but I don't know much to do this
so, I need somebody to help me to do this

Peter Johnson źśźgŠó¤ĺłš <7t4u07$kp9$3...@autumn.news.rcn.net>...

0 new messages