2013-05-06 824 views
1

不正确的操作数类型的含义是什么?使用__asm不正确的操作数类型错误

我想一些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 

} 
+0

什么你是否正在尝试**?哪一行出现该错误? – 2013-05-06 20:16:53

+0

mov temp_char,[eax + OChars] – 2013-05-06 20:23:52

+0

您正尝试将数组移入寄存器。那不是bueno。 – inetknght 2013-05-06 20:24:50

回答

5

你不能直接从内存中移动的东西存储在x86 - 你必须去通过寄存器 - 线沿线的:

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

其在mov mov_char中的操作数大小冲突bx – 2013-05-06 20:44:20

+0

temp_char声明为什么? – 2013-05-06 22:56:03

+0

这给我修好了。 – rev 2014-05-31 23:59:19

相关问题