收藏 分享(赏)

汇编语言小程序例子.doc

上传人:cjc2202537 文档编号:5956994 上传时间:2019-03-22 格式:DOC 页数:24 大小:20.11KB
下载 相关 举报
汇编语言小程序例子.doc_第1页
第1页 / 共24页
汇编语言小程序例子.doc_第2页
第2页 / 共24页
汇编语言小程序例子.doc_第3页
第3页 / 共24页
汇编语言小程序例子.doc_第4页
第4页 / 共24页
汇编语言小程序例子.doc_第5页
第5页 / 共24页
点击查看更多>>
资源描述

1、1. AX101CH,0CLCODE SEGMENTASSUME CS:CODESTART: MOV CX, 0MOV DX,17AA1: SUB DX, 1JZ AA3SHL AX, 1JNC AA2INC CHJMP AA1AA2: INC CLJMP AA1AA3: MOV AH,4CHINT 21HCODE ENDSEND START2. STRING1STRING2MATCHNO MATCHDATA SEGMENTR1 DB MATCH,0AH,0DHR2 DB NO MATCH,0AH,0DHSTRING1 DB XXXXXN1 EQU $-STRING1STRING2 DB YY

2、YYYN2 EQU $-STRING2DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX,DATAMOV DS,AXMOV AX,N1CMP AX,N2JNZ AA1ADD AX,1LEA SI,STRING1LEA DI,STRING2AA2: MOV BL,SIMOV BH,DIINC SIINC DISUB AX,1JZ AA3CMP BL,BHJZ AA2JMP AA1AA3: LEA BX,R1MOV CX,7AA4: MOV DL,BXINC BXMOV AH,2INT 21HLOOP AA4JMP EAA1: LEA

3、BX,R2MOV CX,10AA5: MOV DL,BXINC BXMOV AH,2INT 21HLOOP AA5E: MOV AH,4CHINT 21HCODE ENDSEND START3. CRT.44 ASC30H39H,af AFASC61H66H 41H46H DATA SEGMENTMSG1 DB Hex:,$MSG2 DB 0DH,0AH,Binary:,$COUNT EQU 4BUF DB 4 DUP(?)DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX, DATAMOV DS, AXLEA DX, MSG1MO

4、V AH, 9INT 21HMOV CX, COUNTMOV SI, 0INPUT: -MOV AH, 1INT 21HMOV BUFSI, ALDEC CXINC SICMP CX, 0JNZ INPUTNEXT3: LEA DX, MSG2MOV AH, 9INT 21HMOV CX, COUNTMOV SI, 0NEXT2: MOV BL, BUFSICMP BL , 9JBE OK OK:SUB BL, 7 ;= 9 7OK: PUSH CXMOV CL ,4SHL BL, CL ; -4,44MOV CX, 4 ; 4-4NEXT1: MOV DL, 0SHL BL, 1JNC SK

5、IPINC DLSKIP: MOV AH, 2INT 21HLOOP NEXT1POP CX ;INC SILOOP NEXT2 ; 4-4,4EXIT: MOV AH, 4CHINT 21HCODE ENDSEND START4. STRING$NUMBCHARLCHAROTHERDATA SEGMENTSTRING DB abc123ABC,$N EQU $-STRINGNUM DB N DUP(?)BCHAR DB N DUP(?)LCHAR DB N DUP(?)OTHER DB N DUP(?)DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATAST

6、ART:MOV AX,DATAMOV DS,AXLEA BX,STRINGDEC BXLEA SP,BCHARLEA CX,LCHARLEA DX,OTHERLEA SI,NUMAA1:INC BXMOV AL,BX /$,CMP AL,$JZ AA5CMP AL,30H /JC AA4CMP AL,39HJA AA2MOV SI,ALINC SIJMP AA1AA2:CMP AL,41H /JC AA4CMP AL,5AHJA AA3MOV DI,SPMOV DI,ALINC SPJMP AA1AA3:CMP AL,61H /JC AA4CMP AL,7AHJA AA4MOV DI,CXMO

7、V DI,ALINC CXJMP AA1AA4:MOV DI,DX /MOV DI,ALINC DXJMP AA1AA5:MOV AH,4CH / DOS INT 21HCODE ENDSEND START5. BUF100CRTDATA SEGMENTBUF DB 100 DUP(?) ;DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART:MOV AX,DATAMOV DS,AXLEA BX,BUF ;BUFBXMOV CL,101 ;-MOV DL,126 ;DLMOV AH,0 ;LOOP1:DEC CL ;-1JZ TOEND ;ZF0MO

