Home » Java » How can write assembly function for summing in java for double value?-Exceptionshub

How can write assembly function for summing in java for double value?-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have assembly function for summing integer, I tried to write code for double value, but I got an error.

My java class:

public class TestJNI {    
    public native static double sum(double x, double y);    
}

Header:

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class TestJNI */

#ifndef _Included_TestJNI
#define _Included_TestJNI
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     TestJNI
 * Method:    sum
 * Signature: (II)I
 */
JNIEXPORT jdouble JNICALL Java_TestJNI_sum
  (JNIEnv *, jclass, jdouble, jdouble);

#ifdef __cplusplus
}
#endif
#endif

My native code in the library:

global Java_TestJNI_sum

Java_TestJNI_sum:
    fld dword [r8]
    fld dword [r9]
    fadd st0,st1
    fstp dword [rax]
    ret 32
end

How to solve this?

How to&Answers: