实际上,我正在将 NASM 用于我的学术项目。这个想法是为数学运算构建一个静态库。
我已经能够在不同的 asm 文件中构建单独的函数。示例:
add_vectorial
- 有 3 个参数:
- d,尺寸
- v1, float 数组
- v2, float 数组
- rt,必须包含运算结果的 float 数组
- 有 3 个参数:
子 vector
- 有 3 个参数:
- d,尺寸
- v1, float 数组
- v2, float 数组
- rt,必须包含运算结果的 float 数组
- 有 3 个参数:
但是我有第三个 asm 文件,它必须调用 2 个函数:add_vectorial 和 sub_vectorial 来进行一些微积分。
我读到我必须使用调用词来调用我的外部函数。但我不知道如何传递参数?
我的代码示例:
extern add_vectorial
global operation: ;for linux
operation:
;Initialize a stack frame
push ebp
mov ebp, esp
;Loading the arguments values
mov ebx, [ebp+8] ; ebx='d'
mov ecx, [ebp+12] ; ecx='v1'
mov edx, [ebp+16] ; edx='v2'
mov eax, [ebp+20] ; eax = rt
;Initial the xmm4 registry with zero.
xorps xmm4, xmm4
.body:
;Here, How can i pass the parameters to my asm external function?
call add_vectorial
.done:
;Restore the call's stack frame pointer
leave ; mov esp,ebp / pop ebp
ret ; return from function
最佳答案
感谢大家的支持...终于我找到了解决问题的一个方法...我留下了我的解决方案..
%macro call_fun1 4
pushad ;I put this
push %4
push %3
push %2
push %1
call sub_vectorial
add esp, 16 ;4p*4bytes
popad ;I put this
%endmacro
关于c - 如何从另一个汇编文件调用汇编函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37336297/