8、V AL,BX ;BXALINC BX ;BXSHR AL,1 ;AL-JC LOOP1 ;-SHL AL,1 ; -MOV AH,1 ; CMP AL,DL ;CHJGE LOOP1 ;ALDL -MOV DL,AL ;DLJMP LOOP1 ;CL0 -TOEND:CMP AH,1JC L ;DOSMOV BL,DLSHR DL,1SHR DL,1SHR DL,1SHR DL,1AND DL,0FHCMP DL,10JB L4ADD DL,7L4:ADD DL,30H ;asciiMOV AH,2INT 21HMOV DL,BLAND DL,0FHCMP DL,10JB L6ADD DL,

9、7L6:ADD DL,30H ;asciiMOV AH,2INT 21HMOV DL,H ;HMOV AH,2INT 21HL:MOV AH,4CH ;DOSINT 21HCODE ENDSEND START6. BUFA15BUFB20BUFABUFBBUFCDATA SEGMENTBUFA DB 41H,42H,43H,44H,45H,46H,47H,48H,49H,4AH,4BH,4CH,4DH,4EH,4FHBUFB DB 31H,32H,33H,41H,42H,43H,44H,45H,46H,47H,48H,49H,4AH,4BH,4CHDB 50H,51H,52H,53H,54HB

10、UFC DB 15 DUP (0)DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX,DATAMOV DS,AXLEA SI,BUFALEA BX,BUFCMOV CX,15 -AA1: MOV AH,20 -20MOV AL,SILEA DI,BUFBAA2: CMP AL,DI BUFA , BUFBJNZ AA3 AA3MOV BX,AL BUFCINC BXJMP AA4 -AA3: INC DIDEC AH -JNZ AA2 -AA4: INC SILOOP AA1 -MOV CX,15 BUFCLEA BX,BUFCBB

11、1: MOV DL,BXINC BXMOV AH,2INT 21HLOOP BB1MOV AH,4CHINT 21HCODE ENDSEND START7. ASCIICRTDATA SEGMENTBUF DB 200 DUPDATA ENDSCODE SEGMENTASSUME CSCODEDSDATASTART MOV AXDATAMOV DSAXMOV DI0MOV BXOFFSET BUFAA1 MOV AH1INT 21HCMP DI201JNC AA6 CMP AL0DHJZ AA6MOV BXALINC BXINC DIJMP AA1AA6 MOV DXDICMP DI,0JZ

12、AA7CMP DI,1JZ AA8DEC DX-1AA2 MOV BXOFFSET BUFMOV CXDIDEC CX-1AA3 MOV ALBXCMP ALBX+1JNC AA4XCHG ALBX+1MOV BXALAA4 INC BXLOOP AA3DEC DXJNZ AA2AA8 MOV BXOFFSET BUFMOV CXDI-AA5 MOV DLBXMOV AH2INT 21HINC BXLOOP AA5AA7 MOV AH4CHINT 21HCODE ENDSEND START8. BUFFER$PLUSDATA SEGMENTBUFFER DB 1,2,3,4,5,6,7,-8,

13、9,2,-1,-2,-3,-4,-5,-6,-7,-8,-9,1,$PLUS DB (?)DATA ENDSCODE SEGMENTASSUME CS: CODE,DS: DATASTART: MOV AX,DATAMOV DS,AXMOV DI,-1 -LEA BX,BUFFERLEA SI,PLUSL1: MOV AL,BXXOR AL,$ $JNZ L2 $JMP L4L2: MOV AL,BX ROL AL,1JNC L3 INC BXJMP L1L3: ROR AL,1 MOV SI,AL INC DIINC SIINC BXJMP L1L4: CMP DI,0JG L5 =2MOV

14、 AH,4CHINT 21H 01L5: LEA SI,PLUS MOV CX,DIL6: MOV AL,SICMP AL,SI+1JNC L7XCHG AL,SI+1MOV SI,ALL7: INC SILOOP L6DEC DIJNZ L5MOV AH,4CHINT 21HCODE ENDSEND START-DATA SEGMENTBUFFER DB 1,2,3,4,5,6,7,-8,9,2,-1,-2,-3,-4,-5,-6,-7,-8,-9,1,$PLUS DB (?)DATA ENDSCODE SEGMENTASSUME CS: CODE,DS: DATASTART: MOV AX

