【发布时间】:2020-10-02 23:05:11
【问题描述】:
为什么从 C 调用函数 Assembly 时我不能在汇编代码的 ror 处使用 rsi
出现错误:操作码和操作数的组合无效
帮帮我谢谢
汇编代码:
section .text
global en_code
en_code:
mov ax,[rdi]
ror ax,rsi ;????
mov [r13],ax
mov rax,r13
ret
C 代码:
#include<stdio.h>
#include<string.h>
extern char* en_code();
int main()
{
printf("Here:%s .\n",en_code("ng",2));
return 0;
}
【问题讨论】:
-
如果您坚持将 16 位输入通过内存中的引用而不是在寄存器本身中返回为一个 uint16_t。
r13不用于 x86-64 System V 中的参数传递,IDK 为什么您要从源字符串加载并通过 R13 存储。 -
另外,您不需要 asm 来获取旋转指令。 C 编译器可以发出它们:Best practices for circular shift (rotate) operations in C++
-
我没有组装经验并尝试做一些简单的例子
标签: c assembly x86-64 bit-shift