Conditional operator “ ? : ”

后端 未结 3 1311
盖世英雄少女心
盖世英雄少女心 2021-01-13 18:24

I\'ve done my programming exam in C yesterday. There was a question I could not answer, and even though I\'ve studied today I can\'t come up with a solution.

So we h

3条回答
  •  醉梦人生
    2021-01-13 19:02

    Why not to surprise your teacher with very detailed explanation of what is happening ;)

        ...
        mov     eax, dword ptr [rbp - 16]       ; get C
        xor     eax, -1                         ; negate C
        mov     ecx, dword ptr [rbp - 8]        ; get A
        mov     edx, ecx                        ; put A into edx
        add     edx, -1                         ; add -1 to edx => A--
        mov     dword ptr [rbp - 8], edx        ; store result inside A
        sub     eax, ecx                        ; substract from ~C what was the result of A--
        mov     dword ptr [rbp - 8], eax        ; store it inside variable A
        ...
    

提交回复
热议问题