Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing arguments through two functions

Status
Not open for further replies.

dcgsmix

Programmer
Dec 20, 2001
35
IL
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
 
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.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top