[英]Move the value of an array of character to register x86 inline assembly
I'm doing an inline assembly coding with Microsoft Visual C++ 2010 Express. 我正在使用Microsoft Visual C ++ 2010 Express进行内联汇编编码。
I have this kind of code. 我有这种代码。 The main point is I need to access each single character of an array of character.
要点是我需要访问一个字符数组的每个单个字符。 Below is just an not that relevant example, when it reach the end of the string (the terminating null character) it will jump to finish or else it will separate each character of the string with a new line.
下面只是一个不相关的示例,当它到达字符串的末尾(终止的空字符)时,它将跳至结束,否则它将用新行分隔字符串的每个字符。
line[10] = "I am Kevin";
format[] = "%c\n";
_asm {
mov ebx,0
loop:
cmp line[ebx],0
jz finish
mov eax, line[ebx]
push eax
lea eax, format
push eax
call printf
jmp loop
finish:
....
}
Somehow I keep having error for this line: 不知何故,我在此行中一直出错:
mov eax, line[ebx]
It kept on saying error C2443: operand size conflict
它一直说
error C2443: operand size conflict
" eax
" describes 32 bits of register a
. “
eax
”描述寄存器a
32位。
The low 8 bits of register a
is al
. 寄存器
a
的低8位为al
。 This will move 8 bits: 这将移动8位:
mov al, line[ebx]
使用零扩展字节加载insn movzx
:
movzx eax, line[ebx]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.