How to prototype.h files? based on assembler programs

Posted on 2005-04-10
Last Modified: 2010-04-01
This is my float.h

#ifndef _FLOTANTE_H
#define _FLOTANTE_H

#define MyProc __MyProc
extern "C" __stdcall __MyProc(float,float);

float MyProc(float var1, float var2);

This is my Assembly code


.model flat, stdcall

option casemap:none

;include \masm32\include\
;include \masm32\include\



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


And this is my C code.

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
#include "H:\Practica Arquitectura del Computador\include\flotantes.h"

float MyProc(float, float);

void sum(void)
     float total2;
     total2 = MyProc(3.2, 4.2);
     printf("Total is: %d", total2);

But I have this error

Compilador: Default compiler
Building Makefile: "H:\Practica Arquitectura del Computador\"
Ejecutando  make...
make.exe -f "H:\Practica Arquitectura del Computador\" all
gcc.exe -c test/pentium/main.c -o test/pentium/main.o -I"C:/Dev-Cpp/include"  -I"H:/Practica Arquitectura del Computador/include"  

gcc.exe test/pentium/main.o  -o "test\pentium\Practica.exe" -L"C:/Dev-Cpp/lib" src/pentium/pentium.obj  

test/pentium/main.o(.text+0xdc):main.c: undefined reference to `MyProc'
collect2: ld returned 1 exit status

make.exe: *** [test/pentium/Practica.exe] Error 1

Ejecución Terminada
Question by:djhex
    1 Comment
    LVL 22

    Accepted Solution

    Could be one of three things:

    (1)  You didnt include the assembly source file in the list of files to compile and assemble.

    (2)  The name of the assembly .o file didnt get passed to the linker

    (3)  The function names are not exactly matched up.

    You'll have to look at the gcc conventions for external names.  

    This varies from compiler to compiler.  Some Prepend an underline.  Some postpend an underline, or two.

    Some assemblers uppercase all external names, some dont.

    You could run a "strings" or "dumpobj" over the .o files and see if "MyProc" shows up in the .o files with the exact same capitalization and underline decorations.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
      Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

    737 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

    22 Experts available now in Live!

    Get 1:1 Help Now