无符号数除以非2的幂(MagicNumber有进位)
发布日期:2021-06-30 22:10:17 浏览次数:2 分类:技术文章

本文共 6402 字,大约阅读时间需要 21 分钟。

前言

这里写图片描述

这里写图片描述
这里写图片描述

试验

// hw.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include 
#include
void fnDiv7(UINT x) { printf("==========\r\n"); printf("%d\r\n", x/7);}void fnDiv19(UINT x) { printf("==========\r\n"); printf("%d\r\n", x/19);}void fnDiv21(UINT x) { printf("==========\r\n"); printf("%d\r\n", x/21);}void fnDiv27(UINT x) { printf("==========\r\n"); printf("%d\r\n", x/27);}int main(int argc, char* argv[]){ // hw1_4 验证 : 无符号数除以非2的幂(MagicNumber有进位) fnDiv7(14); fnDiv19(57); fnDiv21(84); fnDiv27(135); /** ========== 2 ========== 3 ========== 4 ========== 5 请按任意键继续. . . */ system("pause"); return 0;}
.text:00401000 ; =============== S U B R O U T I N E =======================================.text:00401000.text:00401000.text:00401000 fnDiv7          proc near               ; CODE XREF: _main+2p.text:00401000.text:00401000 arg_0           = dword ptr  4.text:00401000.text:00401000                 push    offset Format   ; "==========\r\n".text:00401005                 call    _printf.text:0040100A                 mov     ecx, [esp+4+arg_0] ; step1.text:0040100E                 mov     eax, 24924925h  ; step2.text:00401013                 mul     ecx             ; step3.text:00401015                 sub     ecx, edx        ; step4.text:00401017                 add     esp, 4.text:0040101A                 shr     ecx, 1          ; step5.text:0040101C                 add     ecx, edx        ; step6.text:0040101E                 shr     ecx, 2          ; step7.text:00401021                 push    ecx.text:00401022                 push    offset aD       ; "%d\r\n".text:00401027                 call    _printf.text:0040102C                 add     esp, 8.text:0040102F                 retn.text:0040102F fnDiv7          endp.text:0040102F.text:00401030.text:00401030 ; =============== S U B R O U T I N E =======================================.text:00401030.text:00401030.text:00401030 fnDiv19         proc near               ; CODE XREF: _main+9p.text:00401030.text:00401030 arg_0           = dword ptr  4.text:00401030.text:00401030                 push    offset Format   ; "==========\r\n".text:00401035                 call    _printf.text:0040103A                 mov     ecx, [esp+4+arg_0] ; step1.text:0040103E                 mov     eax, 0AF286BCBh ; step2.text:00401043                 mul     ecx             ; step3.text:00401045                 sub     ecx, edx        ; step4.text:00401047                 add     esp, 4.text:0040104A                 shr     ecx, 1          ; step5.text:0040104C                 add     ecx, edx        ; step6.text:0040104E                 shr     ecx, 4          ; step7.text:00401051                 push    ecx.text:00401052                 push    offset aD       ; "%d\r\n".text:00401057                 call    _printf.text:0040105C                 add     esp, 8.text:0040105F                 retn.text:0040105F fnDiv19         endp.text:0040105F.text:00401060.text:00401060 ; =============== S U B R O U T I N E =======================================.text:00401060.text:00401060.text:00401060 fnDiv21         proc near               ; CODE XREF: _main+10p.text:00401060.text:00401060 arg_0           = dword ptr  4.text:00401060.text:00401060                 push    offset Format   ; "==========\r\n".text:00401065                 call    _printf.text:0040106A                 mov     ecx, [esp+4+arg_0] ; step1.text:0040106E                 mov     eax, 86186187h  ; step2.text:00401073                 mul     ecx             ; step3.text:00401075                 sub     ecx, edx        ; step4.text:00401077                 add     esp, 4.text:0040107A                 shr     ecx, 1          ; step5.text:0040107C                 add     ecx, edx        ; step6.text:0040107E                 shr     ecx, 4          ; step7.text:00401081                 push    ecx.text:00401082                 push    offset aD       ; "%d\r\n".text:00401087                 call    _printf.text:0040108C                 add     esp, 8.text:0040108F                 retn.text:0040108F fnDiv21         endp.text:0040108F.text:00401090.text:00401090 ; =============== S U B R O U T I N E =======================================.text:00401090.text:00401090.text:00401090 fnDiv27         proc near               ; CODE XREF: _main+1Ap.text:00401090.text:00401090 arg_0           = dword ptr  4.text:00401090.text:00401090                 push    offset Format   ; "==========\r\n".text:00401095                 call    _printf.text:0040109A                 mov     ecx, [esp+4+arg_0] ; step1.text:0040109E                 mov     eax, 2F684BDBh  ; step2.text:004010A3                 mul     ecx             ; step3.text:004010A5                 sub     ecx, edx        ; step4.text:004010A7                 add     esp, 4.text:004010AA                 shr     ecx, 1          ; step5.text:004010AC                 add     ecx, edx        ; step6.text:004010AE                 shr     ecx, 4          ; step7.text:004010B1                 push    ecx.text:004010B2                 push    offset aD       ; "%d\r\n".text:004010B7                 call    _printf.text:004010BC                 add     esp, 8.text:004010BF                 retn.text:004010BF fnDiv27         endp.text:004010BF.text:004010C0.text:004010C0 ; =============== S U B R O U T I N E =======================================.text:004010C0.text:004010C0.text:004010C0 ; int __cdecl main(int argc, const char **argv, const char **envp).text:004010C0 _main           proc near               ; CODE XREF: start+AFp.text:004010C0                 push    14.text:004010C2                 call    fnDiv7.text:004010C7                 push    57.text:004010C9                 call    fnDiv19.text:004010CE                 push    84.text:004010D0                 call    fnDiv21.text:004010D5                 push    135.text:004010DA                 call    fnDiv27.text:004010DF                 push    offset aPause   ; "pause".text:004010E4                 call    _my_system.text:004010E9                 add     esp, 14h.text:004010EC                 xor     eax, eax.text:004010EE                 retn.text:004010EE _main           endp.text:004010EE.text:004010EE ; ---------------------------------------------------------------------------

转载地址:https://lostspeed.blog.csdn.net/article/details/52496632 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:有符号数除以非2的幂(MagicNumber为负)
下一篇:有符号数除以非2的幂

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年04月25日 01时15分39秒