英特尔8086汇编程序从C调用 [英] Intel 8086 Assembly procedure calling from C

查看:434
本文介绍了英特尔8086汇编程序从C调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要开发汇编语言程序并调用从C语言程序(传递一个字符串,并返回一个整数值)。我的装配程序工作正常独立。我需要与他们连接在一起帮助。

计划应该是在Intel 8086上运行,我需要使用MASM或EMU8086作为汇编/模拟器。请推荐一个C编译器,也是一个方法,使简单的C程序,它是能够调用组装过程,并获得返回的值。

如何传递一个字符串,这个外部函数?结果
我怎样才能连接ASM文件和C文件? (如何将编译器知道哪里是定义/ code此过程?)结果
我怎样才能在汇编语言从C发送的字符串,还怎么整数返回到C?


解决方案

  

建议C编译器


没有足够的信息,但是,如果你的平台够显著,有机会,GCC已经支持了。


  

,也是一个方法,使简单的C程序,它是能够调用组装过程,并获得返回的值。


编写简单的C程序中使用文本编辑器的方式。 (哦,等一下,你有兴趣在code这里有云:?

 的#include<&stdio.h中GT;EXTERN INT富();诠释的main()
{
    INT I = foo的();
    的printf(%d个\\ N,I);
    返回0;
}

I need to develop a procedure for Assembly language and call that procedure from C language (pass a string and return an integer value). My assembly procedure works fine "stand-alone". I need help with connecting them together.

Program is supposed to run on Intel 8086. I need to use MASM or emu8086 as assembler/simulator. Kindly recommend a C compiler and also a way to make the simple C program that is able to call the assembly procedure and get the returned value.

How can I pass a string to this external function?
How can I connect the ASM file and the C file? (How will the compiler know where is the definition/code for this procedure?)
How can I get the string sent from C in Assembly language, also how to return the integer to C?

解决方案

recommend a C compiler

Not enough info, however if your platform is significant enough, chances are that GCC already supports it.

and also a way to make the simple C program that is able to call the assembly procedure and get the returned value.

The way for writing simple C programs is using a text editor. (Oh wait, you're interested in the code? Here it goes:

#include <stdio.h>

extern int foo();

int main()
{
    int i = foo();
    printf("%d\n", i);
    return 0;
}

这篇关于英特尔8086汇编程序从C调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