匯編語(yǔ)言實(shí)驗(yàn)整理_第1頁(yè)
匯編語(yǔ)言實(shí)驗(yàn)整理_第2頁(yè)
匯編語(yǔ)言實(shí)驗(yàn)整理_第3頁(yè)
匯編語(yǔ)言實(shí)驗(yàn)整理_第4頁(yè)
匯編語(yǔ)言實(shí)驗(yàn)整理_第5頁(yè)
已閱讀5頁(yè),還剩1頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、1. 設(shè)計(jì)程序。實(shí)現(xiàn)Y=2X+3X是一位十進(jìn)制數(shù)。要求X從鍵盤(pán)輸入,在下一行顯示“Y=2X+3=”以及十進(jìn)制計(jì)算結(jié)果。data segment x db ? y dw ? mess1 db 0ah,0dh,input x:$ mess2 db0ah,0dh,Y=2X+3=$dataendscodesegmentassumecs:code,ds:datastart: mov ax,data mov ds,axlet3: mov dx,offsetmess1 mov ah,9 int 21h mov ah,1 int 21h cmp al,0 jb out1cmp al,9 ja out1 and

2、 al,0fh mov bl,2 mul bl add ax,3 mov y,axmov cx,0 mov bx,10let0: mov dx,0 inc cx idiv bx push dx cmpax,0 jne let0 mov dx,offset mess2 mov ah,9 int 21hlet1: pop axadd ax,0030h mov dl,al mov ah,2 int 21h dec cx cmp cx,0 jnzlet1 jmp let3out1: mov ah,4ch int21hcode endsend start2. 編寫(xiě)程序,將鍵盤(pán)輸入的小寫(xiě)字母變?yōu)榇髮?xiě)字母顯

3、示在屏幕上,輸入小寫(xiě)字母以外的其它字符則退出。data segmentmess1 db 0ah,0dh,xiaoxieinput:$endscode segmentmess2 dbassume0ah,0dh,daxieoutput:$datacs:code,ds:datastart: mov ax,data mov ds,axlet2: mov dx,offsetmess1 mov ah,9 int 21h mov ah,1 int 21h cmp al,a jb out1cmp al,z ja out1 mov bl,al mov dx,offset mess2 mov ah,9 int21

4、hlet0: sub bl,20h mov dl,bl mov ah,2 int 21h jmp let2out1:mov ah,4ch int21hcode endsend start3. Z=X/4+16*YX和 Y在下一行顯示“Z=X/4+16*Y”以及十進(jìn)制計(jì)算結(jié)果。data segment mess1 db 0ah,0dh,input x:$ mess2 db 0ah,0dh,input y:$mess3 db 0ah,0dh,z=x/4+16*y=$data endscode segmentassumecs:code,ds:datastart: mov ax,data mov ds

5、,axlet0: mov dx,offsetmess1 mov ah,9 int 21h mov ah,1 int 21h mov cl,2 sub al,30hmov ah,0 sar ax,cl mov bl,al mov dx,offset mess2 mov ah,9 int21hmov ah,1 int 21h sub al,30h mov ah,0 mov cl,4 sal ax,cl addal,bl mov bx,ax mov dx,offset mess3 mov ah,9 int 21hlet1: movax,bx mov cx,0 mov bx,10let2: mov d

6、x,0 inc cx idiv bx push dxcmp ax,0 jne let2let3: pop ax add ax,0030h mov dl,al mov ah,2int 21h dec cx cmp cx,0 jne let3 mov ah,4ch int 21h codeendsend start4. 用查表的方法將內(nèi)存單元中的字用十六進(jìn)制顯示出來(lái)。data segment tabledb 30h,31h,32h,33h,34h,35h,36h,37hdb38h,39h,41h,42h,43h,44h,45h,46h mess1 db 0ah,0dh,output:$ 6asci

7、idb ?dataendscode segment assume ax,datamov ds,axmov mov ah,9int21hmov bx,offsettable mov al,hex xlat mov ascii,al mov dl,al mov ah,2 int 21h mov ah,4chint 21h code endsend start5. 輸入0255 以內(nèi)的十進(jìn)制數(shù),顯示出相應(yīng)的十六進(jìn)制數(shù)。datasegment xdb 3dup(?) mess1 db 0dh,0ah,decimal=$mess2 db segment assume cs:code,ds:datasta

