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.

Recommended Answers

All 3 Replies

You just described one way - what's the problem?

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.

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.