[英]How do I assign elements of an array to a variable in x86 Assembly?
我有一个char数组和一个temp_char变量,我想将给定索引处的char传递给我的temp_char变量,但是我真的不知道该怎么做。
我本来以为
mov temp_char,[index*4+CharsArray]
本来可以,但是不会编译。
movzx ecx,[index*4+CharsArray]
mov temp_char,cl
将编译,但随后导致程序中断。
我找不到任何能真正说明如何在组装中将事物放入或从阵列中取出的东西,如果有人可以指出正确的方向,那我将不胜感激。 到目前为止,我已经能够弄明白所有事情并使其正常工作,但这使我完全陷入了困境。
谢谢。
聚苯乙烯
我正在尝试使用全局数组将C ++中的for循环转换为__asm以进行分配
for循环基本上是这样的:
for(int i(0); i<length; ++i)
{
temp_char = CharArray[i]
// do other stuff
}
所以对于我的__asm
void myfunction(int length) {
char temp_char
int index
__asm{
mov ebx, len ;for part
mov index,0
jmp checkend
forloop: mov edx,index ;add one to index
add edx,1
mov index,edx
checkend: cmp index,ebx ; check to see if completed
jge endfor
mov temp_char,[index*4,CharsArray] ; program breaks here
//do other stuff
如果我的其他程序集都是废话,我也不会太在意,一旦我可以将数组中的字符读入temp变量中,就可以解决这个问题。
希望事情变得更清楚。
PPS
好吧,显然我必须从数组转移到寄存器,再转移到可变变量,很公平,我理解这一点。 唯一的问题是我该怎么做? 我可以编译代码的唯一方法是使用上述代码:
movzx ecx, [index*4+CharsArray] ;as soon as program gets here it throws exception
mov temp_char, cl
我想知道的是,如果有人可以帮助,以上两行代码应该如何工作。
谢谢。
只加载cl怎么样:
mov cl, [index*4+nCharsArray]
mov temp_char, cl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.