匯編語(yǔ)言編程題目資料答案_第1頁(yè)
匯編語(yǔ)言編程題目資料答案_第2頁(yè)
匯編語(yǔ)言編程題目資料答案_第3頁(yè)
匯編語(yǔ)言編程題目資料答案_第4頁(yè)
已閱讀5頁(yè),還剩13頁(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、5.1 編寫(xiě)程序,從鍵盤(pán)接收一個(gè)小寫(xiě)字母,然后找出它的前導(dǎo)字符和后續(xù)字符,再按順序用大寫(xiě)字母顯示這三個(gè)字符?!窘狻浚?MAIN PROC FARstart:push dssub ax,axpush axinput:mov ah,7Hint 21Hcmpe:cmp al,20HJE exitcmp al,61HJL inputcmp al,7AHJG inputprint:sub al,01Hmov dl,almov ah,02Hint 21Hadd al,01Hmov dl,almov ah,02Hint 21Hadd al,01Hmov dl,al1/18mov ah,02Hint 21H;

2、 輸出換行回車(chē)mov dl,0AHmov ah,02Hint 21Hj mp inputexit :retMAIN ENDPEND start5.2將 AX 寄存器中的16 位數(shù)分成4 組,每組4 位,然后把這4 組數(shù)分別放在AL、 BL、 CL 和DL 中?!窘狻浚?DB4dup(?).stack100H.codeMAINPROC FARstart:pushdsandax,00Hpushaxmovax,1234Hmovcx,04Hmovsi,00Hlop:pushcxmovcl,04Hrolax,clpushaxandal,0FH2/18movBYTEPTRxsi,alpopaxpopcxa

3、ddsi,2Looplopmoval,Xmovbl,X+2movcl,X+4movdl,X+6print:movah,02Hint21Hmovdl,almovah,02Hint21Hmovdl,blmovah,02Hint21Hmovdl,clmovah,02Hint21Hexit:retMAINENDPEND start5.3試編寫(xiě)一程序,要求比較兩個(gè)字符串STRING1和 STRING2所含字符是否相同,若相同則顯示 MATCH,若不相同則顯示NO MATCH?!窘狻浚?datasegmentstring1db"111111111",13,10,"$"

4、;string2db"222222222",13,10,"$"inf1db"match!",13,10,"$"3/18inf2db"nomatch!",13,10,"$"dataendscodesegmentmainprocfarassumeds:data,cs:code,es:codestart:pushdsmovax,0pushaxmovax,datamovds,axmoves,axleasi,string1leadi,string2movcx,9repzcmpsbjzm

5、atchleadx,inf2jmpdispmatch:leadx,inf1disp :movah,09int21hretmainendpcodeendsendstart5.4試編寫(xiě)一程序,要求能從鍵盤(pán)接收一個(gè)個(gè)位數(shù)N,然后響鈴N 次( 響鈴的ASCII 碼為 07H)。【解】: mainprocfarstart:pushdssubax,axpushaxinput:movah,01Hint21H4/18cmpal,20Hjeexitcmpal,30Hjleinputcmpal,3AHjgeinputsubal,30Hmovcx,axandcx,0FFHlop:movdl,07Hmovah,2Hi

6、nt21Hlooplopjmpinputexit:retmainendpendstart5.5編寫(xiě)程序,將一個(gè)包含有20 個(gè)數(shù)據(jù)的數(shù)組M分成兩個(gè)數(shù)組:正數(shù)數(shù)組P 和負(fù)數(shù)數(shù)組N,并分別把這兩個(gè)數(shù)組中數(shù)據(jù)的個(gè)數(shù)顯示出來(lái)?!窘狻浚篋ATA SEGMENTBUF DB -32,25,36,-18,-64,0,-3COUNT EQU $-BUFPLUS DB ? ;存放正數(shù)MINUS DB ? ;存放負(fù)數(shù)DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX, DATA5/18MOV DS, AXMOV BL, 0 ;負(fù)數(shù)個(gè)數(shù)MOV DL, 0

7、;正數(shù)個(gè)數(shù)MOV SI, OFFSET BUF ;首地址MOV CX, COUNT ;循環(huán)次數(shù)LOP1: MOV AL, SI ;取第一個(gè)數(shù)CMP AL, 0 ;和 0比較JGE NEXT0 ;大于等于0,轉(zhuǎn)INC BL ;小于 0,BL 加1JMP NEXT1 ;轉(zhuǎn)NEXT1NEXT0: INC DL ;大于等于 0,DL 加 1NEXT1: INC SI ;指針增 1DEC CX ;循環(huán)次數(shù)減1JNZ LOP1 ;CX 不等于 0,轉(zhuǎn)回MOV MINUS, BL ;存儲(chǔ)負(fù)數(shù)個(gè)數(shù)MOV PLUS, DL ;存儲(chǔ)正數(shù)個(gè)數(shù)CODE ENDSEND START5.6試編寫(xiě)一匯編語(yǔ)言程序,要求從鍵盤(pán)

8、接收一個(gè)4 位的十六進(jìn)制數(shù),并在終端上顯示與它等值的二進(jìn)制數(shù)?!窘狻浚簊tacks segment stacks db 20 dup(0)stacks endsdata segmentn equ 4char db n+1 ;輸入內(nèi)存字符db 06/18db n+1 dup(0)input db 'Input the number:',0dh,0ah,'$'enter db 0dh,0ah,'$'output db 'Result is:',0dh,0ah,'$'data endscode segmentassume

9、 cs:code,ss:stacks,ds:datastart: mov ax,datamov ds,axlea dx,inputmov ah,9int 21hlea dx, charmov ah,0ahint 21hlea dx,entermov ah,9int 21hmov si,2mov cx,4l0: mov bl,charsicmp bl,30hjb startcmp bl,39hjbe l00cmp bl,61hjb start7/18cmp bl,66hja startsub bl,57hjmp l333l00: sub bl,30hl333:mov charsi,blinc s

10、idec cxjnz l0lea dx,outputmov ah,9int 21hmov si,2l000:mov bl,charsimov ch,4mov cl,4shl bl,clll00:test bl,80hjnz l1mov dl,'0'mov ah,2int 21hjmp l2l1: mov dl,'1'mov ah,28/18int 21hl2: shl bl,1dec chjnz ll00inc sicmp si,6jne l000mov ah,4chint 21hcode endsend start5.7設(shè)有一段英文,其字符變量名為ENG,并以

11、 $字符結(jié)束。試編寫(xiě)一程序,查對(duì)單詞SUN在該文中的出現(xiàn)次數(shù),并以格式“SUNXXXX”顯示出次數(shù)?!窘狻浚?movZ,0leaesi,ENGlp1:lodsblp2:cmpal,"$"jztoQuitcmpal,"S"jnzlp1lodsbcmpal,"U"jnzlp2lodsbcmpal,"N"jnzlp2incZjmplp1toQuit:5.8有一個(gè)首地址為MEM的 100D 字?jǐn)?shù)組,試編制程序刪除數(shù)組中所有為零的項(xiàng),并將后續(xù)項(xiàng)向前壓縮,最后將數(shù)組的剩余部分補(bǔ)上零。9/18【解】: stack100H.dat

