在MASM程序中使用C函数

问题描述 投票:0回答:1

我有C函数,我想在我的MASM程序中使用它。

C文件:

#include <stdio.h>

int go() {
    printf("Hello\n");
    return 10;
}

我在gcc中使用了此命令:gcc -c go_func.c在我获得go_func.obj

之后

但是,我无法编译/翻译我的MASM程序,因为我那里没有go函数的地址。也许我需要创建dll(静态或动态)?

prog.asm:

.386p
.model flat, stdcall
; include c:\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\msvcrt.inc
include c:\masm32\include\kernel32.inc

includelib c:\masm32\lib\msvcrt.lib
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib

extern go@0:NEAR

_data segment dword public use32 'data'

_data ends

_text segment dword public use32 'code'

START:
    call go

_text ends

end START

我无法调用该函数,因为我没有指向该函数的指针?

c include call masm extern
1个回答
0
投票

您想要a PROTO declaration用于告诉MASM使用C调用约定的函数。在这种情况下,它将是PROTO,而不是C(这是从80年代起已经过时的16位调用约定)。

© www.soinside.com 2019 - 2024. All rights reserved.