C とアセンブリの連携に関する問題があります。テーブル ポインタをアセンブラ関数に送信するプログラムを書きたいと思います。この関数では、テーブルにデータが入力され、次に C に返され、結果が出力に書き込まれます。
次のコードは C 部分に関連しています。
#include <stdio.h>
extern int oblicz(double,double, double, double, int, double *);//a signature of an exter assembly function
int oblicz(double,double, double, double, int, double *);// the last position is a pointer of my table
//(some code)
size =(int)k;
tab = (double *)malloc(sizeof(double)*(size+1)); // alocation of memory
if (oblicz(a,b,P,Q,size,tab)) //the function
{
for(i;i<size;i++)
printf ("a result on %d index is %.10g \n",i, tab[i] );
}
組立部品:
%define a qword [ebp+8]
%define b qword [ebp+16]
%define P qword [ebp+24]
%define Q qword [ebp+32]
%define sizet dword [ebp+40]
%define tab dword [ebp+44]// the table pointer
コードの達成を簡単にするために、タブ[0]のみを設定する以下の構文を使用しました
;i omited setting frame etc.
xor ebx,ebx
mov ebx, tab
mov qword [ebx], 4
そしてCの結果は
a result on: 0 -is 1.669124542e-307 // it is always the same independently of value in this line : "mov qword [ebx], 4"
何が間違っている可能性があるかについての提案に感謝します