12、amem dw 12,0,0,0,0,0,1,2,3,6,4,7,8,2,1,0,0,54,5,0,2,4,7,8,0,5,6,2,1,4,8,5,1,45,7, 5,1,2,0,2,4,0,2,54,0,12,0,0,0,0,0,1,2,3,6,4,7,8,2,1,0,0,54,5,0,2,4,7,8,0,5,6,2,1,4 ,8,5,1,45,7,5,1,2,0,2,4,0,2,54,0,45,7,5,1,2,0,2,4,0,2 .codeMAINPROC FARstart:pushdsandax,0pushaxmovax,datamovds,ax;-movax,0Hmovbx,64Hmo

13、vcx,64Hmovsi,0FFFEHrepeat:ADD si,2HcmpMEMsi,0HJEcallslooprepeatcalls:INCaxcallsortcmpax,1HJElastValueDEC cxjmprepeatexit:retlastValue:10/18movmembx,0HDEC cxjmprepeatMAINENDPsortPROC NEARpushcxpushsisubsi,2Hs:addsi,2Hmovdx,memsimovmemsi+2,dxloopsreturn:popsipopcxretsortENDPEND start5.9在 STRING到 STRIN

14、G+99單元中存放著一個(gè)字符串,試編制一程序測(cè)試該字符串中是否存在數(shù)字。如有,則把CL 的第 5 位置 1,否則將該位置0?!窘狻浚篨OR EBX,EBXMOV ESI,OFFSET STRINGMOV ECX,99START_LOOP:LODSBCMP AL,'0'JC LOOP_NEXTCMP AL,'9'JNC LOOP_NEXTOR BL,10HLOOP_NEXT:11/18LOOP START_LOOPMOV CL,BL5.10在首地址為T(mén)ABLE的數(shù)組中按遞增次序存放著100H 個(gè) 16 位補(bǔ)碼數(shù)。試編寫(xiě)一個(gè)程序把出現(xiàn)次數(shù)最多的數(shù)及其出現(xiàn)次數(shù)分別存放

