How to Prototype ??

Posted on 2005-04-10
Last Modified: 2010-04-15
Hello. I have DevC++ and RaDASM with MASM32.
I made a program in assembly which I need to use from an C  Program. I generated the obj file . AThen in the C Ide in project options I added this obj file.

The question here is how must I use the .H file to use the assembly function and how can I use the function from main.c

This is my asm program

.model flat, stdcall
option casemap:none



Myproc proc var1:REAL4, var2:REAL4
    LOCAL retval:REAL4
    fld var1
    fld var2
    fstp retval
    fwait                ;<- is this really needed?
    mov eax, retval
Myproc endp

Question by:djhex
    LVL 45

    Accepted Solution

    Hi djhex,

    It looks like you have written an assembly function with a C header that looks like this:

    real Myproc (real var1, real var2);

    If you'll put that line in your .h file (or near the top of your .c file) you'll have an effective prototype.

    There are several ways to get this assembly program into your application.

    Perhaps the easiest is to start by compiling this into an object file (.obj).  Then configure the IDE to use this file in your project.

    Good Luck!
    LVL 4

    Expert Comment

    If thats your whole assembly program why not just use inline assembly and use your c compiler.
    Your prototyping will be the same as for any c function.
    It would be a lot simpler.

    LVL 10

    Author Comment

    I cant use inline ase,bly

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
    Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
    The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now