汇编小白求大神

Devil_hyx 2016-05-30 04:11:22
求大神给下面的代码给个注释啊 关于大数乘法 看不懂 也不知道怎么调 怎么用
void AsmMulL(unsigned long *pL, unsigned long pR, unsigned long *pA, unsigned long t)
{
if (t == 0) return;
__asm
{
mov ecx, t
lea esi, dword ptr pL
lea edi, dword ptr pA
mov ebx, 0
clc
cld
}
AsmMulL1:
__asm
{
mov eax, dword ptr[esi]
lea esi,[esi + 4]
mul dword ptr pR
add eax, ebx
adc edx, 0
mov ebx, edx
mov dword ptr[edi], eax
lea edi,[edi + 4]
loop AsmMulL1
mov[edi], ebx
}
}
...全文
897 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
用户 昵称 2016-05-31
  • 打赏
  • 举报
回复
算法实现中还有最基本的技巧,比如尽量使用更长的寄存器,或进行域转换,将乘法变成加法等。
用户 昵称 2016-05-31
  • 打赏
  • 举报
回复
楼主知道大数乘法的基本原理吗?要从原理入手才能理解汇编啊。 大数乘法,先把两个乘数都对齐,检查有效位,从有效位开始 遇到1就左移1位,再加上原值,遇到0只移位。 举例来说 a = 0033 b = 0044 a 的二进制是 00000000 00110011 b 的二进制是 00000000 01000100 //a = 0033 //b = 0044 //c = 0000 //--// 遇到1 //c = shl ( 0000 , 01 ) = //--bitwise left shift whole block //-- input = 00 00 // //-- result = 00 00 //0000 //c = add ( 0000 , 0033 ) = //--add calculate num1 + num2 //-- num1 = 00 00 //-- num2 = 00 33 //-- result = 00 33 //0033 //--// 连续遇到3个0 //c = shl ( 0033 , 01 ) = //--bitwise left shift whole block //-- input = 00 33 // //-- result = 00 66 //0066 //c = shl ( 0066 , 01 ) = //--bitwise left shift whole block //-- input = 00 66 // //-- result = 00 CC //00CC //c = shl ( 00CC , 01 ) = //--bitwise left shift whole block //-- input = 00 CC // //-- result = 01 98 //0198 //--// 遇到1 //c = shl ( 0198 , 01 ) = //--bitwise left shift whole block //-- input = 01 98 // //-- result = 03 30 //0330 //c = add ( 0330 , 0033 ) = //--add calculate num1 + num2 //-- num1 = 03 30 //-- num2 = 00 33 //-- result = 03 63 //0363 //--// 连续遇到2个0 //c = shl ( 0363 , 01 ) = //--bitwise left shift whole block //-- input = 03 63 // //-- result = 06 C6 //06C6 //c = shl ( 06C6 , 01 ) = //--bitwise left shift whole block //-- input = 06 C6 // //-- result = 0D 8C //0D8C 汇编对于移位,带进位加等操作有极大优势,所以这种乘法优化时首选汇编。
zara 2016-05-31
  • 打赏
  • 举报
回复
也没看懂,不过最简单的就是生成可执行代码,用比较有典型的数据进行调用,单步下,看看数据是怎么转换的就明白了。
Devil_hyx 2016-05-30
  • 打赏
  • 举报
回复
http://wenku.baidu.com/link?url=5NZwmYZVXtCdXnVQTrTfrEKSeRD2-amkaRWGKhZKbpNOyucK9PwkDW_L-P3sZgTR5RA-uTVN3EbrghGELWveYHymDszM7zhTZF2P3SxNGom 文档在这 求大神啊
Devil_hyx 2016-05-30
  • 打赏
  • 举报
回复
void AsmMulLL(unsigned long *pL, unsigned long *pR, unsigned long *pA, unsigned long tL, unsigned long tR) { if ((tL == 0) || (tR == 0)) return; unsigned long Temp; __asm { mov ecx, tL lea esi, dword ptr pL lea edi, dword ptr pR lea ebx, dword ptr pA } mbinmul1: __asm { push ecx mov ecx, tR push ebx push edi mov eax, 0 mov Temp, eax } mbinmul2: __asm { mov eax,[edi] lea edi,[edi + 4] mul dword ptr es : [esi] add eax,[ebx] adc edx, 0 add eax, Temp adc edx, 0 mov [ebx], eax mov Temp, edx lea ebx,[ebx + 4] loop mbinmul2 mov [ebx], edx lea esi,[esi + 4] pop edi pop ebx lea ebx,[ebx + 4] pop ecx loop mbinmul1 } } 还有一段

21,459

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