×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Passing arguments through two functions

Passing arguments through two functions

Passing arguments through two functions

(OP)
I have to create a function that takes an unknown number of arguments, and then pass it forward to another function, while the first argument stands for the address of the function to be called (the only argument which should be poped out of stack)...

Now how do i do that?

I have my function that i built, using assembly & c++ combined, and i want to create one which is pure assembly. also my function has some problems which i have yet to overcome.

Thanks!

Daniel Cohen Gindi
dcgsmix@gmx.net

RE: Passing arguments through two functions

In order to access arguments passed on the stack you should
copy the SP to BP and reference the arguments by offset:

  push bp
  mov bp,sp
  mov ax,[bp+2]    ;access return offset.

Since the function must accept an arbitrary number of
arguments I recommend parsing the address to the function
which must be called, as the LAST parameter. This way you
will know the exact offset from the BP value upon entry to
the first function.

note that there are differences in accessing "stacked"
arguments in a far and near function. You should check what
your code does.

I recommend reading an assembly book of some sort on
this topic before going at it.

RE: Passing arguments through two functions

(OP)
Thanks

Anyway, I found a way i can do it. The problem was that I used MSVC++. I now just declared the whole function clean assembly code so I dont get checked by VC on every smart step in my assembly code by...

Good night!

Daniel Cohen Gindi
dcgsmix@gmx.net

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close