C语句和反汇编代码对照表

时间:2023-01-22 01:24:58

前言

现在还记不住C语句和对应的反汇编代码的关系,先记录一下。

代码对应关系

无符号数除以2的幂

C语句和反汇编代码对照表

int main(int argc, char* argv[])
{
    // hw1_1 验证 : 无符号数除以2的幂
    UINT uIn = (UINT)argc;

    printf("%d\r\n", uIn/2);
    printf("%d\r\n", uIn/4);
    printf("%d\r\n", uIn/8);

    system("pause");
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    esi
.text:00401001                 mov     esi, [esp+4+argc]
.text:00401005                 mov     eax, esi ; // dasm
.text:00401007                 shr     eax, 1 ; // dasm
.text:00401009                 push    eax
.text:0040100A                 push    offset Format   ; "%d\r\n"
.text:0040100F                 call    _printf
.text:00401014                 mov     ecx, esi ; // dasm
.text:00401016                 add     esp, 8
.text:00401019                 shr     ecx, 2 ; // dasm
.text:0040101C                 push    ecx
.text:0040101D                 push    offset Format   ; "%d\r\n"
.text:00401022                 call    _printf
.text:00401027                 add     esp, 8
.text:0040102A                 shr     esi, 3 ; // dasm
.text:0040102D                 push    esi
.text:0040102E                 push    offset Format   ; "%d\r\n"
.text:00401033                 call    _printf
.text:00401038                 push    offset aPause   ; "pause"
.text:0040103D                 call    _my_system
.text:00401042                 add     esp, 0Ch
.text:00401045                 xor     eax, eax
.text:00401047                 pop     esi
.text:00401048                 retn
.text:00401048 _main           endp

有符号数除以2的幂

C语句和反汇编代码对照表

int main(int argc, char* argv[])
{
    // hw1_2 验证 : 有符号数除以2的幂
    int iIn = argc;

    printf("%d\r\n", iIn/2);
    printf("%d\r\n", iIn/4);
    printf("%d\r\n", iIn/8);

    system("pause");
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    esi
.text:00401001                 mov     esi, [esp+4+argc] ; // dasm
.text:00401005                 mov     eax, esi ; // dasm
.text:00401007                 cdq ; // dasm
.text:00401008                 sub     eax, edx ; // dasm
.text:0040100A                 sar     eax, 1 ; // dasm
.text:0040100C                 push    eax
.text:0040100D                 push    offset Format   ; "%d\r\n"
.text:00401012                 call    _printf
.text:00401017                 mov     eax, esi ; // dasm
.text:00401019                 add     esp, 8
.text:0040101C                 cdq ; // dasm
.text:0040101D                 and     edx, 3 ; // dasm
.text:00401020                 add     eax, edx ; // dasm
.text:00401022                 sar     eax, 2 ; // dasm
.text:00401025                 push    eax
.text:00401026                 push    offset Format   ; "%d\r\n"
.text:0040102B                 call    _printf
.text:00401030                 mov     eax, esi ; // dasm
.text:00401032                 add     esp, 8
.text:00401035                 cdq ; // dasm
.text:00401036                 and     edx, 7 ; // dasm
.text:00401039                 add     eax, edx ; // dasm
.text:0040103B                 sar     eax, 3 ; // dasm
.text:0040103E                 push    eax
.text:0040103F                 push    offset Format   ; "%d\r\n"
.text:00401044                 call    _printf
.text:00401049                 push    offset aPause   ; "pause"
.text:0040104E                 call    _my_system
.text:00401053                 add     esp, 0Ch
.text:00401056                 xor     eax, eax
.text:00401058                 pop     esi
.text:00401059                 retn
.text:00401059 _main           endp

无符号数除以非2的幂(MagicNumber无进位)

int main(int argc, char* argv[])
{
    // hw1_3 验证 : 无符号数除以非2的幂(MagicNumber无进位)
    UINT In = (UINT)argc;

    printf("%d\r\n", In/4294967263); // -33

    printf("%d\r\n", In/3);
    printf("%d\r\n", In/5);
    printf("%d\r\n", In/6);
    printf("%d\r\n", In/9);

    system("pause");
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    esi
.text:00401001                 mov     esi, [esp+4+argc] ; // dasm
.text:00401005                 mov     eax, 80000011h ; // dasm
.text:0040100A                 mul     esi ; // dasm
.text:0040100C                 shr     edx, 1Fh ; // dasm
.text:0040100F                 push    edx
.text:00401010                 push    offset aD       ; "%d\r\n"
.text:00401015                 call    printf
.text:0040101A                 mov     eax, 0AAAAAAABh ; // dasm
.text:0040101F                 add     esp, 8
.text:00401022                 mul     esi ; // dasm
.text:00401024                 shr     edx, 1 ; // dasm
.text:00401026                 push    edx
.text:00401027                 push    offset aD       ; "%d\r\n"
.text:0040102C                 call    printf
.text:00401031                 mov     eax, 0CCCCCCCDh ; // dasm
.text:00401036                 add     esp, 8
.text:00401039                 mul     esi ; // dasm
.text:0040103B                 shr     edx, 2 ; // dasm
.text:0040103E                 push    edx
.text:0040103F                 push    offset aD       ; "%d\r\n"
.text:00401044                 call    printf
.text:00401049                 mov     eax, 0AAAAAAABh ; // dasm
.text:0040104E                 add     esp, 8
.text:00401051                 mul     esi ; // dasm
.text:00401053                 shr     edx, 2 ; // dasm
.text:00401056                 push    edx
.text:00401057                 push    offset aD       ; "%d\r\n"
.text:0040105C                 call    printf
.text:00401061                 mov     eax, 38E38E39h ; // dasm
.text:00401066                 add     esp, 8
.text:00401069                 mul     esi ; // dasm
.text:0040106B                 shr     edx, 1 ; // dasm
.text:0040106D                 push    edx
.text:0040106E                 push    offset aD       ; "%d\r\n"
.text:00401073                 call    printf
.text:00401078                 push    offset aPause   ; "pause"
.text:0040107D                 call    sub_401090
.text:00401082                 add     esp, 0Ch
.text:00401085                 xor     eax, eax
.text:00401087                 pop     esi
.text:00401088                 retn
.text:00401088 _main           endp

无符号数除以非2的幂(MagicNumber有进位)

int main(int argc, char* argv[])
{
    // hw1_4 验证 : 无符号数除以非2的幂(MagicNumber有进位)
    UINT In = (UINT)argc;

    printf("%d\r\n", In/7); // ok
    printf("%d\r\n", In/19); //ok
    printf("%d\r\n", In/21); // ok
    printf("%d\r\n", In/27); // ok

    system("pause");
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    esi
.text:00401001                 mov     esi, [esp+4+argc] ; // dasm
.text:00401005                 mov     eax, 24924925h ; // dasm
.text:0040100A                 mul     esi ; // dasm
.text:0040100C                 mov     eax, esi ; // dasm
.text:0040100E                 sub     eax, edx ; // dasm
.text:00401010                 shr     eax, 1 ; // dasm
.text:00401012                 add     eax, edx ; // dasm
.text:00401014                 shr     eax, 2 ; // dasm
.text:00401017                 push    eax
.text:00401018                 push    offset aD       ; "%d\r\n"
.text:0040101D                 call    sub_401136
.text:00401022                 mov     eax, 0AF286BCBh ; // dasm
.text:00401027                 mov     ecx, esi ; // dasm
.text:00401029                 mul     esi ; // dasm
.text:0040102B                 sub     ecx, edx ; // dasm
.text:0040102D                 add     esp, 8
.text:00401030                 shr     ecx, 1 ; // dasm
.text:00401032                 add     ecx, edx ; // dasm
.text:00401034                 shr     ecx, 4 ; // dasm
.text:00401037                 push    ecx
.text:00401038                 push    offset aD       ; "%d\r\n"
.text:0040103D                 call    sub_401136
.text:00401042                 mov     eax, 86186187h ; // dasm
.text:00401047                 add     esp, 8
.text:0040104A                 mul     esi ; // dasm
.text:0040104C                 mov     eax, esi ; // dasm
.text:0040104E                 sub     eax, edx ; // dasm
.text:00401050                 shr     eax, 1 ; // dasm
.text:00401052                 add     eax, edx ; // dasm
.text:00401054                 shr     eax, 4 ; // dasm
.text:00401057                 push    eax
.text:00401058                 push    offset aD       ; "%d\r\n"
.text:0040105D                 call    sub_401136
.text:00401062                 mov     eax, 2F684BDBh // dasm
.text:00401067                 add     esp, 8
.text:0040106A                 mul     esi ; // dasm
.text:0040106C                 sub     esi, edx ; // dasm
.text:0040106E                 shr     esi, 1 ; // dasm
.text:00401070                 add     esi, edx ; // dasm
.text:00401072                 shr     esi, 4 ; // dasm
.text:00401075                 push    esi
.text:00401076                 push    offset aD       ; "%d\r\n"
.text:0040107B                 call    sub_401136
.text:00401080                 push    offset aPause   ; "pause"
.text:00401085                 call    sub_4010A0
.text:0040108A                 add     esp, 0Ch
.text:0040108D                 xor     eax, eax
.text:0040108F                 pop     esi
.text:00401090                 retn
.text:00401090 _main           endp

有符号数除以非2的幂(MagicNumber为正)

int main(int argc, char* argv[])
{
    // hw1_5 验证 : 有符号数除以非2的幂(MagicNumber为正)
    int In = (UINT)argc;

    printf("%d\r\n", In/18); // ok
    printf("%d\r\n", In/19); // ok
    printf("%d\r\n", In/21); // ok
    printf("%d\r\n", In/27); // ok

    system("pause");
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    esi
.text:00401001                 mov     esi, [esp+4+argc] ; // dasm
.text:00401005                 mov     eax, 38E38E39h ; // dasm
.text:0040100A                 imul    esi ; // dasm
.text:0040100C                 sar     edx, 2 ; // dasm
.text:0040100F                 mov     eax, edx ; // dasm
.text:00401011                 shr     eax, 1Fh ; // dasm
.text:00401014                 add     edx, eax ; // dasm
.text:00401016                 push    edx
.text:00401017                 push    offset aD       ; "%d\r\n"
.text:0040101C                 call    printf
.text:00401021                 mov     eax, 6BCA1AF3h ; // dasm
.text:00401026                 add     esp, 8
.text:00401029                 imul    esi ; // dasm
.text:0040102B                 sar     edx, 3 ; // dasm
.text:0040102E                 mov     ecx, edx ; // dasm
.text:00401030                 shr     ecx, 1Fh ; // dasm
.text:00401033                 add     edx, ecx ; // dasm
.text:00401035                 push    edx
.text:00401036                 push    offset aD       ; "%d\r\n"
.text:0040103B                 call    printf
.text:00401040                 mov     eax, 30C30C31h ; // dasm
.text:00401045                 add     esp, 8
.text:00401048                 imul    esi ; // dasm
.text:0040104A                 sar     edx, 2 ; // dasm
.text:0040104D                 mov     eax, edx ; // dasm
.text:0040104F                 shr     eax, 1Fh ; // dasm
.text:00401052                 add     edx, eax ; // dasm
.text:00401054                 push    edx
.text:00401055                 push    offset aD       ; "%d\r\n"
.text:0040105A                 call    printf
.text:0040105F                 mov     eax, 4BDA12F7h ; // dasm
.text:00401064                 add     esp, 8
.text:00401067                 imul    esi ; // dasm
.text:00401069                 sar     edx, 3 ; // dasm
.text:0040106C                 mov     ecx, edx ; // dasm
.text:0040106E                 shr     ecx, 1Fh ; // dasm
.text:00401071                 add     edx, ecx ; // dasm
.text:00401073                 push    edx
.text:00401074                 push    offset aD       ; "%d\r\n"
.text:00401079                 call    printf
.text:0040107E                 push    offset aPause   ; "pause"
.text:00401083                 call    sub_401090
.text:00401088                 add     esp, 0Ch
.text:0040108B                 xor     eax, eax
.text:0040108D                 pop     esi
.text:0040108E                 retn
.text:0040108E _main           endp

有符号数除以非2的幂(MagicNumber为负)

int main(int argc, char* argv[])
{
    // hw1_6 验证 : 有符号数除以非2的幂(MagicNumber为负)
    int In = (UINT)argc;

    printf("%d\r\n", In/28);
    printf("%d\r\n", In/29);
    printf("%d\r\n", In/30);
    printf("%d\r\n", In/31);

    system("pause");
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    esi
.text:00401001                 mov     esi, [esp+4+argc] ; // dasm
.text:00401005                 mov     eax, 92492493h ; // dasm
.text:0040100A                 imul    esi ; // dasm
.text:0040100C                 add     edx, esi ; // dasm
.text:0040100E                 sar     edx, 4 ; // dasm
.text:00401011                 mov     eax, edx ; // dasm
.text:00401013                 shr     eax, 1Fh ; // dasm
.text:00401016                 add     edx, eax ; // dasm
.text:00401018                 push    edx
.text:00401019                 push    offset aD       ; "%d\r\n"
.text:0040101E                 call    sub_401136
.text:00401023                 mov     eax, 8D3DCB09h ; // dasm
.text:00401028                 add     esp, 8
.text:0040102B                 imul    esi ; // dasm
.text:0040102D                 add     edx, esi ; // dasm
.text:0040102F                 sar     edx, 4 ; // dasm
.text:00401032                 mov     ecx, edx ; // dasm
.text:00401034                 shr     ecx, 1Fh ; // dasm
.text:00401037                 add     edx, ecx ; // dasm
.text:00401039                 push    edx
.text:0040103A                 push    offset aD       ; "%d\r\n"
.text:0040103F                 call    sub_401136
.text:00401044                 mov     eax, 88888889h ; // dasm
.text:00401049                 add     esp, 8
.text:0040104C                 imul    esi ; // dasm
.text:0040104E                 add     edx, esi ; // dasm
.text:00401050                 sar     edx, 4 ; // dasm
.text:00401053                 mov     eax, edx ; // dasm
.text:00401055                 shr     eax, 1Fh ; // dasm
.text:00401058                 add     edx, eax ; // dasm
.text:0040105A                 push    edx
.text:0040105B                 push    offset aD       ; "%d\r\n"
.text:00401060                 call    sub_401136
.text:00401065                 mov     eax, 84210843h ; // dasm
.text:0040106A                 add     esp, 8
.text:0040106D                 imul    esi ; // dasm
.text:0040106F                 add     edx, esi ; // dasm
.text:00401071                 sar     edx, 4 ; // dasm
.text:00401074                 mov     ecx, edx ; // dasm
.text:00401076                 shr     ecx, 1Fh ; // dasm
.text:00401079                 add     edx, ecx ; // dasm
.text:0040107B                 push    edx
.text:0040107C                 push    offset aD       ; "%d\r\n"
.text:00401081                 call    sub_401136
.text:00401086                 push    offset aPause   ; "pause"
.text:0040108B                 call    sub_4010A0
.text:00401090                 add     esp, 0Ch
.text:00401093                 xor     eax, eax
.text:00401095                 pop     esi
.text:00401096                 retn
.text:00401096 _main           endp

有符号数除以-2的幂

int main(int argc, char* argv[])
{
    // hw1_7 验证 : 有符号数除以-2的幂
    int uIn = argc;

    printf("%d\r\n", uIn/-2);
    printf("%d\r\n", uIn/-4);
    printf("%d\r\n", uIn/-8);

    system("pause");
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    esi
.text:00401001                 mov     esi, [esp+4+argc] ; // dasm
.text:00401005                 mov     eax, esi ; // dasm
.text:00401007                 cdq ; // dasm
.text:00401008                 sub     eax, edx ; // dasm
.text:0040100A                 sar     eax, 1 ; // dasm
.text:0040100C                 neg     eax ; // dasm
.text:0040100E                 push    eax
.text:0040100F                 push    offset aD       ; "%d\r\n"
.text:00401014                 call    sub_4010F6
.text:00401019                 mov     eax, esi ; // dasm
.text:0040101B                 add     esp, 8
.text:0040101E                 cdq ; // dasm
.text:0040101F                 and     edx, 3 ; // dasm
.text:00401022                 add     eax, edx ; // dasm
.text:00401024                 sar     eax, 2 ; // dasm
.text:00401027                 neg     eax ; // dasm
.text:00401029                 push    eax
.text:0040102A                 push    offset aD       ; "%d\r\n"
.text:0040102F                 call    sub_4010F6
.text:00401034                 mov     eax, esi ; // dasm
.text:00401036                 add     esp, 8
.text:00401039                 cdq ; // dasm
.text:0040103A                 and     edx, 7 ; // dasm
.text:0040103D                 add     eax, edx ; // dasm
.text:0040103F                 sar     eax, 3 ; // dasm
.text:00401042                 neg     eax ; // dasm
.text:00401044                 push    eax
.text:00401045                 push    offset aD       ; "%d\r\n"
.text:0040104A                 call    sub_4010F6
.text:0040104F                 push    offset aPause   ; "pause"
.text:00401054                 call    sub_401060
.text:00401059                 add     esp, 0Ch
.text:0040105C                 xor     eax, eax
.text:0040105E                 pop     esi
.text:0040105F                 retn
.text:0040105F _main           endp

有符号数除以非-2的幂(MagicNumber为正)

int main(int argc, char* argv[])
{
    // hw1_8 验证 : 有符号数除以非-2的幂(MagicNumber为正)
    int In = (UINT)argc;

    printf("%d\r\n", In/-3);
    printf("%d\r\n", In/-7);
    printf("%d\r\n", In/-14);
    printf("%d\r\n", In/-15);

    system("pause");
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    esi
.text:00401001                 mov     esi, [esp+4+argc] ; // dasm
.text:00401005                 mov     eax, 55555555h ; // dasm
.text:0040100A                 imul    esi ; // dasm
.text:0040100C                 sub     edx, esi ; // dasm
.text:0040100E                 sar     edx, 1 ; // dasm
.text:00401010                 mov     eax, edx ; // dasm
.text:00401012                 shr     eax, 1Fh ; // dasm
.text:00401015                 add     edx, eax ; // dasm
.text:00401017                 push    edx
.text:00401018                 push    offset aD       ; "%d\r\n"
.text:0040101D                 call    sub_401136
.text:00401022                 mov     eax, 6DB6DB6Dh ; // dasm
.text:00401027                 add     esp, 8
.text:0040102A                 imul    esi ; // dasm
.text:0040102C                 sub     edx, esi ; // dasm
.text:0040102E                 sar     edx, 2 ; // dasm
.text:00401031                 mov     ecx, edx ; // dasm
.text:00401033                 shr     ecx, 1Fh ; // dasm
.text:00401036                 add     edx, ecx ; // dasm
.text:00401038                 push    edx
.text:00401039                 push    offset aD       ; "%d\r\n"
.text:0040103E                 call    sub_401136
.text:00401043                 mov     eax, 6DB6DB6Dh ; // dasm
.text:00401048                 add     esp, 8
.text:0040104B                 imul    esi ; // dasm
.text:0040104D                 sub     edx, esi ; // dasm
.text:0040104F                 sar     edx, 3 ; // dasm
.text:00401052                 mov     eax, edx ; // dasm
.text:00401054                 shr     eax, 1Fh ; // dasm
.text:00401057                 add     edx, eax ; // dasm
.text:00401059                 push    edx
.text:0040105A                 push    offset aD       ; "%d\r\n"
.text:0040105F                 call    sub_401136
.text:00401064                 mov     eax, 77777777h ; // dasm
.text:00401069                 add     esp, 8
.text:0040106C                 imul    esi ; // dasm
.text:0040106E                 sub     edx, esi ; // dasm
.text:00401070                 sar     edx, 3 ; // dasm
.text:00401073                 mov     ecx, edx ; // dasm
.text:00401075                 shr     ecx, 1Fh ; // dasm
.text:00401078                 add     edx, ecx ; // dasm
.text:0040107A                 push    edx
.text:0040107B                 push    offset aD       ; "%d\r\n"
.text:00401080                 call    sub_401136
.text:00401085                 push    offset aPause   ; "pause"
.text:0040108A                 call    sub_4010A0
.text:0040108F                 add     esp, 0Ch
.text:00401092                 xor     eax, eax
.text:00401094                 pop     esi
.text:00401095                 retn
.text:00401095 _main           endp

有符号数除以非-2的幂(MagicNumber为负)

int main(int argc, char* argv[])
{
    // hw1_9 验证 : 有符号数除以非-2的幂(MagicNumber为负)
    int In = (UINT)argc;

    printf("%d\r\n", In/-33);
    printf("%d\r\n", In/-34);
    printf("%d\r\n", In/-36);

    system("pause");
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    esi
.text:00401001                 mov     esi, [esp+4+argc] ; // dasm
.text:00401005                 mov     eax, 0C1F07C1Fh ; // dasm
.text:0040100A                 imul    esi ; // dasm
.text:0040100C                 sar     edx, 3 ; // dasm
.text:0040100F                 mov     eax, edx ; // dasm
.text:00401011                 shr     eax, 1Fh ; // dasm
.text:00401014                 add     edx, eax ; // dasm
.text:00401016                 push    edx
.text:00401017                 push    offset aD       ; "%d\r\n"
.text:0040101C                 call    sub_401106
.text:00401021                 mov     eax, 87878787h ; // dasm
.text:00401026                 add     esp, 8
.text:00401029                 imul    esi ; // dasm
.text:0040102B                 sar     edx, 4 ; // dasm
.text:0040102E                 mov     ecx, edx ; // dasm
.text:00401030                 shr     ecx, 1Fh ; // dasm
.text:00401033                 add     edx, ecx ; // dasm
.text:00401035                 push    edx
.text:00401036                 push    offset aD       ; "%d\r\n"
.text:0040103B                 call    sub_401106
.text:00401040                 mov     eax, 0C71C71C7h ; // dasm
.text:00401045                 add     esp, 8
.text:00401048                 imul    esi ; // dasm
.text:0040104A                 sar     edx, 3 ; // dasm
.text:0040104D                 mov     eax, edx ; // dasm
.text:0040104F                 shr     eax, 1Fh ; // dasm
.text:00401052                 add     edx, eax ; // dasm
.text:00401054                 push    edx
.text:00401055                 push    offset aD       ; "%d\r\n"
.text:0040105A                 call    sub_401106
.text:0040105F                 push    offset aPause   ; "pause"
.text:00401064                 call    sub_401070
.text:00401069                 add     esp, 0Ch
.text:0040106C                 xor     eax, eax
.text:0040106E                 pop     esi
.text:0040106F                 retn
.text:0040106F _main           endp

对非2的幂取模

// hw.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include <stdlib.h>

#define N2 2
#define N22 (N2 * N2)
#define N23 (N22 * N2)
#define N24 (N23 * N2)
#define N25 (N24 * N2)
#define N26 (N25 * N2)
#define N27 (N26 * N2)
#define N28 (N27 * N2)

// 对非2的幂取模
void fn1(int param);

int main(int argc, char* argv[])
{
    fn1(argc);

    return 0;
}

void fn1(int param)
{
    // 2
    printf("%d\r\n", param % 3);
    // 4
    printf("%d\r\n", param % 5);
    printf("%d\r\n", param % 6);
    printf("%d\r\n", param % 7);
    // 8
    printf("%d\r\n", param % 9);
    printf("%d\r\n", param % 10);
    printf("%d\r\n", param % 11);
    printf("%d\r\n", param % 12);
    printf("%d\r\n", param % 13);
    printf("%d\r\n", param % 14);
    printf("%d\r\n", param % 15);
    // 16
}
.text:00401010 fn1             proc near               ; CODE XREF: _main+5p
.text:00401010
.text:00401010 arg_0           = dword ptr  4
.text:00401010
.text:00401010                 push    esi
.text:00401011                 mov     esi, [esp+4+arg_0]
.text:00401015                 mov     eax, esi
.text:00401017                 mov     ecx, 3
.text:0040101C                 cdq
.text:0040101D                 idiv    ecx
.text:0040101F                 push    edx
.text:00401020                 push    offset aD       ; "%d\r\n"
.text:00401025                 call    printf
.text:0040102A                 mov     eax, esi
.text:0040102C                 mov     ecx, 5
.text:00401031                 cdq
.text:00401032                 idiv    ecx
.text:00401034                 add     esp, 8
.text:00401037                 push    edx
.text:00401038                 push    offset aD       ; "%d\r\n"
.text:0040103D                 call    printf
.text:00401042                 mov     eax, esi
.text:00401044                 mov     ecx, 6
.text:00401049                 cdq
.text:0040104A                 idiv    ecx
.text:0040104C                 add     esp, 8
.text:0040104F                 push    edx
.text:00401050                 push    offset aD       ; "%d\r\n"
.text:00401055                 call    printf
.text:0040105A                 mov     eax, esi
.text:0040105C                 mov     ecx, 7
.text:00401061                 cdq
.text:00401062                 idiv    ecx
.text:00401064                 add     esp, 8
.text:00401067                 push    edx
.text:00401068                 push    offset aD       ; "%d\r\n"
.text:0040106D                 call    printf
.text:00401072                 mov     eax, esi
.text:00401074                 mov     ecx, 9
.text:00401079                 cdq
.text:0040107A                 idiv    ecx
.text:0040107C                 add     esp, 8
.text:0040107F                 push    edx
.text:00401080                 push    offset aD       ; "%d\r\n"
.text:00401085                 call    printf
.text:0040108A                 mov     eax, esi
.text:0040108C                 mov     ecx, 0Ah
.text:00401091                 cdq
.text:00401092                 idiv    ecx
.text:00401094                 add     esp, 8
.text:00401097                 push    edx
.text:00401098                 push    offset aD       ; "%d\r\n"
.text:0040109D                 call    printf
.text:004010A2                 mov     eax, esi
.text:004010A4                 mov     ecx, 0Bh
.text:004010A9                 cdq
.text:004010AA                 idiv    ecx
.text:004010AC                 add     esp, 8
.text:004010AF                 push    edx
.text:004010B0                 push    offset aD       ; "%d\r\n"
.text:004010B5                 call    printf
.text:004010BA                 mov     eax, esi
.text:004010BC                 mov     ecx, 0Ch
.text:004010C1                 cdq
.text:004010C2                 idiv    ecx
.text:004010C4                 add     esp, 8
.text:004010C7                 push    edx
.text:004010C8                 push    offset aD       ; "%d\r\n"
.text:004010CD                 call    printf
.text:004010D2                 mov     eax, esi
.text:004010D4                 mov     ecx, 0Dh
.text:004010D9                 cdq
.text:004010DA                 idiv    ecx
.text:004010DC                 add     esp, 8
.text:004010DF                 push    edx
.text:004010E0                 push    offset aD       ; "%d\r\n"
.text:004010E5                 call    printf
.text:004010EA                 mov     eax, esi
.text:004010EC                 mov     ecx, 0Eh
.text:004010F1                 cdq
.text:004010F2                 idiv    ecx
.text:004010F4                 add     esp, 8
.text:004010F7                 push    edx
.text:004010F8                 push    offset aD       ; "%d\r\n"
.text:004010FD                 call    printf
.text:00401102                 mov     eax, esi
.text:00401104                 mov     ecx, 0Fh
.text:00401109                 cdq
.text:0040110A                 idiv    ecx
.text:0040110C                 add     esp, 8
.text:0040110F                 push    edx
.text:00401110                 push    offset aD       ; "%d\r\n"
.text:00401115                 call    printf
.text:0040111A                 add     esp, 8
.text:0040111D                 pop     esi
.text:0040111E                 retn
.text:0040111E fn1             endp

有符号数对2的幂取模

// hw.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include <stdlib.h>

#define N2 2
#define N22 (N2 * N2)
#define N23 (N22 * N2)
#define N24 (N23 * N2)
#define N25 (N24 * N2)
#define N26 (N25 * N2)
#define N27 (N26 * N2)
#define N28 (N27 * N2)

// 有符号数对2的幂取模
void fn2(int param);

int main(int argc, char* argv[])
{
    fn2(argc);

    return 0;
}

void fn2(int param)
{
// x % 2^n
// and 和 or 取的都是低n位
//
// mov reg, src
// and reg, 10000000000000000000000000000111b
// jns short L_END
// dec reg
// or reg, 11111111111111111111111111111000b
// inc reg

    printf("%d\r\n", param % N2);
    printf("%d\r\n", param % N22);
    printf("%d\r\n", param % N23);
    printf("%d\r\n", param % N24);
    printf("%d\r\n", param % N25);
    printf("%d\r\n", param % N26);
    printf("%d\r\n", param % N27);
    printf("%d\r\n", param % N28);
}
.text:00401010 fn2             proc near               ; CODE XREF: _main+5p
.text:00401010
.text:00401010 arg_0           = dword ptr  4
.text:00401010
.text:00401010                 push    esi
.text:00401011                 mov     esi, [esp+4+arg_0]
.text:00401015                 mov     eax, esi
.text:00401017                 and     eax, 80000001h
.text:0040101C                 jns     short L_1
.text:0040101E                 dec     eax
.text:0040101F                 or      eax, 0FFFFFFFEh
.text:00401022                 inc     eax
.text:00401023
.text:00401023 L_1:                                    ; CODE XREF: fn2+Cj
.text:00401023                 push    eax
.text:00401024                 push    offset aD       ; "%d\r\n"
.text:00401029                 call    printf
.text:0040102E                 mov     ecx, esi
.text:00401030                 add     esp, 8
.text:00401033                 and     ecx, 80000003h
.text:00401039                 jns     short L_2
.text:0040103B                 dec     ecx
.text:0040103C                 or      ecx, 0FFFFFFFCh
.text:0040103F                 inc     ecx
.text:00401040
.text:00401040 L_2:                                    ; CODE XREF: fn2+29j
.text:00401040                 push    ecx
.text:00401041                 push    offset aD       ; "%d\r\n"
.text:00401046                 call    printf
.text:0040104B                 mov     edx, esi
.text:0040104D                 add     esp, 8
.text:00401050                 and     edx, 80000007h
.text:00401056                 jns     short L_3
.text:00401058                 dec     edx
.text:00401059                 or      edx, 0FFFFFFF8h
.text:0040105C                 inc     edx
.text:0040105D
.text:0040105D L_3:                                    ; CODE XREF: fn2+46j
.text:0040105D                 push    edx
.text:0040105E                 push    offset aD       ; "%d\r\n"
.text:00401063                 call    printf
.text:00401068                 mov     eax, esi
.text:0040106A                 add     esp, 8
.text:0040106D                 and     eax, 8000000Fh
.text:00401072                 jns     short L_4
.text:00401074                 dec     eax
.text:00401075                 or      eax, 0FFFFFFF0h
.text:00401078                 inc     eax
.text:00401079
.text:00401079 L_4:                                    ; CODE XREF: fn2+62j
.text:00401079                 push    eax
.text:0040107A                 push    offset aD       ; "%d\r\n"
.text:0040107F                 call    printf
.text:00401084                 mov     ecx, esi
.text:00401086                 add     esp, 8
.text:00401089                 and     ecx, 8000001Fh
.text:0040108F                 jns     short L_5
.text:00401091                 dec     ecx
.text:00401092                 or      ecx, 0FFFFFFE0h
.text:00401095                 inc     ecx
.text:00401096
.text:00401096 L_5:                                    ; CODE XREF: fn2+7Fj
.text:00401096                 push    ecx
.text:00401097                 push    offset aD       ; "%d\r\n"
.text:0040109C                 call    printf
.text:004010A1                 mov     edx, esi
.text:004010A3                 add     esp, 8
.text:004010A6                 and     edx, 8000003Fh
.text:004010AC                 jns     short L_6
.text:004010AE                 dec     edx
.text:004010AF                 or      edx, 0FFFFFFC0h
.text:004010B2                 inc     edx
.text:004010B3
.text:004010B3 L_6:                                    ; CODE XREF: fn2+9Cj
.text:004010B3                 push    edx
.text:004010B4                 push    offset aD       ; "%d\r\n"
.text:004010B9                 call    printf
.text:004010BE                 mov     eax, esi
.text:004010C0                 add     esp, 8
.text:004010C3                 and     eax, 8000007Fh
.text:004010C8                 jns     short L_7
.text:004010CA                 dec     eax
.text:004010CB                 or      eax, 0FFFFFF80h
.text:004010CE                 inc     eax
.text:004010CF
.text:004010CF L_7:                                    ; CODE XREF: fn2+B8j
.text:004010CF                 push    eax
.text:004010D0                 push    offset aD       ; "%d\r\n"
.text:004010D5                 call    printf
.text:004010DA                 add     esp, 8
.text:004010DD                 and     esi, 800000FFh
.text:004010E3                 jns     short L_8
.text:004010E5                 dec     esi
.text:004010E6                 or      esi, 0FFFFFF00h
.text:004010EC                 inc     esi
.text:004010ED
.text:004010ED L_8:                                    ; CODE XREF: fn2+D3j
.text:004010ED                 push    esi
.text:004010EE                 push    offset aD       ; "%d\r\n"
.text:004010F3                 call    printf
.text:004010F8                 add     esp, 8
.text:004010FB                 pop     esi
.text:004010FC                 retn
.text:004010FC fn2             endp

无符号数对2的幂取模

// hw.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include <stdlib.h>

#define N2 2
#define N22 (N2 * N2)
#define N23 (N22 * N2)
#define N24 (N23 * N2)
#define N25 (N24 * N2)
#define N26 (N25 * N2)
#define N27 (N26 * N2)
#define N28 (N27 * N2)

// 无符号数对2的幂取模
void fn3(UINT param);

int main(int argc, char* argv[])
{
    fn3(argc);

    return 0;
}

void fn3(UINT param)
{
// x % 2^n 
// and 语句指出n

// mov ecx, esi
// and ecx, 11b

    printf("%d\r\n", param % N2);
    printf("%d\r\n", param % N22);
    printf("%d\r\n", param % N23);
    printf("%d\r\n", param % N24);
    printf("%d\r\n", param % N25);
    printf("%d\r\n", param % N26);
    printf("%d\r\n", param % N27);
    printf("%d\r\n", param % N28);
}
.text:00401010 fn3             proc near               ; CODE XREF: _main+5p
.text:00401010
.text:00401010 arg_0           = dword ptr  4
.text:00401010
.text:00401010                 push    esi
.text:00401011                 mov     esi, [esp+4+arg_0]
.text:00401015                 mov     eax, esi
.text:00401017                 and     eax, 1
.text:0040101A                 push    eax
.text:0040101B                 push    offset aD       ; "%d\r\n"
.text:00401020                 call    printf
.text:00401025                 mov     ecx, esi
.text:00401027                 add     esp, 8
.text:0040102A                 and     ecx, 3
.text:0040102D                 push    ecx
.text:0040102E                 push    offset aD       ; "%d\r\n"
.text:00401033                 call    printf
.text:00401038                 mov     edx, esi
.text:0040103A                 add     esp, 8
.text:0040103D                 and     edx, 7
.text:00401040                 push    edx
.text:00401041                 push    offset aD       ; "%d\r\n"
.text:00401046                 call    printf
.text:0040104B                 mov     eax, esi
.text:0040104D                 add     esp, 8
.text:00401050                 and     eax, 0Fh
.text:00401053                 push    eax
.text:00401054                 push    offset aD       ; "%d\r\n"
.text:00401059                 call    printf
.text:0040105E                 mov     ecx, esi
.text:00401060                 add     esp, 8
.text:00401063                 and     ecx, 1Fh
.text:00401066                 push    ecx
.text:00401067                 push    offset aD       ; "%d\r\n"
.text:0040106C                 call    printf
.text:00401071                 mov     edx, esi
.text:00401073                 add     esp, 8
.text:00401076                 and     edx, 3Fh
.text:00401079                 push    edx
.text:0040107A                 push    offset aD       ; "%d\r\n"
.text:0040107F                 call    printf
.text:00401084                 mov     eax, esi
.text:00401086                 add     esp, 8
.text:00401089                 and     eax, 7Fh
.text:0040108C                 push    eax
.text:0040108D                 push    offset aD       ; "%d\r\n"
.text:00401092                 call    printf
.text:00401097                 add     esp, 8
.text:0040109A                 and     esi, 0FFh
.text:004010A0                 push    esi
.text:004010A1                 push    offset aD       ; "%d\r\n"
.text:004010A6                 call    printf
.text:004010AB                 add     esp, 8
.text:004010AE                 pop     esi
.text:004010AF                 retn
.text:004010AF fn3             endp

无符号数对-2的幂取模

// hw.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include <stdlib.h>

#define N2 2
#define N22 (N2 * N2)
#define N23 (N22 * N2)
#define N24 (N23 * N2)
#define N25 (N24 * N2)
#define N26 (N25 * N2)
#define N27 (N26 * N2)
#define N28 (N27 * N2)

// 无符号数对-2的幂取模
void fn4(UINT param);

int main(int argc, char* argv[])
{
    fn4(argc);

    return 0;
}

void fn4(UINT param)
{
    printf("%d\r\n", param % -N2);
    printf("%d\r\n", param % -N22);
    printf("%d\r\n", param % -N23);
    printf("%d\r\n", param % -N24);
    printf("%d\r\n", param % -N25);
    printf("%d\r\n", param % -N26);
    printf("%d\r\n", param % -N27);
    printf("%d\r\n", param % -N28);
}
.text:00401010 fn4             proc near               ; CODE XREF: _main+5p
.text:00401010
.text:00401010 arg_0           = dword ptr  4
.text:00401010
.text:00401010                 push    esi
.text:00401011                 mov     esi, [esp+4+arg_0]
.text:00401015                 mov     eax, esi
.text:00401017                 xor     edx, edx
.text:00401019                 mov     ecx, 0FFFFFFFEh
.text:0040101E                 div     ecx
.text:00401020                 push    edx
.text:00401021                 push    offset aD       ; "%d\r\n"
.text:00401026                 call    printf
.text:0040102B                 mov     eax, esi
.text:0040102D                 xor     edx, edx
.text:0040102F                 mov     ecx, 0FFFFFFFCh
.text:00401034                 add     esp, 8
.text:00401037                 div     ecx
.text:00401039                 push    edx
.text:0040103A                 push    offset aD       ; "%d\r\n"
.text:0040103F                 call    printf
.text:00401044                 mov     eax, esi
.text:00401046                 xor     edx, edx
.text:00401048                 mov     ecx, 0FFFFFFF8h
.text:0040104D                 add     esp, 8
.text:00401050                 div     ecx
.text:00401052                 push    edx
.text:00401053                 push    offset aD       ; "%d\r\n"
.text:00401058                 call    printf
.text:0040105D                 mov     eax, esi
.text:0040105F                 xor     edx, edx
.text:00401061                 mov     ecx, 0FFFFFFF0h
.text:00401066                 add     esp, 8
.text:00401069                 div     ecx
.text:0040106B                 push    edx
.text:0040106C                 push    offset aD       ; "%d\r\n"
.text:00401071                 call    printf
.text:00401076                 mov     eax, esi
.text:00401078                 xor     edx, edx
.text:0040107A                 mov     ecx, 0FFFFFFE0h
.text:0040107F                 add     esp, 8
.text:00401082                 div     ecx
.text:00401084                 push    edx
.text:00401085                 push    offset aD       ; "%d\r\n"
.text:0040108A                 call    printf
.text:0040108F                 mov     eax, esi
.text:00401091                 xor     edx, edx
.text:00401093                 mov     ecx, 0FFFFFFC0h
.text:00401098                 add     esp, 8
.text:0040109B                 div     ecx
.text:0040109D                 push    edx
.text:0040109E                 push    offset aD       ; "%d\r\n"
.text:004010A3                 call    printf
.text:004010A8                 mov     eax, esi
.text:004010AA                 xor     edx, edx
.text:004010AC                 mov     ecx, 0FFFFFF80h
.text:004010B1                 add     esp, 8
.text:004010B4                 div     ecx
.text:004010B6                 push    edx
.text:004010B7                 push    offset aD       ; "%d\r\n"
.text:004010BC                 call    printf
.text:004010C1                 mov     eax, esi
.text:004010C3                 xor     edx, edx
.text:004010C5                 mov     ecx, 0FFFFFF00h
.text:004010CA                 add     esp, 8
.text:004010CD                 div     ecx
.text:004010CF                 push    edx
.text:004010D0                 push    offset aD       ; "%d\r\n"
.text:004010D5                 call    printf
.text:004010DA                 add     esp, 8
.text:004010DD                 pop     esi
.text:004010DE                 retn
.text:004010DE fn4             endp

有符号数对-2的幂取模

// hw.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include <stdlib.h>

#define N2 2
#define N22 (N2 * N2)
#define N23 (N22 * N2)
#define N24 (N23 * N2)
#define N25 (N24 * N2)
#define N26 (N25 * N2)
#define N27 (N26 * N2)
#define N28 (N27 * N2)

// 有符号数对-2的幂取模
void fn5(int param);

int main(int argc, char* argv[])
{
    fn5(argc);

    return 0;
}

void fn5(int param)
{
// mov     eax, esi ; 赋值
// cdq ; 扩展符号位
// xor     eax, edx ; 求补
// sub eax, edx // and eax, n ; 求模

// xor     eax, edx ; 求补
// sub eax, edx printf("%d\r\n", param % -N2);
    printf("%d\r\n", param % -N22);
    printf("%d\r\n", param % -N23);
    printf("%d\r\n", param % -N24);
    printf("%d\r\n", param % -N25);
    printf("%d\r\n", param % -N26);
    printf("%d\r\n", param % -N27);
    printf("%d\r\n", param % -N28);
}
.text:00401010 fn5             proc near               ; CODE XREF: _main+5p
.text:00401010
.text:00401010 arg_0           = dword ptr  4
.text:00401010
.text:00401010                 push    esi
.text:00401011                 mov     esi, [esp+4+arg_0]
.text:00401015                 mov     eax, esi
.text:00401017                 cdq
.text:00401018                 xor     eax, edx
.text:0040101A                 sub     eax, edx
.text:0040101C                 and     eax, 1
.text:0040101F                 xor     eax, edx
.text:00401021                 sub     eax, edx
.text:00401023                 push    eax
.text:00401024                 push    offset aD       ; "%d\r\n"
.text:00401029                 call    printf
.text:0040102E                 mov     eax, esi
.text:00401030                 add     esp, 8
.text:00401033                 cdq
.text:00401034                 xor     eax, edx
.text:00401036                 sub     eax, edx
.text:00401038                 and     eax, 3
.text:0040103B                 xor     eax, edx
.text:0040103D                 sub     eax, edx
.text:0040103F                 push    eax
.text:00401040                 push    offset aD       ; "%d\r\n"
.text:00401045                 call    printf
.text:0040104A                 mov     eax, esi
.text:0040104C                 add     esp, 8
.text:0040104F                 cdq
.text:00401050                 xor     eax, edx
.text:00401052                 sub     eax, edx
.text:00401054                 and     eax, 7
.text:00401057                 xor     eax, edx
.text:00401059                 sub     eax, edx
.text:0040105B                 push    eax
.text:0040105C                 push    offset aD       ; "%d\r\n"
.text:00401061                 call    printf
.text:00401066                 mov     eax, esi
.text:00401068                 add     esp, 8
.text:0040106B                 cdq
.text:0040106C                 xor     eax, edx
.text:0040106E                 sub     eax, edx
.text:00401070                 and     eax, 0Fh
.text:00401073                 xor     eax, edx
.text:00401075                 sub     eax, edx
.text:00401077                 push    eax
.text:00401078                 push    offset aD       ; "%d\r\n"
.text:0040107D                 call    printf
.text:00401082                 mov     eax, esi
.text:00401084                 add     esp, 8
.text:00401087                 cdq
.text:00401088                 xor     eax, edx
.text:0040108A                 sub     eax, edx
.text:0040108C                 and     eax, 1Fh
.text:0040108F                 xor     eax, edx
.text:00401091                 sub     eax, edx
.text:00401093                 push    eax
.text:00401094                 push    offset aD       ; "%d\r\n"
.text:00401099                 call    printf
.text:0040109E                 mov     eax, esi
.text:004010A0                 add     esp, 8
.text:004010A3                 cdq
.text:004010A4                 xor     eax, edx
.text:004010A6                 sub     eax, edx
.text:004010A8                 and     eax, 3Fh
.text:004010AB                 xor     eax, edx
.text:004010AD                 sub     eax, edx
.text:004010AF                 push    eax
.text:004010B0                 push    offset aD       ; "%d\r\n"
.text:004010B5                 call    printf
.text:004010BA                 mov     eax, esi
.text:004010BC                 add     esp, 8
.text:004010BF                 cdq
.text:004010C0                 xor     eax, edx
.text:004010C2                 sub     eax, edx
.text:004010C4                 and     eax, 7Fh
.text:004010C7                 xor     eax, edx
.text:004010C9                 sub     eax, edx
.text:004010CB                 push    eax
.text:004010CC                 push    offset aD       ; "%d\r\n"
.text:004010D1                 call    printf
.text:004010D6                 mov     eax, esi
.text:004010D8                 add     esp, 8
.text:004010DB                 cdq
.text:004010DC                 xor     eax, edx
.text:004010DE                 sub     eax, edx
.text:004010E0                 and     eax, 0FFh
.text:004010E5                 xor     eax, edx
.text:004010E7                 sub     eax, edx
.text:004010E9                 push    eax
.text:004010EA                 push    offset aD       ; "%d\r\n"
.text:004010EF                 call    printf
.text:004010F4                 add     esp, 8
.text:004010F7                 pop     esi
.text:004010F8                 retn
.text:004010F8 fn5             endp

表达式2和3有2个变量参与

// hw.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
    printf("f %d\r\n", (argc > 1) ? argc : rand());

    system("pause");    
    return 0;
}

.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 arg_0           = dword ptr  4
.text:00401000
.text:00401000                 mov     eax, [esp+arg_0]
.text:00401004                 cmp     eax, 1
.text:00401007                 jg      short L_1
.text:00401009                 call    _rand
.text:0040100E
.text:0040100E L_1:                                    ; CODE XREF: _main+7j
.text:0040100E                 push    eax
.text:0040100F                 push    offset aFD      ; "f %d\r\n"
.text:00401014                 call    printf
.text:00401019                 push    offset aPause   ; "pause"
.text:0040101E                 call    system
.text:00401023                 add     esp, 0Ch
.text:00401026                 xor     eax, eax
.text:00401028                 retn
.text:00401028 _main           endp

表达式2和3有1个变量参与A

// hw.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
    printf("g %d\r\n", (argc > 0) ? argc : 0);
    system("pause");    
    return 0;
}

.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 arg_0           = dword ptr  4
.text:00401000
.text:00401000                 mov     eax, [esp+arg_0]
.text:00401004                 xor     ecx, ecx
.text:00401006                 test    eax, eax
.text:00401008                 setle   cl
.text:0040100B                 dec     ecx
.text:0040100C                 and     ecx, eax
.text:0040100E                 push    ecx
.text:0040100F                 push    offset aGD      ; "g %d\r\n"
.text:00401014                 call    sub_4010C6
.text:00401019                 push    offset aPause   ; "pause"
.text:0040101E                 call    sub_401030
.text:00401023                 add     esp, 0Ch
.text:00401026                 xor     eax, eax
.text:00401028                 retn
.text:00401028 _main           endp

表达式2和3有1个变量参与B

// hw.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
    printf("h %d\r\n", (argc > 0) ? argc : 1);
    printf("i %d\r\n", (argc > 0) ? argc : 2);
    printf("j %d\r\n", (argc > 0) ? argc : 3);
    printf("k %d\r\n", (argc > 0) ? argc : 4);
    printf("l %d\r\n", (argc > 0) ? argc : 5);
    printf("m %d\r\n", (argc > 0) ? argc : 6);
    printf("n %d\r\n", (argc > 0) ? argc : 7);
    printf("o %d\r\n", (argc > 0) ? argc : 8);
    printf("p %d\r\n", (argc > 0) ? argc : 9);

    system("pause");    
    return 0;
}

.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    esi
.text:00401001                 mov     esi, [esp+4+argc]
.text:00401005                 test    esi, esi
.text:00401007                 mov     eax, esi
.text:00401009                 jg      short L_1
.text:0040100B                 mov     eax, 1
.text:00401010
.text:00401010 L_1:                                    ; CODE XREF: _main+9j
.text:00401010                 push    eax
.text:00401011                 push    offset aHD      ; "h %d\r\n"
.text:00401016                 call    printf
.text:0040101B                 add     esp, 8
.text:0040101E                 mov     eax, esi
.text:00401020                 test    esi, esi
.text:00401022                 jg      short L_2
.text:00401024                 mov     eax, 2
.text:00401029
.text:00401029 L_2:                                    ; CODE XREF: _main+22j
.text:00401029                 push    eax
.text:0040102A                 push    offset aID      ; "i %d\r\n"
.text:0040102F                 call    printf
.text:00401034                 add     esp, 8
.text:00401037                 mov     eax, esi
.text:00401039                 test    esi, esi
.text:0040103B                 jg      short L_3
.text:0040103D                 mov     eax, 3
.text:00401042
.text:00401042 L_3:                                    ; CODE XREF: _main+3Bj
.text:00401042                 push    eax
.text:00401043                 push    offset aJD      ; "j %d\r\n"
.text:00401048                 call    printf
.text:0040104D                 add     esp, 8
.text:00401050                 mov     eax, esi
.text:00401052                 test    esi, esi
.text:00401054                 jg      short L_4
.text:00401056                 mov     eax, 4
.text:0040105B
.text:0040105B L_4:                                    ; CODE XREF: _main+54j
.text:0040105B                 push    eax
.text:0040105C                 push    offset aKD      ; "k %d\r\n"
.text:00401061                 call    printf
.text:00401066                 add     esp, 8
.text:00401069                 mov     eax, esi
.text:0040106B                 test    esi, esi
.text:0040106D                 jg      short L_5
.text:0040106F                 mov     eax, 5
.text:00401074
.text:00401074 L_5:                                    ; CODE XREF: _main+6Dj
.text:00401074                 push    eax
.text:00401075                 push    offset aLD      ; "l %d\r\n"
.text:0040107A                 call    printf
.text:0040107F                 add     esp, 8
.text:00401082                 mov     eax, esi
.text:00401084                 test    esi, esi
.text:00401086                 jg      short L_6
.text:00401088                 mov     eax, 6
.text:0040108D
.text:0040108D L_6:                                    ; CODE XREF: _main+86j
.text:0040108D                 push    eax
.text:0040108E                 push    offset aMD      ; "m %d\r\n"
.text:00401093                 call    printf
.text:00401098                 add     esp, 8
.text:0040109B                 mov     eax, esi
.text:0040109D                 test    esi, esi
.text:0040109F                 jg      short L_7
.text:004010A1                 mov     eax, 7
.text:004010A6
.text:004010A6 L_7:                                    ; CODE XREF: _main+9Fj
.text:004010A6                 push    eax
.text:004010A7                 push    offset aND      ; "n %d\r\n"
.text:004010AC                 call    printf
.text:004010B1                 add     esp, 8
.text:004010B4                 mov     eax, esi
.text:004010B6                 test    esi, esi
.text:004010B8                 jg      short L_8
.text:004010BA                 mov     eax, 8
.text:004010BF
.text:004010BF L_8:                                    ; CODE XREF: _main+B8j
.text:004010BF                 push    eax
.text:004010C0                 push    offset aOD      ; "o %d\r\n"
.text:004010C5                 call    printf
.text:004010CA                 add     esp, 8
.text:004010CD                 test    esi, esi
.text:004010CF                 jg      short L_9
.text:004010D1                 mov     esi, 9
.text:004010D6
.text:004010D6 L_9:                                    ; CODE XREF: _main+CFj
.text:004010D6                 push    esi
.text:004010D7                 push    offset aPD      ; "p %d\r\n"
.text:004010DC                 call    printf
.text:004010E1                 push    offset aPause   ; "pause"
.text:004010E6                 call    system
.text:004010EB                 add     esp, 0Ch
.text:004010EE                 xor     eax, eax
.text:004010F0                 pop     esi
.text:004010F1                 retn
.text:004010F1 _main           endp

表达式2和3有1个变量参与C

int main(int argc, char* argv[])
{
    printf("%d\r\n", (argc > 0x888) ? argc : 0x999);
    system("pause");    
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 arg_0           = dword ptr  4
.text:00401000
.text:00401000                 mov     eax, [esp+arg_0]
.text:00401004                 cmp     eax, 888h
.text:00401009                 jg      short L_1
.text:0040100B                 mov     eax, 999h
.text:00401010
.text:00401010 L_1:                                    ; CODE XREF: _main+9j
.text:00401010                 push    eax
.text:00401011                 push    offset aD       ; "%d\r\n"
.text:00401016                 call    printf
.text:0040101B                 push    offset aPause   ; "pause"
.text:00401020                 call    system
.text:00401025                 add     esp, 0Ch
.text:00401028                 xor     eax, eax
.text:0040102A                 retn
.text:0040102A _main           endp

表达式2和3都是常量或等价与常量>

int main(int argc, char* argv[])
{
    printf("a %d\r\n", (argc > 0x777) ? 0x888 : 0x999);
    system("pause");    
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 arg_0           = dword ptr  4
.text:00401000
.text:00401000                 mov     ecx, [esp+arg_0]
.text:00401004                 xor     eax, eax
.text:00401006                 cmp     ecx, 777h
.text:0040100C                 setle   al
.text:0040100F                 dec     eax
.text:00401010                 and     eax, 0FFFFFEEFh
.text:00401015                 add     eax, 999h
.text:0040101A                 push    eax
.text:0040101B                 push    offset aAD      ; "a %d\r\n"
.text:00401020                 call    printf
.text:00401025                 push    offset aPause   ; "pause"
.text:0040102A                 call    system
.text:0040102F                 add     esp, 0Ch
.text:00401032                 xor     eax, eax
.text:00401034                 retn
.text:00401034 _main           endp

表达式2和3都是常量或等价与常量 >=

int main(int argc, char* argv[])
{
    printf("b %d\r\n", (argc >= 0x777) ? 0x888 : 0x999);
    system("pause");    
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 arg_0           = dword ptr  4
.text:00401000
.text:00401000                 mov     ecx, [esp+arg_0]
.text:00401004                 xor     eax, eax
.text:00401006                 cmp     ecx, 777h
.text:0040100C                 setl    al
.text:0040100F                 dec     eax
.text:00401010                 and     eax, 0FFFFFEEFh
.text:00401015                 add     eax, 999h
.text:0040101A                 push    eax
.text:0040101B                 push    offset aBD      ; "b %d\r\n"
.text:00401020                 call    printf
.text:00401025                 push    offset aPause   ; "pause"
.text:0040102A                 call    system
.text:0040102F                 add     esp, 0Ch
.text:00401032                 xor     eax, eax
.text:00401034                 retn
.text:00401034 _main           endp

表达式2和3都是常量或等价与常量 <

int main(int argc, char* argv[])
{
    printf("c %d\r\n", (argc < 0x777) ? 0x888 : 0x999);
    system("pause");    
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 arg_0           = dword ptr  4
.text:00401000
.text:00401000                 mov     ecx, [esp+arg_0]
.text:00401004                 xor     eax, eax
.text:00401006                 cmp     ecx, 777h
.text:0040100C                 setnl   al
.text:0040100F                 dec     eax
.text:00401010                 and     eax, 0FFFFFEEFh
.text:00401015                 add     eax, 999h
.text:0040101A                 push    eax
.text:0040101B                 push    offset aCD      ; "c %d\r\n"
.text:00401020                 call    printf
.text:00401025                 push    offset aPause   ; "pause"
.text:0040102A                 call    system
.text:0040102F                 add     esp, 0Ch
.text:00401032                 xor     eax, eax
.text:00401034                 retn
.text:00401034 _main           endp

表达式2和3都是常量或等价与常量 <=

int main(int argc, char* argv[])
{
    // 表达式23都是常量或等价与常量 <=
    printf("d %d\r\n", (argc <= 0x777) ? 0x888 : 0x999);
    system("pause");    
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 arg_0           = dword ptr  4
.text:00401000
.text:00401000                 mov     ecx, [esp+arg_0]
.text:00401004                 xor     eax, eax
.text:00401006                 cmp     ecx, 777h
.text:0040100C                 setnle  al
.text:0040100F                 dec     eax
.text:00401010                 and     eax, 0FFFFFEEFh
.text:00401015                 add     eax, 999h
.text:0040101A                 push    eax
.text:0040101B                 push    offset aDD      ; "d %d\r\n"
.text:00401020                 call    printf
.text:00401025                 push    offset aPause   ; "pause"
.text:0040102A                 call    system
.text:0040102F                 add     esp, 0Ch
.text:00401032                 xor     eax, eax
.text:00401034                 retn
.text:00401034 _main           endp

表达式2和3都是常量或等价与常量 !=

int main(int argc, char* argv[])
{
    printf("e %d\r\n", (argc != 0x777) ? 0x888 : 0x999);
    printf("e1 %d\r\n", (argc != 3) ? 0x888 : 0x999);
    system("pause");    
    return 0;
}
.text:00401000 ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00401000 _main           proc near               ; CODE XREF: start+AFp
.text:00401000
.text:00401000 argc            = dword ptr  4
.text:00401000 argv            = dword ptr  8
.text:00401000 envp            = dword ptr  0Ch
.text:00401000
.text:00401000                 push    esi
.text:00401001                 mov     esi, [esp+4+argc]
.text:00401005                 mov     eax, esi
.text:00401007                 sub     eax, 777h
.text:0040100C                 neg     eax
.text:0040100E                 sbb     eax, eax
.text:00401010                 and     eax, 0FFFFFEEFh
.text:00401015                 add     eax, 999h
.text:0040101A                 push    eax
.text:0040101B                 push    offset aED      ; "e %d\r\n"
.text:00401020                 call    printf
.text:00401025                 sub     esi, 3
.text:00401028                 add     esp, 8
.text:0040102B                 neg     esi
.text:0040102D                 sbb     esi, esi
.text:0040102F                 and     esi, 0FFFFFEEFh
.text:00401035                 add     esi, 999h
.text:0040103B                 push    esi
.text:0040103C                 push    offset aE1D     ; "e1 %d\r\n"
.text:00401041                 call    printf
.text:00401046                 push    offset aPause   ; "pause"
.text:0040104B                 call    system
.text:00401050                 add     esp, 0Ch
.text:00401053                 xor     eax, eax
.text:00401055                 pop     esi
.text:00401056                 retn
.text:00401056 _main           endp