0

出于某种原因,我的 cmp 语句总是会导致jeto DoubleScore,而不是jne函数RegularScore。我对组装相当陌生,所以这可能是一个简单的错误。

  Approved:
                        mov eax,[prev]
                        mov edi,  dword[buffermaze+eax]
                        mov eax,edi
                        call print_nl
                        call print_int
                        mov eax, 45
                        call print_nl
                        call print_int

                        cmp eax,edi
                        je DoubleScore
                        dump_regs 1
                        jne RegularScore
                        dump_regs 2

                                DoubleScore:
                                        mov ebx,0
                                        ret
                                RegularScore:

                                        mov edx, 0
                                        mov eax,[new]

                                            ret


The Output for this part of the code is 
774778411
45
Register Dump # 1
EAX = 0000002D EBX = F7704FF4 ECX = 00000000 EDX = 00000000
ESI = 0804A434 EDI = 2E2E2E2B EBP = FFF2D4E8 ESP = FFF2D4C4
EIP = 080487B0 FLAGS = 0283       SF          CF
4

2 回答 2

0

我认为这是因为代码片段

 call print_nl 
 call print_int

这两个函数可能会对寄存器 eax 和 edi 做一些事情。您是否尝试过调试代码?

编辑: jne RegularScore指的是 DumpRegs2,而不是cmp eax, edi

在我看来应该是这样的:

                cmp eax,edi
                je DoubleScore
                dump_regs 1
                ;here we will handle the regularScore


                                mov edx, 0
                                mov eax,[new]

                                    ret


                        DoubleScore:
                                mov ebx,0
                                ret
于 2013-11-28T05:59:44.523 回答
0

这行得通吗?

    cmp eax,edi
    je DoubleScore // if equal jmps to DoubleScore and jmps back to passedNotEqual
    jmp RegularScore // if je fails, jmps to RegularScore and returns normal
passedNotEqual:

        DoubleScore:
                mov ebx,0
                dump_regs 1
                jmp passedNotEqual

        RegularScore:

                mov edx, 0
                mov eax,[new]
                dump_regs 2
                ret
于 2013-11-28T11:53:20.297 回答