如何在C#中混合汇编代码 [英] How to mix assembly code in C#

查看:163
本文介绍了如何在C#中混合汇编代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如何在C#中混合汇编代码?

我记得在pascal中我们可以这样混合:

Hi,
How to mix assembly code in C# ?

I remember in pascal we could mix like this:

function GetCharacter ( x, y : word ) : byte; assembler;
asm
PUSH    BP
MOV BP,SP
PUSH    SI
PUSHF
CLD
{...}
end;



但是,C#的解决方案是什么?

谢谢.



But, what''s the solution in C#?

Thank you.

推荐答案

尝试
在C#中使用非托管代码和汇编器 [ ^ ]
组装操作和C#/VB.NET代码注入 [ ^ ]
Try
Using Unmanaged code and assembler in C#[^]
Assembly Manipulation and C# / VB.NET Code Injection[^]


您可以编写一个C dll,然后从C#调用C代码.这就是我的操作方式-顺便说一下,这在Abhinav的第一个链接中进行了介绍.
You can write a C dll, and then invoke the C code from C#. That''s how I do it - and by the way, that is described in Abhinav''s first link above.


没办法. C#是托管代码,但程序集不受托管.
您只能将非托管dll导入程序.
使用[DllImport("dllname.dll")]
No way. C# is a managed code but assembly is unmanaged.
You can only import unmanaged dlls to your program.
use [DllImport("dllname.dll")]


这篇关于如何在C#中混合汇编代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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