1
后,ebx寄存器的值发生了变化。我是汇编中的新手,我试图在汇编中执行一些任意的精确算术操作。但是我陷入了一整天的错误。在执行“mov eax,[edx + ebx]”程序集(NASM)
mov eax,[ebp+8] ; the first parameter of c function
mov edx,[ebp+12] ; the second parameter of c function
sub ecx,ecx
sub ebx,ebx
for_loop2:
cmp ecx,[noktadanSonraFark] ; [noktadanSonraFark] is a variable that contains the difference of the lenghts of the two parameters
je end_for2
mov ebx,[length2] ; the length of the second parameter "9"
sub ebx,1 ; if length is 9 the last chacter will be on 8. index
sub ebx,ecx
mov eax, [edx+ebx] ; must show the character at the 8.index
mov eax,ebx ; this 4 line returns thee value stored in eax to the
pop ebx ; c function. and the result is printed
pop ebp
ret
inc ecx
jmp for_loop2
我的问题是没有什么打印到屏幕上。但是当我评论此行mov eax, [edx+ebx]
ebx值正确打印“8”因此,看起来这行mov eax, [edx+ebx]
更改ebx中的值或删除它。因为没有东西印在屏幕上。有任何想法吗?
为什么两个MOV在相邻的行上进入EAX? – 2011-05-19 22:31:41
因为使用ret命令,eax中的值返回给调用者函数。在我们的例子中,它是一个打印eax结果的c函数。我希望看到ebx寄存器中的值,因为我将它移动到eax然后返回。但通常我不需要以mov eax,ebx开头的四行。当我看到ebx中的值是正确的,我会删除它们。所以我用它只是为了调试 – Alptugay 2011-05-19 22:38:09
这是否应该是一个字符或整数的返回?如果您在预期字符时返回数字8,则不会看到任何输出。 (将一个数字从0-9转换为一个字符的简单方法是添加48) – ughoavgfhw 2011-05-19 22:47:02