8、rt:mov ax,data mov ds,axlet0:mov si,0mov x,0 mov x+1,0 movx+2,0 mov dx,offset mess1mov ah,9 int ah,1 int 21hcmp al,0dh jz al,30hmov sijmp mov ah,9 cmp si,1jalet3mov bl,xmovcl,1add bl,30h mov dl,blmov ah,2 int21h jmp si,2ja al,x mov cl,10 mul cladd al,x+1mov ah,0 movbl,16div blmov bx,ax mov cl,2 jmp

9、al,x mov cl,10mul cl add al,x+1mul cl add al,x+2mov ah,0 mov bl,16divblmov bx,ax mov bl,10 jl bl,30hmov dl,blmov ah,2 int21h mov bl,bhdec cl jneah,4ch int 21hcode ends end start6. 分支程序設(shè)計(jì)。完成如下公式的計(jì)算,請(qǐng)寫(xiě)出程序。(X+3)/2X0X=0Y=0X0data segmentx dw -1200ydw ?,?zdw 10countdb 0dataendscodesegmentassume ds:data,cs

10、:codestart:mov ax,datajzprog2 movmov ah,2movds,axcmp x,0int 21hsalax,clmov bl,2mov ah,0jmp dx,0jgprog1mov dl,2dhcl,2mov ax,xneg axjmp exitprog1:mov ax,xaddax,3mov byteptry,aljmp exitprog2:idivzmov bytemov y,0push dxptry+1,ahmov ax,0inc countdx,0030hmov ah,4chcmp ax,0mov ah,2jnz exitexit1:int21hpop d

11、xdec countaddjnz exit1int21hcode endsend start7. 字?jǐn)?shù)組 M中有 10 個(gè)數(shù)據(jù),分類統(tǒng)計(jì)其中正數(shù)、負(fù)數(shù)、0的個(gè)數(shù),分別存入POSI、NEGA、ZERO 單元。data segmentM db 91h,-1,2,3,4,5,80h,0,-3,-4str1 db POSI:$str2 db0dh,0ah,NEGA:$str3 db 0dh,0ah,ZERO:$count1 db 0count2 db 0count3db 0data endscode segmentassume ds:data,cs:codebegin:movjzax,dataoutp

12、utinc simov ds,axcmp Msi,0jmp forfor1:mov si,0for:jg for1cmp si,10jl for2inc siinc count3jmp forfor2:mov ah,9add dl,30hinc count1inc count2inc sijmp foroutput:mov dl,count1mov dx,offset str1mov ah,2int 21hint 21hmov ah,9add dl,30hmov dx,offset str2int21h21hmov dl,count2mov ah,9add dl,30hmov ah,2int

13、21hint 21hintmovmovmov dx,offset str3mov ah,2dl,count3ah,4chint21hcode endsend begin8. 分別統(tǒng)計(jì) 3個(gè)班級(jí)中某科成績(jī)優(yōu)秀的人數(shù)和不及格的人數(shù)。data segmenttongji db 6 dup(?)grade db 25,42,95,77db 12,0,85,97db 92,99,59,24i dw 3j dw 4n1 db ?n2 db ?data endscode segmentassumeds:data,cs:codestart:mov ax,datamov ds,axmov cx,jfor:mov

14、 si,0cmpmov di,0mov cx,ifor1: push cxgradesi,60gradesi,90mov al,n1add di,2jge let1jl let2inc n2jmp let2let1:inc sicmpinc n1let2:loop formov ds:di,almov n1,0mov al,n2mov n2,0 pop cxmov ds:di+1,alloop for1mov ah,4chint21hcode endsend start9. 編寫(xiě)程序,將 AX 寄存器中的 16 位數(shù)分成 4 組,每組 4 位,從低到高分別放在 AL、BL、CL、DL中。.mo

15、del small.datanum db 4 dup(?)count db 4.codebegin:movax,datamov ds,axrol ax,clinc simov ax,0101hmov bh,almov cl,4mov si,0for:mov numsi,bhand bh,0fhjnz fordec countmovbh,0mov ah,0mov dl,num0mov cl,num1int21hmov bl,num2end beginmov al,num3mov ah,4ch10. 對(duì)一個(gè)有 10個(gè)元素的字節(jié)數(shù)組按降序排序data segmentx db a,b,c,d,f,g,

