我需要用 Java 代码为我大学的任务编写一些程序集注入。我有一个具有本机功能的课程
import java.io.File;
public class AsmOR {
static {
String path = System.getProperty("user.dir");
System.load(path+File.separator+"mydll.dll");
}
public static native int or(int num1, int num2);
}
然后我使用命令 javac -h AsmOR.java 编译了这个类,我得到了标题。
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_user_AsmFun_AsmOR */
#ifndef _Included_org_user_AsmFun_AsmOR
#define _Included_org_user_AsmFun_AsmOR
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_user_AsmFun_AsmOR
* Method: or
* Signature: (II)I
*/
JNIEXPORT jint JNICALL Java_org_user_AsmFun_AsmOR_or
(JNIEnv *, jclass, jint, jint);
#ifdef __cplusplus
}
#endif
#endif
我用汇编这个汇编代码,但我不明白为什么函数的参数是r8和r9。我试图阅读 javadoc,但它没用。
global Java_org_user_AsmFun_AsmOR_or
Java_org_user_AsmFun_AsmOR_or:
mov rax,r8
or rax,r9
ret 32
end
另外,我想使用协处理器进行双倍求和,但它不起作用。
fld dword [r8]
fld dword [r9]
fadd st0,st1
fistp dword [rax]
ret 32
如何做到这一点以及如何区分系统的32位和64位版本并根据版本加载dll库?