15、,DATAMOV DS,AXMOV DI,-1 -LEA SI,PLUSLEA BX,BUFFERL1: MOV AL,BXXOR AL,$ $JNZ L2JMP L3L2: INC DIINC BXJMP L1L3: LEA BX,BUFFER MOV CX,DIL4: MOV AL,BXCMP AL,BX+1JLE L5 XCHG AL,BX+1MOV BX,ALL5: INC BXLOOP L4MOV AL,BX -ROL AL,1JNC AA4 MOV AH,4CHINT 21HL6: MOV DL,BXMOV SI,DL INC SIDEC DIJNZ L3 -MOV AH,4CHI

16、NT 21HCODE ENDSEND START9. 20MPNCRTDATA SEGMENTORG 100HM DB 12,23,58,15,36,55,44,89,45,-23,-56,-47,-21,-65,32,69,82,58,29,-14 ;P DB 20 DUP(?) ;PN DB 20 DUP(?) ;NDATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX,DATAMOV DS,AXLEA SI,P ;PSILEA DI,N ;NDILEA BX,M ;MBXXOR AX,AX ;AX0XOR DX,DX ;DX0,D

17、L/DH/MOV CX,20 ;M20L1: MOV AL,BX ;TEST AL,80H ;AL,80HJZ L2 ;0,AL,L2MOV DI,AL ;AL,NINC BX ;BX+1,MINC DI ;NINC DH ;DH+1JMP L3 ;L2: MOV SI,AL ;AL,PINC BXINC SI ;PINC DL ;DL+1L3: LOOP L1 ;-MOV CX,2 ;-,L5: MOV BL,DL ;DL,DL4SHR DL,1SHR DL,1SHR DL,1SHR DL,1 ;-4,4CMP DL,10JB L4 ;DL=10,DL+7,9ASCII39H,AASCII4

18、1H,8L4: ADD DL,30HMOV AH,2 ;DL,/INT 21HMOV DL,BL ;BLDL,/AND DL,0FH ;DL40,DL4CMP DL,10JB L6ADD DL,7L6: ADD DL,30HMOV AH,2INT 21HMOV DL,0AH ;MOV AH,2INT 21HMOV DL,0DH ;MOV AH,2INT 21HMOV DL,DH ;DHDL,LOOP L5MOV AH,4CH ;DOSINT 21HCODE ENDSEND START10. NNASCII07CODE SEGMENTASSUME CS:CODESTART: MOV AH,1 ;

19、NINT 21HCMP AL,30HJC START ;0,CMP AL,3AHJNC START ;9,AND AL,0FHXOR CX,CX ;CX0MOV CL,AL ;-NMOV DL,07H ;ASCII07AA1:MOV AH,2INT 21HLOOP AA1 ;-MOV AH,4CHINT 21HCODE ENDSEND START11. STRINGSTRING+99CL0FFHCL0DATAS SEGMENTSTRING DB XYZIL12LWR; N EQU $-STRING;DATAS ENDS;CODES SEGMENTASSUME CS:CODES,DS:DATAS

20、START:MOV AX,DATASMOV DS,AXMOV CX,NLEA BX,STRINGAA1:MOV AL,BXCMP AL,30H;ASCII30H,JB AA2CMP AL,39H;ASCII39H,JA AA2JMP AA3;,AA2:INC BXLOOP AA1MOV CL,0JMP AA4AA3:MOV CL,0FFHAA4:MOV AH,4CHINT 21HCODES ENDSEND START12. ,DXASCII,ASCIIMEM4.,DX=2A49H,MEM439H34H41H32HDATA SEGMENTSOURCE DW 2A49HMEM DB 4 DUP(?

21、)DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATA;START:MOV AX,DATAMOV DS,AX;MOV DX,SOURCELEA BX,MEM;set the loopMOV CX,4;the loop bodyLB: MOV AX,DXAND AX,000FHCMP AL,10JC AD;ADD AL,7;AD: ADD AL,30HMOV BX,ALINC BX;SHR DX,1SHR DX,1SHR DX,1SHR DX,1LOOP LB;the loop end, return to dosMOV AH,4CHINT 21HCODE ENDSEND START13. 10110BCDAHALXOR DXDXMOV CX 10LOP1 MOV AH01HINT 21HMOV AHDHADD ALDLAAAMOV DXAXLOOP LOP1

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 网络科技 > 开发文档

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报