16、h,i,j,kn equ $-xdata endscode segmentassume ds:data,cs:codebegin:mov ax,seg xpush cxmov ds,axmov cx,nmov al,xsimov xsi,alfor:loop loop1 mov ah,4chdec cxloop1:cmp al,xsi+1inc simov si,0loop2:xchg al,xsi+1jge forloop loop2pop cxbeginint 21h code endsend11. data segmentnum dw 2 dup(?)str1 db 0dh,0ah,x1

17、=$str2 db0dh,0ah,x2=$str3 db 0dh,0ah,x1-x2=$data endscode segmentassumeds:data,cs:codebegin:mov ax,datamov si,0mov ds,axmain procmov ah,9farmov bx,0call sub1mov dx,offset str1int 21h21hmov dx,offset str2mov ah,9intmovmov bx,0int 21hcall sub1call sub2mov dx,offset str3ah,9call sub3mov ah,4chint 21h21

18、hmain endpsub1 proc nearfor: mov ah,1intxchgcmp al,0dhmov cx,10jz exitmul cxand ax,000fhxchg ax,bxax,bxadd bx,axret sub1jmp for exit:endpmov numsi,bxsub2 proc nearadd si,2mov ah,0jge for1mov ax,numneg ax for1: retmov cx,0sub ax,num+2sub2 endpcmp ax,0sub3 proc nearmov bx,10push dxpop dxlet:mov dx,0di

19、v bxinc cxcmp ax,0jnz let let1:add dl,30hmov ah,2sub3 endpcode endsend begin12. 鍵入一個(gè)十六進(jìn)制數(shù),求其真值(用十進(jìn)制顯示,負(fù)數(shù)前加負(fù)號(hào)“”data segmentx dw 0str1 db 0dh,0ah,hex=$str2 db 0dh,0ah,dec=$dataendscode segmentassume ds:data,cs:codebegin: mov ax,dataint 21hdec cxjnz let1retmov ds,ax21hmain proc farcall sub1mov ah,9lea

20、dx,str1lea dx,str2mov dl,-intint 21hintmov ah,9test x,8000hjz for1for:mov ah,2call sub321hneg xfor1:mov ah,4chmov ah,1int21hmain endpcmp al,0dhjbe for5sub1 proc nearfor2:jz exitint21hcmp al,9jbe for6for5:jbe for3subcmp al,Fal,7hcmp al,fjmp for3for6: sub al,27hfor3: mov ah,0 xchg ax,x mov cx,16 mul c

21、xadd x,ax jmp for2exit:mov ax,xdiv bxsubal,30hfor4:ax,xxchgretmov bx,10push dxpop dxsub1 endpmov cx,0inc cxsub3 proc nearlet:mov dx,0cmp ax,0mov ah,2jnz let let1:int 21hadd dl,30hjnz let1 retdec cxsub3 endpcode endsend begin13. 對(duì)輸入的負(fù)數(shù)求反碼,并用十六進(jìn)制顯示出來(lái)。include 13.mac.model small.datatable db 0123456789A

22、BCDEFs1 db0dh,0ah,input:$s2 db 0dh,0ah,Hex=$;s3 db 0dh,0ah,Binary=$x dw0count db ?.codebegin:mov ax,datamov ah,9int21hmov ds,axmov ah,1jz exitl4:cx,10main proc farint 21hlea dx,s1jz l1l2:cmp al,-cmp al,0dhand al,0fhxchg x,axjz l3lea dx,s2; lea dx,s3mov ah,4ch int 21hmov ah,1 int 21hmov ah,0add x,axjmp l4l1:int 21h; int 21hmain endpcmp al,0dhxchg x,axmovmov ah,1call sub1jinzhimul cxcmp al,0dhmov ah,9mov ah,9int 21hnot xl3:4,4,000fh; jinzhisub11,16,0001hexit:proc for0:jz for1and al,0fhmov ah,0add x,axxchg x,axmov cx,10retmul cxsub1xchg x,axjmp for0for1:endp

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論