Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables 使用变量指向字符串中的特定字符_Variables_Assembly_X86_Nasm - Fatal编程技术网

Variables 使用变量指向字符串中的特定字符

Variables 使用变量指向字符串中的特定字符,variables,assembly,x86,nasm,Variables,Assembly,X86,Nasm,我正在开发一个程序,在这个程序中,当用户在字符串中移动时,我需要能够更改字符串中特定位置的字符,并且我希望使用一个变量来存储用户在字符串中的位置 在处理程序的其他部分时,我临时使用了下面的代码,其中buffer是我的字符串: mov eax, buffer mov byte [eax + 14], '@' 在已完成的程序中,我想使用如下内容: mov byte [eax + position], '@' 然而,当我使用上面的行时,位置设置为14,我得到了一个分段错误。如何使用变量指向字符串中

我正在开发一个程序,在这个程序中,当用户在字符串中移动时,我需要能够更改字符串中特定位置的字符,并且我希望使用一个变量来存储用户在字符串中的位置

在处理程序的其他部分时,我临时使用了下面的代码,其中buffer是我的字符串:

mov eax, buffer
mov byte [eax + 14], '@'
在已完成的程序中,我想使用如下内容:

mov byte [eax + position], '@'
然而,当我使用上面的行时,位置设置为14,我得到了一个分段错误。如何使用变量指向字符串中的特定点

编辑:位置变量设置如下:

segment .data
position db 14

好的。。。[eax+职位]是eax+职位地址。您需要[eax+[position]],而我们没有此类指示。做一些类似mov ecx、[position]使位置dd而不是db!那么[eax+ecx]应该可以工作。

什么是
位置
,如何将其设置为14?它是一个标签、一个常数、一个寄存器吗?我在
段下设置
位置
。数据
位置db 14
。这是一个好问题,我把它添加到我的主要帖子中。
[eax+职位]
是eax+职位地址。您需要
[eax+[position]]
,而我们没有此类指示。执行类似于
mov ecx、[position]
Make position dd not db!那么
[eax+ecx]
应该可以工作了。@FrankKotler,工作得很好!非常感谢。如果你想把它作为正式答复,我会接受的。