![24個匯編實例小程序_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/16/6a42d649-b049-448c-bab0-5aa488b5951d/6a42d649-b049-448c-bab0-5aa488b5951d1.gif)
![24個匯編實例小程序_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/16/6a42d649-b049-448c-bab0-5aa488b5951d/6a42d649-b049-448c-bab0-5aa488b5951d2.gif)
![24個匯編實例小程序_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/16/6a42d649-b049-448c-bab0-5aa488b5951d/6a42d649-b049-448c-bab0-5aa488b5951d3.gif)
![24個匯編實例小程序_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/16/6a42d649-b049-448c-bab0-5aa488b5951d/6a42d649-b049-448c-bab0-5aa488b5951d4.gif)
![24個匯編實例小程序_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-3/16/6a42d649-b049-448c-bab0-5aa488b5951d/6a42d649-b049-448c-bab0-5aa488b5951d5.gif)
下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、24 個匯編小程序題目列表:逆序輸出字符串“BASED ADDRESSIN” G從鍵盤上輸入兩個數(shù),分別放到x, y 單元,求出它們的和試編寫一段程序,要求在長度為10h 的數(shù)組中,找出大于42h 的無符號數(shù)的個數(shù)并存入地址為 up 開始區(qū)域,找出小于42h 的無符號數(shù)的個數(shù)并存入地址為down 的開始區(qū)域鍵盤輸入一段字符串,其中小寫字母以大寫字母輸出,其他字符不變輸出從鍵盤上就收一個小寫字母,找出它的前導字符和后續(xù)字符,在順序顯示這三個字符把一個包含20個數(shù)據(jù)白數(shù)組 M分成兩組:正整數(shù)組P和負整數(shù)組N,分別把這兩個數(shù)組中的數(shù)據(jù)的個數(shù)顯示出來求出首地址為data 的 100 個字數(shù)組中的最小偶
2、數(shù),并把它放在ax 中輸入兩船字符串string1 和 string2 ,并比較兩個字符串是否相等,相等就顯示“match”,否則顯示“no match ”從鍵盤接收一個四位的十六進制數(shù),并在終端顯示與它等值的二進制數(shù)從鍵盤輸入一系列以$為結束符的字符串,然后對其中的非數(shù)字字符計數(shù),并顯示計數(shù)結果有一個首地址為mem勺100個字的數(shù)組,試編程序刪除數(shù)組中所有為零的項,并將后續(xù)項向前壓縮,最后將數(shù)組的剩余部分補上零從鍵盤上輸入一串字符(用回車鍵結束,使用 10 號功能調用)放在 string 中,是編制一個程序測試字符串中是否存在數(shù)字。如有,則把cl 的第五位置1 ,否則將該位置置0在首地址為d
3、ata 的字數(shù)組中,存放了100h 的 16 位字數(shù)據(jù),試編寫一個程序,求出平均值放在 ax 寄存器中,并求出數(shù)組中有多少個數(shù)小于此平均值,將結果放在bx 寄存器中(f 分別考慮有符號數(shù)、無符號數(shù)情況)一直數(shù)組A包含15個互不相等的整數(shù),數(shù)組B包含20個互不相等的整數(shù)。試編制一個程序, 把既在A中又在B中出現(xiàn)的整數(shù)存放于數(shù)組C中設在A、 B 和 D 單元中分別存放著三個數(shù)。若三個數(shù)都不是0, 則求出三個數(shù)的和并存放在S單元,若其中有一個數(shù)為0,則把其它兩個單元也清零。請編寫此程序從鍵盤輸入一系列字符(以回車鍵結束),并按字母、數(shù)字和其他字符分類計數(shù),最后顯示這三類的計數(shù)結果已定義兩個整數(shù)變量A
4、和B,試編寫程序完成以下功能( 1 )若兩個樹種有一個是奇數(shù),則將奇數(shù)存入A 中,偶數(shù)存入B 中( 2)若兩個數(shù)均為奇數(shù),則將兩個數(shù)加1 后存回原變量( 3)若兩個數(shù)均為偶數(shù),則兩個變量均不變寫一段子程序skiplines ,完成輸出空行的功能。空行的行數(shù)由用戶在主程序過鍵盤輸入,并將行數(shù)放在ax 寄存器中設有 10 個學生成績分別是76, 69 , 84, 73, 88, 99, 63, 100 和 80。試編寫一個子程序統(tǒng)計 60-69 分, 70-79 分, 80-89 分, 90-99 分和 100 分的人數(shù),并分別放到S6, S7, S8,S9, S10 單元中編寫子程序嵌套結構的程
5、序,把整數(shù)分別用二進制和八進制顯示出來在 D 盤根目錄建立一個文件,第一次向文件寫入“ 123456” 六個字符,第二次增加“ abcdefg幾個字符從鍵盤上輸入文本文件:“ ”的容后,然后新建一個文件“”,把前一個文件的所有容復制到后一個文件中從鍵盤上輸入一個十進制數(shù),以十六進制數(shù)顯示出來。要求子程序用寄存器參數(shù)傳送方法試編制一個程序,把bx 寄存器中的二進制數(shù)用十六進制數(shù)的形式在屏幕上顯示出來代碼:1. 逆序輸出字符串“BASED ADDRESSIN” Gs1segment stack定義棧段s1top s1dw 100 dup() ;label word ;topendss2S2segm
6、ent;db BASED ADDRESSING,$ ;ends定義棧空間為100指向棧頂定義數(shù)據(jù)段s2定義字符串ss3定義代碼段s3segmentassume cs:s3,ds:s2,ss:s1main proc farmovax,s1;棧初始化movss,axleasp,top; 棧初始化movax,s2;數(shù)據(jù)段初始化movds,ax; 數(shù)據(jù)段初始化movsi,15l: movdl,ssi;dl 獲取字符串s 的最后一個(從零開始的第十五個字符)movah,2; 調用int 21h 2 號功能輸出dl 上的值int21hdecsi;寄存器減一,準備獲取下一個字符cmpsi,0jalmovah
7、,4ch;終止int21hmain endps3 endsendmain2. 從鍵盤上輸入兩個數(shù),分別放到上輸入兩個數(shù),分別放到x, y 單元,求出它們的和s1 segment stackdw 100h dup() top label word s1 endss2segmenth1dbPlease input x:,$ ;提示輸入h2dbPlease input y:,$ ;提示輸入h3dbz=x+y:,$;提示輸出crlfdb0dh,0ah,24h;定義回車換行xdwydws2endss3 segmentassume cs:s3,ds:s2,ss:s3main proc farmov ax,
8、s1 ;初始化mov ss,ax lea sp,top mov ax,s2leadx,h1;int 21h 9號功能輸出“提示輸入 X”的字符串movah,9int21hxorbx,bx;bx清零,即把bx 置零InputX:movah,1;輸入一個字符int21hcmpal,0dh;判斷時候為“回車”字符jzexit1;如果是回車字符就跳轉到eXit1cmpal,30h;和30h (即字符0的asii值)比較jlexit1; 如果輸入字符小于0 ,跳轉到eXit1cmpal,39h;和39h(即字符9的ascii值)比較jgexit1;如果輸入字符大于9 ,跳轉到eXit1subal,30h
9、;al減去30h, 輸入字符轉化成數(shù)字(從這一行開始到后面的 add bx,ax 為輸入字符轉化為數(shù)字的處理方法)cbw;al擴充為aXxchgax,bxmovcx,10mulcxxchgax,bxaddbx,ax;sub al,30h開始到這一行為輸入字符轉化為數(shù)字的處理方法jmpInputXexit1: mov x,bx;把輸入的存于bX 的放到X 中l(wèi)eadx,crlfmovah,9int21hleadx,h2movah,9int21hxorbx,bxInputY:;和 InputX 類似,輸入ymovah,1int21hcmpal,0dhjzexit2cmpal,30hjlexit2J
10、初始化mov ds,axcmpal,39hjgexit2subal,30hcbwxchgax,bxmovcx,10mulcxxchgax,bxaddbx,axjmpInputYexit2: mov y,bx把輸入的存于bx 的放到 y 中mov bx,xaddbx,yleadx,crlfmovah,9int21Hleadx,h3movah,9int21hxorsi,simovax,bxmovcl,10divclmovdl,ahmovdh,0pushdxincsimov ah,0cmpal,0jnzl4popdxadddl,30hmovah,2int21hdecsicmpsi,0jnzl5J;s
11、iJl4:Jl5:JJJ此時 bx 為兩數(shù)加和清零,用作計數(shù)把和放到ax 上把和連續(xù)除以10 知道和變?yōu)榱?,余?shù)依次進棧重要,不能漏寫余數(shù)依次出棧 余數(shù)轉換為顯示的余數(shù)字符 輸入余數(shù)字符mov ah,4chint 21Hmain endps3 endsend main3. 是編寫一段程序,要求在長度為10 的數(shù)組中,找出大于42h 的無符號數(shù)的個數(shù)并存入地址為 up 開始區(qū)域,找出小于42h 的無符號數(shù)的個數(shù)并存入地址為down 的開始區(qū)域,并分別顯示up、down數(shù)組的個數(shù)和數(shù)組的數(shù)字s1 segment stackdw 100h dup()top label words1 endss2 s
12、egmenth1 db the num of up array and the up array are(prints in decimalism) :,$h2 db the num of down array and the down array are(prints in decimalism) :,$ crlf db 0dh,0ah,24harray db0,50h,11h,61h,22h,72h,33h,73h,41h,74h,$; 定義數(shù)組arrayup db 10 dup();定義 up 數(shù)組down db 10 dup(); 定義 down 數(shù)組s2 ends s3 segmen
13、tassume cs:s3,ds:s2,ss:s3 main proc farmovax,s1movss,axleasp,topmovax,s2movds,axmovsi,0movdi,1movbp,1repeat: cmp arraysi,42h ;把array 數(shù)組中小于 42h的值放到down數(shù)組里,大于 42h 的值放到up 數(shù)組里面jb downarray mov dl,arraysi mov upbp,dl inc si cmp si,10jz exit1 inc bp jmp repeatdownarray:mov dl,arraysi mov downdi,dl inc sic
14、mp si,10jz exit2 inc di jmp repeatexit1:sub di,1jmp exitexit2:sub bp,1把分配好的up 數(shù)組和 down 數(shù)組在其有效數(shù)字后面添加exit: mov dx,bp ;$ ,便于后面的輸出結束mov up0,dlinc bpmov upbp,$ mov dx,di mov down0,dl inc dimov downdi,$mov cl,10mov si,0lea dx,h1mov ah,9 int 21hPrintUparray: cmp upsi,$ jz next mov al,upsi call print inc si
15、jmp PrintUparraynext:lea dx,crlfmov ah,9int 21hlea dx,h2int 21hxor si,siPrintDownArray:cmp downsi,$jz atendmov al,downsicall printinc sijmp PrintDownArrayprint proc near ;print為輸出十進制輸出某個數(shù)的子程序mov di,0rediv: mov ah,0div clmov dl,ahmov dh,0push dxinc dicmp al,0jnz redivbreak: pop dxadd dl,30hmov ah,2in
16、t 21hdec dicmp di,0jnz breakmov dl, mov ah,2int 21Hretprint endpatend: mov ah,4chint 21Hmain endps3 endsend main4. 鍵盤輸入一段字符串,其中小寫字母以大寫字母輸出,其他字符不變輸出51 segment stackdw 100h dup()top label words1 ends52 segmenth1 db Please input a string:,$ h2 db The changed string is:,$ crlf db 0dh,0ah,24htemp dbs2 en
17、ds53 segmentassume cs:s3,ds:s2,ss:s3main proc farmov ax,s1mov ss,ax lea sp,top mov ax,s2mov ds,axlea dx,h1mov ah,9 int 21hmov si,0l: mov ah,1int 21hcmp al,0dhjz exit cmp al,a jl putin cmp al,z jg putin sub al,20h ; 把小寫字符變?yōu)榇髮懽址鹥utin:mov tempsi,al ; 把字符放到temp 數(shù)組里inc si jmp lexit: lea dx,crlf ;輸出 tmp 數(shù)
18、組mov ah,9int 21hlea dx,h2mov ah,9int 21hinc simov tempsi,$lea dx,tempmov ah,9int 21hmov ah,4ch int 21H main endp s3 endsend main5. 從鍵盤上就收一個小寫字母,找出它的前導字符和后續(xù)字符,在順序顯示這三個字符51 segment stack dw 100h dup()top label words1 ends52 segmenth1 db Please input a lowercase: ,$ h2 db The the three chars are: ,$ cr
19、lf db 0dh,0ah,24h s2 ends53 segmentassume cs:s3,ds:s2,ss:s3main proc farmov ax,s1mov ss,ax lea sp,top mov ax,s2 mov ds,axl: lea dx,h1 mov ah,9 int 21hmov ah,1int 21hcmp al,ajl lcmp al,zjg lmov cl,allea dx,crlfmov ah,9int 21Hlea dx,h2mov ah,9int 21hdec clmov dl,cl ;輸出前導字符mov ah,2int 21hmov dl, mov ah
20、,2int 21hinc clmov dl,cl ;輸出該字符mov ah,2int 21hmov dl, mov ah,2int 21hinc clmov dl,cl ;輸出后導字符mov ah,2int 21hmov ah,4chint 21Hmain endps3 endsend main6.把一個包含20個數(shù)據(jù)的數(shù)組 M分成兩組:正整數(shù)組 P和負整數(shù)組N,分別把這兩個數(shù)組 中的數(shù)據(jù)的個數(shù)顯示出來s1 segment stackdw 100h dup()top label words1 endss2 segmenth1 db the positive number is: ,$h2 db
21、 the negative number is: ,$crlf db 0dh,0ah,24harraydw50h,-11h,61h,-22h,72h,-33h,73h,-41h,74h,21h,67h,-90h,73h,77h,-1h,-89h,-11h,61h,-22h,20h,$s2 endss3 segmentassume cs:s3,ds:s2,ss:s3main proc farmov ax,s1mov ss,axlea sp,topmov ax,s2mov ds,axmov bx,0mov si,0l: mov dx,arraysicmp dx,0jl addlow ;有符號數(shù)比較
22、用jladd si,2cmp si,40jz exitjmp laddlow: inc bxadd si,2cmp si,40jz exitjmp lleadx,h2movah,9int21hmovax,bxcallprintleadx,crlfmovah,9int21hleadx,h1movah,9int21hmov ax,20subax,bxcallprintjmpatendexit:打印數(shù)字字符的子程序print proc nearmov cl,10 mov si,0repeat: div cl mov dl,ah add dl,30h mov dh,0 push dx inc si m
23、ov ah,0 cmp al,0 jnz repeatl2: pop dx mov ah,2 int 21h dec si cmp si,0 jnz l2retprint endpatend: mov ah,4chint 21H main endps3 endsend main7. 打印輸出首地址為data 的 20 個字數(shù)組中的最小偶數(shù)51 segment stackdw 100h dup()top label words1 ends52 segmenth1 db the min even number is: ,$crlf db 0dh,0ah,24hdwdata50,-11,61,-22
24、,72,-33,73,-41,74,21,67,-90,73,77,-1,-89,-11,61,-22,20,$s2 ends53 segmentassume cs:s3,ds:s2,ss:s1main proc farmov ax,s1mov ss,axlea sp,topmov ax,s2mov ds,axmov bx,65534 ;bx存最小數(shù),初始令最小值置為65534mov si,0mov cl,100mov dl,2l2: mov ax,datasicmp ax,0jnl l4neg ax ;如果是負數(shù),則求補14: div clmov al,ahmov ah,0div dl cm
25、p ah,0 jnz l1cmp bx,datasi ;jl l1 ;mov bx,datasi ;比較最小值和數(shù)組中的每個數(shù)如果數(shù)組中的數(shù)大于最小值跳轉到l1如果數(shù)組中的數(shù)小于最小值則將其賦給最小值l1: add si,2cmp si,40jz exitjmp l2exit: lea dx,h1mov ah,9int 21hcmp bx,0jnl l5neg bxmov dl,-mov ah,2int 21h15: mov ax,bxcall print ;調用子程序輸出最小值jmp atendprint proc nearmov cl,10mov si,0repeat: div clmov
26、 dl,ahadd dl,30hmov dh,0push dxinc simov ah,0cmp al,0jnz repeat13: pop dx mov ah,2 int 21h dec si cmp si,0 jnz l3ret print endpatend: mov ah,4ch int 21Hmain endps3 endsend main8. 輸入兩船字符串string1 和 string2 , 并比較兩個字符串是否相等,相等就顯示“ match”,否則顯示“no match ”s1segment stackdw 100h dup()top label words1 endss2
27、segmenth1dbPlease input the first string: ,$h2dbPlease input the second string: ,$h3 db MATCH,$h4 db NO MATCH,$crlf db 0dh,0ah,24hstr1 db50,50 dup($)str2 db50,50 dup($)s2 endss3 segmentassume cs:s3,ds:s2,ss:s3main proc farmov ax,s1mov ss,ax lea sp,top mov ax,s2mov ds,axlea dx,h1 mov ah,9 int 21hlea
28、dx,str1 mov ah,0ah int 21hlea dx,crlf mov ah,9 int 21hlea dx,h2int 21hlea dx,str2 mov ah,0ah int 21hlea dx,crlf mov ah,9 int 21hmovdl,str1+1;str1+1為 str1實際的字符個數(shù)cmpdl,str2+1;str2+1為 str2實際的字符個數(shù)jnzlmovsi,2movdl,str1sicmpdl,str2sijnzlincsicmpsi,50jzl3jmpl2leadx,h4 ;輸出不匹配信息movah,9int21hleadx,h3 ;輸出匹配信息m
29、ovah,9int21hl2:l:l3:mov ah,4ch int 21Hmain endps3 endsend main9. 從鍵盤接收一個四位的十六進制數(shù),并在終端顯示與它等值的二進制數(shù)s1 segment stack dw 100h dup()top label words1 endss2 segmenth1dbPlease input a hexadecimal number: ,$h2dbThe number is printed in binary number: ,$temp db 17 dup($) crlf db 0dh,0ah,24h s2 endss3 segmenta
30、ssume cs:s3,ds:s2,ss:s3main proc farmov ax,s1mov ss,ax lea sp,top mov ax,s2 mov ds,axrepeat: lea dx,h1mov ah,9int 21hmov bx,0mov cx,4newchar:;接收新字符mov ah,1int 21hcmp al,30h jb repeatcmp al,46hjg repeat cmp al,39h jnb l1 ; sub al,30h jmp l211: cmp al,41h jb repeat ; sub al,37h ; jmp l212: cbw;l2xchg
31、ax,bx mov dx,10h mul dx xchg ax,bx add bx,ax ;loop newchar dec cxcmp cx,0 jnz newcharlea dx,crlf mov ah,9 int 21h lea dx,h2 int 21hmov si,0mov cx,10h ;cxl5: rol bx,1 ;bx jc l3 ;mov tempsi,0 jmp l413: mov tempsi,1 l4: inc siloop l5lea dx,temp mov ah,9 int 21h如果輸入字符大于9 跳到 l1如果輸入字符小于 A,則輸入錯誤,跳到輸入字符為AZ,
32、故相應地要減37h為把輸入字符轉化為數(shù)值作計數(shù)器,即待會要循環(huán)16 次循環(huán)左移以為,最高位進標志位若標志位為1 則跳轉到l3repeatmov ah,4chint 21H main endps3 endsend main10 從鍵盤輸入一系列以$為結束符的字符串,然后對其中的非數(shù)字字符計數(shù),并顯示計數(shù)結果51 segment stack dw 100h dup()top label words1 ends52 segmenth1dbPlease input a string: ,$h2dbThe number of the chars that is not digit:,$crlf db 0
33、dh,0ah,24h s2 ends53 segmentassume cs:s3,ds:s2,ss:s3main proc farmov ax,s1mov ss,ax lea sp,top mov ax,s2mov ds,axlea dx,h1mov ah,9 int 21hmov cx,0l2: mov ah,1int 21h cmp al,$ jz exit cmp al,30hjb lcmp al,39hjnb ljmp l2l: inc cxjmp l2 exit: lea dx,crlfmov ah,9int 21hlea dx,h2int 21hmov si,0mov bl,10m
34、ov ax,cx14: div blmov dl,ahmov dh,0push dxinc simov ah,0cmp al,0jnz l415: pop dxadd dl,30hmov ah,2int 21hdec sicmp si,0jnz l5mov ah,4chint 21Hmain endps3 endsend main并將后續(xù)項11.有一個首地址為 mem勺10個字的數(shù)組,試編程序刪除數(shù)組中所有為零的項, 向前壓縮,最后將數(shù)組的剩余部分補上零s1 segment stackdw 100h dup()top label words1 ends s2 segmentmem dw 0,1
35、,0,3,0,0,4,5,6,0,$crlf db 0dh,0ah,24hs2 endss3 segmentassume cs:s3,ds:s2,ss:s3main proc farmov ax,s1mov ss,ax lea sp,top mov ax,s2 mov ds,axmov si,0mov di,2repeat: cmp di,20 jz exit mov bx,memsi mov dx,memdicmp bx,0 jnz next xchg bx,dxmov memsi,bx mov memdi,dxnext:cmp memsi,0jz l add si,2l: add di,2
36、 jmp repeatexit: mov ah,4ch int 21Hmain endps3 ends end main; 以下是該算法描述; 定義兩個指針,當前指針si 和檢查指針di ,先把 si 指針指向第一個字得到的值bx,;di指向第二個字得到的值dx。若bx為0, di自力口 2,否則,則交換這兩字,; 若此時 si 指向字為0,則di, 否則, di , si 都自己加2。如此循環(huán)直到di 指向最后一個; 這樣就把所有非零字至于前面了。string 中,是編制1,否則將該位置置012. 從鍵盤上輸入一串字符(用回車鍵結束,使用10 號功能調用)放在一個程序測試字符串中是否存在數(shù)字
37、。如有,則把cl 的第五位置s1 segment stack dw 100h dup()top label words1 endss2 segmenth1dbPlease input a string: ,$h2dbcx: ,$crlf db 0dh,0ah,24hstring db 50,50 dup($)s2 endss3 segmentassume cs:s3,ds:s2,ss:s3main proc farmov ax,s1mov ss,ax lea sp,top mov ax,s2mov ds,axand cl,0dfh ; 先假設無數(shù)字,置0lea dx,h1 mov ah,9 i
38、nt 21h lea dx,stringmov ah,10d int 21hmov si,212: cmp stringsi,$ jz exitmov dl,stringsicmp dl,30h jb lcmp dl,39hjnb lor cl,20h ; 有數(shù)字,置1jmp exitl: inc sijmp l2exit: lea dx,crlf mov ah,9 int 21h lea dx,h2 int 21hmov ax,cx call print jmp atendprint proc nearmov cl,10 mov si,0repeat: div cl mov dl,ah ad
39、d dl,30h mov dh,0 push dx inc simov ah,0 cmp al,0 jnz repeat13: pop dx mov ah,2 int 21h dec si cmp si,0 jnz l3retprint endp atend: mov ah,4chint 21Hmain endps3 endsend main13. 在首地址為data 的字數(shù)組中,存放了 10 個 16 位字數(shù)據(jù),試編寫一個程序,求出平均值放在 ax 寄存器中,并求出數(shù)組中有多少個數(shù)小于此平均值,將結果放在bx 寄存器中(f 分別考慮有符號數(shù)、無符號數(shù)情況)s1 segment stack d
40、w 100h dup()top label words1 endss2 segmentdata dw -1,0,1,-2,2,3,-3,-4,4,15,$ crlf db 0dh,0ah,24h s2 endss3 segmentassume cs:s3,ds:s2,ss:s3 main proc farmov ax,s1mov ss,ax lea sp,top mov ax,s2mov ds,axmov si,0mov ax,0l3: cmp datasi,$ jz exitmov dx,datasicmp dx,0jnl l1neg dx sub ax,dxjmp l211: add ax
41、,dx12: add si,2 jmp l3exit: mov cl,10 ;平均值放到ax 中div clmov ah,0 mov si,0 mov bx,015: cmp datasi,$ ;小于平均值的數(shù)的個數(shù)放到bx 中jz exit2 cmp ax,datasijz l6jl l6 inc bx16: add si,2 jmp l5exit2: mov ah,4ch int 21Hmain endps3 ends end main14.一直數(shù)組A包含15個互不相等的整數(shù),數(shù)組B包含20個互不相等的整數(shù)。試編制一個程序,把既在 A中又在B中出現(xiàn)的整數(shù)存放于數(shù)組C中并顯示C中的數(shù)值; 兩
42、層循環(huán)比較得出兩個數(shù)組中相同的數(shù)值s1 segment stack dw 100h dup()top label words1 endss2 segmentdwa dw 1h,2h,3h,4h,5h,6h,7h,8h,9h,10h,11h,12h,13h,14h,15h,$ b21h,22h,23h,24h,25h,6h,18h,19h,10h,11h,12h,34h,14h,53h,31h,32h,33h,36h,7h,67h, $c dw 16 dup($) crlf db 0dh,0ah,24hs2 endss3 segment assume cs:s3,ds:s2,ss:s3main
43、proc farmovax,s1movss,axleasp,topmovax,s2movds,axmov si,0 mov di,0 mov bp,0l4: cmp di,40jz l2jmp l312: add si,2cmp si,30jz exit mov di,013: mov ax,asi mov bx,bdi cmp ax,bx jnz lmov cbp,ax add bp,2l: add di,2 jmp l4exit: mov bp,0l6: cmp cbp,$jz atend mov ax,cbp call print add bp,2 mov dl, mov ah,2 in
44、t 21h jmp l6print proc nearmov cl,10repeat: div cl mov dl,ah add dl,30h mov dh,0 push dx inc si mov ah,0 cmp al,0 jnz repeatl5: pop dx mov ah,2 int 21h dec si cmp si,0 jnz l5ret print endpatend: mov ah,4ch int 21Hmain endps3 ends end main15.設在A、B和D單元中分別存放著三個數(shù)。若三個數(shù)都不是0,則求出三個數(shù)的和并存放在 S 單元,若其中有一個數(shù)為0,則把其
45、它兩個單元也清零。請編寫此程序s1 segment stackdw 100h dup() top label word s1 endss2 segment adw1h,$bdw-11h,$ddw0h,$sdw2dup($)crlf db 0dh,0ah,24hs2 endss3 segmentassume cs:s3,ds:s2,ss:s3 main proc farmov ax,s1mov ss,axlea sp,topmov ax,s2mov ds,axmov ax,a0mov bx,b0mov dx,d0cmp ax,0jz lcmp bx,0jz lcmp dx,0jz lmov cx
46、,0cmp ax,0 jnl add_ax neg ax ; 減法需先求補 sub cx,ax jmp l2add_ax: add cx,ax12: cmp bx,0jnl add_bxneg bxsub cx,bxjmp l3add_bx: add cx,bx13: cmp dx,0jnl add_dxneg dxsub cx,dxjmp l4add_dx: add cx,dx14: mov s0,cxjmp exitl: mov a0,0 mov b0,0mov d0,0exit:mov ah,4chint 21Hmain endps3 endsend main最后顯16. 從鍵盤輸入一系
47、列字符(以回車鍵結束),并按字母、數(shù)字和其他字符分類計數(shù),示這三類的計數(shù)結果51 segment stack dw 100h dup()top label words1 ends52 segmentletter db the number of letter: ,$digit dbthe number of digit: ,$others dbthe number of other chars: ,$crlf db 0dh,0ah,24h s2 ends53 segmentassume cs:s3,ds:s2,ss:s3main proc farmov ax,s1mov ss,ax lea s
48、p,top mov ax,s2 mov ds,axmov bx,0mov cx,0mov dx,0repeat: mov ah,1int 21hcmp al,0dh jz exitcmp al,30hjb count_otherscmp al,zjnb count_otherscmp al,39hjb count_digitcmp al,Ajb count_otherscmp al,Zjb count_lettercmp al,ajb count_othersjmp count_lettercount_letter:inc bxjmp repeatcount_digit:inc cxjmp r
49、epeatcount_others:inc dxjmp repeatexit:push cxpushdxcallprint_crlflea dx,lettermov ah,9int 21hmov ax,bxcallprint_axcallprint_crlflea dx,othersmov ah,9int 21hpop dx ; 棧,后進先出,先進后出mov ax,dxcallprint_axcallprint_crlflea dx,digitmov ah,9int 21hpop cx ;print_ax 會修改 cx 的值 , 故要先把cx 進棧mov ax,cxcallprint_axjmp exit2print_crlfprocnearlea dx,crlfmov ah,9int 21hretprint_crlf endpprint_ax proc ne
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年高壓液壓柱塞泵馬達項目發(fā)展計劃
- 2025年度新能源材料研發(fā)保密與共享合同
- 2025年度綠色建筑項目財產贈與合同
- 2025年(半)干式煙氣脫硫成套設備項目建議書
- 2025年度出境領隊帶團操作規(guī)范合同范本
- 水務生態(tài)保護規(guī)劃計劃
- 2025年食品分離機械項目合作計劃書
- 持續(xù)改進教學工作的機制計劃
- 高危行業(yè)的安全防控計劃
- 合理安排急診排班的重要性計劃
- 《煤礦安全培訓知識》課件
- 消防安全電動車培訓
- 阿爾茲海默病的家庭護理
- 腹水形成的原因及治療
- 糖尿病酮癥酸中毒小講課
- 高中地理必修第一冊期末試卷及答案-中圖版-2024-2025學年
- 護理核心制度測試題+參考答案
- 《2023版CSCO卵巢癌診療指南》解讀課件
- 福建省公路水運工程試驗檢測費用參考指標
- 人教版一年級道德與法治下冊全冊教案
- 2024-2030年中國化妝鏡行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略分析報告
評論
0/150
提交評論