15、于AX 和 CX中。【解】:datasegmentTable dw0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9dw0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9dw0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9dw0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9dw0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9dw0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9dw0,1,2,3,4,5,6,7,8,9,0

16、,1,2,3,4,5,6,7,8,9dw0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9dw0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9dw5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,-1,-1Result dw0,0,0,0dataendscodesegmentassumecs:code,ds:datastart:movax,datamov ds,ax;-mov si,offsetTablemov ax,si;ax存放最大數(shù)mov bx,si;bx存放最小數(shù)mov cx,199;循環(huán) 199次C001

17、:inc siinc simov dx,sicmp dx,axjg C00212/18cmp dx,bxjl C003jmp C004C002:mov ax,dxjmp C004C003:mov bx,dxC004:loop C001; 保存結(jié)果mov Result,axmov Result+2,bx;-mov si,offsetTablemov cx,200C005:mov ax,sixor dx,dx;-push cxmov di,offsetTablemov cx,200C006:mov bx,dicmp ax,bxjnz C007inc dxC007:inc diinc di13/18

18、loop C006pop cx;-cmp dx,Result+6jle C008mov Result+4,axmov Result+6,dxC008:inc siinc siloop C005;-movax,4c00hint21hcodeendsendstart;最后結(jié)果Result9,-1,5,365.11試編制一個(gè)程序,把AX中的十六進(jìn)制數(shù)轉(zhuǎn)換為ASCII 碼,并將對(duì)應(yīng)的ASCII 碼依次存放到 MEM數(shù)組中的4 個(gè)字節(jié)中。例如,當(dāng)(AX) 2A49H時(shí),程序執(zhí)行完后,MEM中的 4 個(gè)字節(jié)內(nèi)容分別為 39H, 34H,41H 和 32H?!窘狻浚?datasegmentxdb'Y

19、','$'ydb'N','$'dataendscodesegmentassumecs:code,ds,datastart:movax,datamovds,axmovah,01int21hcmpal,'a'jaabc14/18abc:cmpal,'z'jbabc1retabc1:movdl,offsetxmovah,9int21hretcmpal,'A'jaabab:cmpal,'Z'jbab1retab1:movdl,offsetxmovah,9int21hretcmpal,

20、'z'jaaccmpal,'A'jbacac:movdl,offsetymovah,9int21hretmovah,4chint21hcodeendsendstart5.12已知數(shù)組 A 包含 15 個(gè)互不相等的整數(shù),數(shù)組B 包含 20 個(gè)互不相等的整數(shù)。試編制一程序,把既在 A 中又在 B 中出現(xiàn)的整數(shù)存放于數(shù)組C 中。【解】: DATASEGMENTADB 1,3,4,6,10,12,15,21,33,2,40,42,46,48,55BDB 2,3,6,21,33,41,55,88,8,66,21,10,22,23,56,48,50,51,89,100ZDB 15 DUP (?)15/18DATAENDSCODESEGMENTASSUME DS:DATA,CS:CODESTART:MOVAX,DATAMOVDS,AXLEASI,ALEABX,ZMOVCX,15CLDLOP1:LODSBPUSHCX(保存外環(huán) CX)MOVCX,20(內(nèi)環(huán)次數(shù))LEADI,B( 每次內(nèi)環(huán)完,重新賦值 )LOP2:CMPAL,DIJELOP3(相等,退出內(nèi)環(huán))INCDILOOPLOP2JMPLOP4(內(nèi)環(huán)完畢而沒(méi)有相等的就直接到外環(huán))LOP3:M

溫馨提示

  • 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)論