|
-
Dec 28th, 2007, 09:17 PM
#1
Thread Starter
Hyperactive Member
C TO asm [NASM]
I am stuck - i cannot find answer in google or any where else -
how can I pass values to my C code from asm ??
I am compiling my both C code and ASM code to .obj file and linking the mess together . but i cannot find a way pass values to my c code and return value
Thx for help
VS 2005 .....Framework SDK 3.0
"Its mostly the brave one who choose to not fight"
-
Dec 30th, 2007, 10:42 PM
#2
Re: C TO asm [NASM]
The EAX register is commonly where values are stored on 32-bit machines once a function has returned.
So,
Code:
; ASM
ASMFunction proc
mov eax, 1234
ASMFunction endp
// C
void CFunction()
{
int blah = ASMFunction();
}
Passing values to functions is simple enough.. you just need to make sure the data types are the same size/type:
Code:
; ASM
AddASM proc
LOCAL arg1:DWORD,arg2:DWORD
pop arg2
pop arg1
add arg1, arg2
mov eax, arg1
ret
AddASM endp
// C
void AddC(int num1, int num2)
{
return AddASM(num1, num2);
}
chem
Last edited by chemicalNova; Dec 30th, 2007 at 10:45 PM.
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Dec 31st, 2007, 11:00 AM
#3
Thread Starter
Hyperactive Member
Re: C TO asm [NASM]
THX
how i pass values from my asm to my C code ??
VS 2005 .....Framework SDK 3.0
"Its mostly the brave one who choose to not fight"
-
Dec 31st, 2007, 10:10 PM
#4
Visual Studio 6, Visual Studio.NET 2005, MASM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|