汇编代码没有给出正确的比较结果

时间:2016-04-16 21:09:23

标签: assembly x86

int i;

    float x;

    double d;

    char c;
    x=10;
    i=19;
// below assm code for this line only.
        c=x<i;  // below ass code show c=10? why it should be 1

汇编代码:

 #   39
                # b_push_ext_addr (c)
    subl    $8, %esp
    movl    $c, (%esp)
                # b_push_ext_addr (x)
    subl    $8, %esp
    movl    $x, (%esp)
                # b_deref (float)
    movl    (%esp), %eax
    movl    (%eax), %edx
    movl    %edx, (%esp)
                # b_convert (float -> double)
    flds    (%esp)
    fstpl   (%esp)
                # b_push_ext_addr (i)
    subl    $8, %esp
    movl    $i, (%esp)
                # b_deref (signed int)
    movl    (%esp), %eax
    movl    (%eax), %edx
    movl    %edx, (%esp)
                # b_convert (signed int -> double)
    fildl   (%esp)
    fstpl   (%esp)
                # b_arith_rel_op ( < , double)
    fldl    8(%esp)
    fldl    (%esp)
    addl    $8, %esp
    fucompp
    fnstsw  %ax
    testb   $69, %ah
    sete    %al
    movzbl  %al, %eax
    movl    %eax, (%esp)
                # b_convert (double -> signed char)
    fldl    (%esp)
    subl    $8, %esp
    fnstcw  6(%esp)
    movzwl  6(%esp), %eax
    movb    $12, %ah
    movw    %ax, 4(%esp)
    fldcw   4(%esp)
    fistpl  8(%esp)
    fldcw   6(%esp)
    addl    $8, %esp
                # b_assign (signed char)
    movzbl  (%esp), %edx
    addl    $8, %esp
    movl    (%esp), %eax
    movb    %dl, (%eax)
    movb    %dl, (%esp)
                # b_pop ()
    addl    $8, %esp

1 个答案:

答案 0 :(得分:1)

movl    %eax, (%esp) # eax is an integer here!
            # b_convert (double -> signed char)
fldl    (%esp)       # you load integer as double

我没有告诉过你使用调试器吗?我们不会为您调试所有内容!