微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

执行“ mov eax [edx + ebx]”汇编程序NASM后,ebx寄存器的值更改

如何解决执行“ mov eax [edx + ebx]”汇编程序NASM后,ebx寄存器的值更改

我是汇编的新手,我正在尝试在汇编中进行任意精度的算术运算。但是我整天陷入了错误
    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
我的问题是屏幕上没有任何内容。但是,当我在第1行注释时,ebx值正确打印为\“ 8 \”,因此似乎第1行更改了ebx中的值或将其删除了。因为没有任何内容打印到屏幕上。有任何想法吗?     

解决方法

最有可能的问题是指令“ 1”正试图访问您的程序无权访问的内存地址。这会导致程序崩溃。因此,没有输出。可以肯定的是,访问
[edx+ebx]
不会修改这两个寄存器中的任何一个。 您说如果注释掉该行,则事情按预期进行,并且输出为\“ 8 \”,即
ebx
的值。您检查了
edx
的值吗?     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。