我在我的C代码中写了一小段内联汇编代码。 该汇编代码遍历一个数组,如果需要,将另一个数组中的值移动到寄存器中。 最后,调用一个中断。 代码类似于下面这样:
cmp arrPointer[2],1h
jne EXIT
mov AX, shortArrPtr[2]
EXIT:
int 3h
在x86中,这些都可以正常工作。但据微软称,x64不支持内联汇编。我该如何将其全部翻译为x64支持的形式?我无法找到编译器内置过程来执行我想要的操作,也无法弄清楚如何将参数传递给外部汇编文件。
我在我的C代码中写了一小段内联汇编代码。 该汇编代码遍历一个数组,如果需要,将另一个数组中的值移动到寄存器中。 最后,调用一个中断。 代码类似于下面这样:
cmp arrPointer[2],1h
jne EXIT
mov AX, shortArrPtr[2]
EXIT:
int 3h
void *someOperation(void *parameter1, int parameter2);
myAssemblyFile.s:
.text
.globl someOperation
someOperation:
add %rdx, %rcx
mov %rcx, %rax
ret
.end
mySourceCode.c:
#include "myHeader.h"
void someFunction(void)
{
void *arg1 = (void *)0x80001000;
int arg2 = 12;
void *returnValue;
printf("Calling with %x %x\n", arg1, arg2);
// call assembly function
returnValue = someOperation(arg1, arg2);
printf("Returned: %x\n", returnValue);
}
int 3h
用于跳转到调试器,我会说翻译为assert(0)
。 - avakar