Passing Variables

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2009
Posts: 4
Reputation: Jake12 is an unknown quantity at this point 
Solved Threads: 0
Jake12 Jake12 is offline Offline
Newbie Poster

Passing Variables

 
0
  #1
Jan 31st, 2009
Hi. I am a little new to mixing C and ASM and I was wondering how one could pass a value from one asm function to another ASM function that then pushes the same value to a C function.

What I have is this:

01. ASM 01 loads ASM 2 into memory, pushes dword value into EAX, and then calls the ASM 2 function.
02. ASM 02 function sets up the stack and then calls the C function.

So, how do I pass this value from ASM to ASM to C? I hope this makes sense.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Passing Variables

 
0
  #2
Feb 1st, 2009
You just described one way - what's the problem?
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 4
Reputation: Jake12 is an unknown quantity at this point 
Solved Threads: 0
Jake12 Jake12 is offline Offline
Newbie Poster

Re: Passing Variables

 
0
  #3
Feb 1st, 2009
I think the EAX register is getting overwritten in ASM 02. When I push the value onto the stack and call ASM 02, as soon as ASM 02 gets control I pop the EAX register and mov it to EBP which I then push on the stack and call the C program. The value I get is two small as it is supposed to be the linear frame buffer address and it appears to be the &end of my entire program as ASM 02 and C program are linked, but ASM 01 is not.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Passing Variables

 
0
  #4
Feb 2nd, 2009
Dunno, maybe post some code.

> ASM 01 loads ASM 2 into memory,
Is this some kind of DLL or overlay?

Which 'assembler' are you using (masm, tasm, nasm, ....)
Which memory model(s) are you using?
Which C compiler at the end of the chain?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Assembly
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC