如何将数组的元素分配给 x86 程序集中的变量
How do I assign elements of an array to a variable in x86 Assembly?
我有一个字符数组和一个temp_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
如果我的另一个程序集都是废话,我不会太烦恼,一旦我可以将我的字符从我的数组读取到我的临时变量中,我就可以解决这个问题。
希望这能更清楚。
.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
相关文章:
- 如何将C++子例程链接到 x86 程序集程序?
- 将内联程序集尾调用函数尾声替换为用于x86/x64 msvc的Intrinsics
- 将程序从x86转换为x64
- 参数传递和返回值如何在程序集级别的 x86 上的 C/C++ 中工作?
- x86-64 程序集:为什么偏移 25 字节
- C DLL通过C#UWP应用程序中的Win运行时组件适用于ARM,但对于X86/X64不适用于
- 如何使用 x86 程序集在 c 中访问 main 函数中的变量
- 移动字符数组的值以注册 x86 内联程序集
- 程序集asm x86加密/解密程序
- 从我的 C/C++ 代码 - x86 和 ARM 获取程序集等效代码
- C++ ASM x86 加密/解密程序
- 在c++中使用x64系统和x86应用程序分配大内存
- 使用x86程序集的信号量实现
- x86英特尔程序集和C++-数组周围的堆栈已损坏
- 使用交换方法x86 MASM反转程序集中的外部阵列
- 假设任何x86编译的应用程序总是在x64版本下运行是安全的吗?
- 在x86_64 linux系统上构建x86 ImageMagick应用程序
- 如何在64位x86环境下编译32位x86应用程序
- 有一个简单的程序文件/程序文件(x86)指令的c++在windows
- 复制到程序文件(x86)时无法执行我的DLL