資源描述:
《匯編語(yǔ)言實(shí)現(xiàn)用16位乘法指令完成32位無(wú)符號(hào)數(shù)乘法》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫(kù)。
1、《微型計(jì)算機(jī)原理與接口技術(shù)》實(shí)驗(yàn)報(bào)告一、程序設(shè)計(jì)題目一三十二位無(wú)符號(hào)乘法1設(shè)計(jì)分析:(1)程序設(shè)計(jì)任務(wù):用十六位乘法指令完成三十二位無(wú)符號(hào)數(shù)乘法(結(jié)果64位)。使用MUL指令,完成雙字無(wú)符號(hào)數(shù)乘法程序,要求乘數(shù)和被乘數(shù)從鍵盤(pán)輸入,結(jié)果顯示于屏幕上。(2)程序設(shè)計(jì)要求:1)從鍵盤(pán)輸入兩個(gè)乘數(shù)(十六進(jìn)制)2)結(jié)果顯示于屏幕上(十六進(jìn)制)(3)程序設(shè)計(jì)過(guò)程:1)定義數(shù)據(jù)段用于開(kāi)辟緩沖區(qū)存儲(chǔ)輸入數(shù)據(jù)、輸出數(shù)據(jù)和乘積。2)從鍵盤(pán)分別輸入兩個(gè)八位數(shù)字符(三十二字節(jié))存入緩沖區(qū)(分4次輸入,每次輸入4個(gè)字符,前兩次為被乘數(shù)的高位與低位,后兩
2、次為乘數(shù)的高位與低位)3)對(duì)緩沖區(qū)輸入的字符進(jìn)行處理,讓Ascal碼轉(zhuǎn)換為數(shù)值本身的數(shù)值。4)把三十二位分割成兩位十六位,分別對(duì)其進(jìn)行十六位的乘法。5)將四個(gè)十六位乘法的乘積按照各自的位相加的最終乘積6)對(duì)所得結(jié)果進(jìn)行處理,讓Ascal碼轉(zhuǎn)換為數(shù)值本身的數(shù)值7)將結(jié)果向屏幕輸出。2、算法(一個(gè)框代表16位2進(jìn)制數(shù))3、X2X11616y2y11616161616161616161616161616P+6p+4p+2p開(kāi)始2、程序流程圖:初始化輸入被乘數(shù)的高位的4個(gè)字符X2輸入被乘數(shù)的低位的4個(gè)字符X1輸入乘數(shù)的高位的4個(gè)字符y
3、2輸入乘數(shù)的低位的4個(gè)字符y1開(kāi)始運(yùn)算乘法被乘數(shù)低位4個(gè)字符x1和乘數(shù)低位4個(gè)字符y1相乘結(jié)果低位存入p,高位存入p+2被乘數(shù)高位4個(gè)字符x2和乘數(shù)低位4個(gè)字符y1相乘結(jié)果低位存入p+2,高位存入p+4被乘數(shù)低位4個(gè)字符x1和乘數(shù)高位4個(gè)字符y2相乘結(jié)果低位存入p+2,高位存入p+4被乘數(shù)高位4個(gè)字符x2和乘數(shù)高位4個(gè)字符y2相乘結(jié)果低位存入p+4,高位存入p+6乘積相加輸出結(jié)果162、測(cè)試數(shù)據(jù)與運(yùn)行結(jié)果:輸入被乘數(shù)的高位的4個(gè)字符X2:輸入被乘數(shù)的低位的4個(gè)字符X1:輸入乘數(shù)的高位的4個(gè)字符y2:輸入乘數(shù)的低位的4個(gè)字符y1
4、:運(yùn)行結(jié)果:2、程序源代碼及注解:ddatasegmentx1dw16dup(?)x2dw16dup(?)y1dw16dup(?)y2dw16dup(?)pdw30dup(?)keybufdb10dup(?)ddataends;定義數(shù)據(jù)段ccodesegmentassumecs:ccode,ds:ddatastart:movax,ddatamovds,axmovdx,offsetkeybufmovbx,dxmov[bx],byteptr9movah,0ahint21hmovah,[bx+2]moval,[bx+3]shlal,
5、4shrax,4movdh,almovah,[bx+4]moval,[bx+5]shlal,4shrax,4movdl,almovx2,dx;輸入被乘數(shù)的高位的4個(gè)字符x2movdx,offsetkeybufmovbx,dxmov[bx],byteptr9movah,0ahint21hmovah,[bx+2]moval,[bx+3]shlal,4shrax,4movdh,almovah,[bx+4]moval,[bx+5]shlal,4shrax,4movdl,almovx1,dx;輸入被乘數(shù)的低位的4個(gè)字符x1movdx,o
6、ffsetkeybufmovbx,dxmov[bx],byteptr9movah,0ahint21hmovah,[bx+2]moval,[bx+3]shlal,4shrax,4movdh,almovah,[bx+4]moval,[bx+5]shlal,4shrax,4movdl,almovy2,dx;輸入乘數(shù)的高位的4個(gè)字符y2movdx,offsetkeybufmovbx,dxmov[bx],byteptr9movah,0ahint21hmovah,[bx+2]moval,[bx+3]shlal,4shrax,4movdh,
7、almovah,[bx+4]moval,[bx+5]shlal,4shrax,4movdl,almovy1,dx;輸入乘數(shù)的低位的4個(gè)字符y1movax,x1movdx,y1muldxmov[p],axmov[p+2],dx;被乘數(shù)低位4字符x1和乘數(shù)低位4字符y1相乘結(jié)果低位存入p,高位存入p+2movax,x2movdx,y1muldxadd[p+2],axadc[p+4],dx;被乘數(shù)高位4字符x2和乘數(shù)低位4字符y1相乘結(jié)果低位存入p+2,高位存入p+4movax,x1movdx,y2muldxadd[p+2],axa
8、dc[p+4],dxadc[p+6],0;被乘數(shù)低位4個(gè)字符x1和乘數(shù)高位4個(gè)字符y2相乘結(jié)果低位存入p+2,高位存入p+4movax,x2movdx,y2muldxadd[p+4],axadc[p+6],dx;被乘數(shù)高位4個(gè)字符x2和乘數(shù)高位4個(gè)字符y2相乘結(jié)果低位存入p+