gpt4 book ai didi

c++ - 使用 __asm 时出现不正确的操作数类型错误

转载 作者:行者123 更新时间:2023-11-30 01:22:23 25 4
gpt4 key购买 nike

不正确的操作数类型是什么意思?

我正在尝试将一些 C++ 代码转换为汇编程序

     temp_char = OChar[i]         //temp_char is a character and OChar is array and i is the index

我试过了

     mov eax, i
mov temp_char, [eax+OChar]

还有

     mov eax, i
movsx temp_char, [eax+OChar]

谁能解释我如何避免不正确的操作数类型?

这是完整的代码

                  char temp_char;                       
int i;

__asm{

mov i,0
jmp checkend

startfor: mov eax,i
add eax,1
mov i,eax



checkend: cmp i,length
jge endloop
movsx temp_char, [eax+OChars]

//encryption of string//
push eax
and eax,0xAA
not al
mov edx,eax
pop eax
and eax,0x55

xor ecx,edx
xor ecx,eax
rol cl,2

sub al,0x20
pop ebp

//end of encryption//
movsx [eax+EChars], temp_char
jmp startfor
endloop: ret

}

最佳答案

您不能在 x86 上将内容直接从一个内存移动到另一个内存 - 您必须通过寄存器 - 按照以下方式:

 mov eax, i
mov bx, word ptr [eax+OChar]
mov temp_char, bx

关于c++ - 使用 __asm 时出现不正确的操作数类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16406506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com