汇编实验集锦(共18页).doc

上传人:飞****2 文档编号:15109565 上传时间:2022-05-11 格式:DOC 页数:18 大小:57.50KB
返回 下载 相关 举报
汇编实验集锦(共18页).doc_第1页
第1页 / 共18页
汇编实验集锦(共18页).doc_第2页
第2页 / 共18页
点击查看更多>>
资源描述

《汇编实验集锦(共18页).doc》由会员分享,可在线阅读,更多相关《汇编实验集锦(共18页).doc(18页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、精选优质文档-倾情为你奉上1-1.将存放在数据段中的变量VAR1中的三个数,传送到该段中的变量VAR2中。DATA SEGMENT VAR1 DW 35,24,0451H VAR2 DW 3DUP(?)DATA ENDSCODE SEGMENT ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX LEA SI,VAR1 LEA DI,VAR2 MOV AX,SI MOV DI,AX ADD SI,2 ADD DI,2 MOV AX,SI MOV DI,AX ADD SI,2 ADD DI,2 MOV AX,SI MOV DI,AX MOV A

2、H,4CH INT 21HCODE ENDS END START1-2.将存放在数据段STR1的字符串“ABCDEF”传送到该段的STR2储存区中,DATA SEGMENT STR1 DB “ABCDEF” STR2 DB 6 DUP(?)DATA ENDSCODE SEGMENT ASSUME DS:DATA,CS:CODE START: MOV AX,DATA MOV DS,AX LEA SI, STR1 LEA DI, STR2 REST: MOV AL,SIMOV DI,ALINC SIINC DIDEC CXJNZ RESTMOV AH,4CH INT 21H CODE ENDS E

3、ND START2-1.从键盘输入一个数字就会自动输出两个相同的数字。DSEG SEGMENT STRBUF DB 10 DUP(?)DSEG ENDSCSEG SEGMENT ASSUME CS:CSEG,DS:DSEGSTART:MOV AX,DSEG MOV DS,AX MOV CX,10 MOV DI,0REST:MOV AH,01H INT 21H MOV STRBUFDI,AL MOV DL,AL MOV AH,02H INT 21H INC DI LOOP REST MOV AH,4CH INT 21HCSEG ENDS END START2-2.程序示例:从键盘输入10个数字,

4、并且存入STRBUF缓冲区中,并将这十个字符显示。DSEG SEGMENT STRBUF DB 10DUP(?)DSEG ENDSCSEG SEGMENT ASSUME CS:CSEG,DS:DSEGSTART: MOV AX,DSEG MOV DS,AX MOV CX,10 MOV DI,0RSET: MOV AH,01H INT 21H MOV STRBUFDI,AL MOV DL,AL MOV AH,02H INT 21H INC DI LOOP REST MOV AH,4CH INT 21HCSEG ENDS END START3-1.将实验一中的寄存器间接寻址改为寄存器直接寻址。并将

5、实验二中的寄存器相对寻址改为基址变址寻址。实验一:DATA SEGMENT VAR1 DW 35,24,0451H VAR2 DW 3 DUP(?)DATA ENDSCODE SEGMENT ASSUME DS:DATA,CS:CODESTART:MOV AX,DATA MOV DS,AX MOV DI,0 MOV AX,VAR1DI MOV SI,0 MOV VAR2SI,AX ADD SI,2 ADD DI,2 MOV AX,SI MOV DI,AX ADD SI,2 ADD DI,2 MOV AX,SI MOV DI,AX MOV AH,4CH INT 21HCODE ENDS END

6、START实验二:DSEG SEGMENT STRBUF DB 10 DUP(?)DSEG ENDSCSEG SEGMENT ASSUME CS:CSEG,DS:DSEGSTART:MOV AX,DSEG MOV DS,AX MOV CX,10 MOV DI,0REST:MOV AH,01H INT 21H LEA BX,STRBUF MOV SI,DI MOV BXSI,AL MOV DL,AL MOV AH,02H INT 21H INC DI LOOP REST MOV AH,4CH INT 21HCSEG ENDS END START3-2.完成将一个一位十进制数转换成ASC码存入单元

7、ASC中。DATA SEGMENT TAB DB 40H,79H,24H,30H,19H DB 12H,02H,78H,00H,18H DEN DB 6 NUM DB ?DATA ENDSCODE SEGMENT ASSUME DS:DATA,CS:CODESTART:MOV AX,DATA MOV DS,AX LEA BX,TAB MOV AL,DEN XLAT MOV NUM,AL MOV AH,4CH INT 21HCODE ENDS END START4-1.计算(X+(Y*Z-100)/W其中:X,Y,Z,W均为十六位有符号数,其储存形式如下, X DW -13Y DW 30Z DW

8、 24W DW 50DSEG SEGMENTX DW -13Y DW 30Z DW 24W DW 50 。DSEG ENDSCSEG SEGMENT ASSUME CS:CSEG,DS:DSEGSTART:MOV AX,Y IMUL Z MOV CX,AX MOV BX,DX MOV AX,X CWD ADD CX,AX ADC BX,DX SUB CX,100 CWD SUB AX,CX SBB DX,BX IDIV WCSEG ENDS END START4-2.设X,Y,Z均为双精度数,它们分别存在X,X+2,Y,Y+2,Z,Z+2储存单元中,存放时高位字存放在高地址,低位字存放在低地址

9、,编写程序实现下面表达式的计算:X+(Y-Z)=WDSEG SEGMENTX DW -13,-13Y DW 30,30Z DW 24,24W DW 50,50DSEG ENDSCSEG SEGMENT ASSUME CS:CSEG,DS:DSEGSTART:MOV AX,X MOV DX,X+2 ADD AX,Y ADC DX,Y+2 SUB AX,Z SBB DX,Z+2 MOV W,AX MOV W+2,DX CSEG ENDS END START5-1.、编写完整程序,从键盘输入一个字符串STRING,同时,把字符串 STRING中的&字符用空格符替代.EXDATA SEGMENT ST

10、RING DB 8 DUP(?) ADDR DW ? DC DB ?,?EXDATA ENDSCODE SEGMENT ASSUME ES:EXDATA,CS:CODESTART:MOV AX,EXDATA MOV ES,AX MOV CX,8 MOV DI,0AGAIN:MOV AH,01H INT 21H MOV STRINGDI,AL INC DI LOOP AGAIN LEA DI,STRING MOV CX,8 CLD MOV AL,& REPNZ SCASB MOV AL, XCHG AL,STRINGDI-1 MOV SI,0 MOV BX,8 SUB BX,CX MOV ADD

11、R,BX MOV CX,8REST: MOV AH,02H MOV AL,STRINGSI MOV DL,AL INT 21H INC SI LOOP REST ADD BX,30H AND BX,00FFH MOV DL,BX MOV AH,02H INT 21H MOV AH,4CH INT 21HCODE ENDSEND START5-2.编写完整程序,从键盘输入两串字符OLDS和NEWS,如果两个字符串相同显示“YES”串,不同显示“NO”串。DATA SEGMENT OLDS DB 8 DUP(?) NEWS DB 8 DUP(?)DATA ENDSCODE SEGMENT ASSU

12、ME DS:DATA,CS:CODESTART:MOV AX,DATA MOV DS,AX MOV CX,10H CLD MOV DI,0REST1: MOV AX,01H INT 21H MOV OLDSDI,AL INC DI LOOP REST1 MOV DI,0 MOV CX,10REST2: MOV AX,01H INT 21H MOV NEWSDI,AL INC DI LOOP REST2 MOV CX,8 LEA SI,WORD PTR OLDS LEA DI,WORD PTR NEWS CLD REPZ CMPSB JNZ BUTONG MOV SI,0 CLD MOV CX,

13、8AGAIN1: MOV AH,02H MOV DL,OLDSSI INT 21H INC SI LOOP AGAIN1 JMP EDBUTONG: MOV SI,0 CLD MOV CX,8AGAIN2: MOV AH,02H MOV DL,NEWSSI INT 21H INC SI LOOP AGAIN2ED: MOV AH,4CH INT 21HCODE ENDSEND START6-1. 数组ARRAY存放着10个字数据,求数组的最大数和最小数,并分别存放在变量MAX和MIN中。DATA SEGMENT ARRAY DB 1,2,13,14,5,6,7,8,11,10 MAX DB ?

14、 MIN DB ?DATA ENDSCODE SEGMENT ASSUME DS:DATA,CS:CODESTART: MOV AX,DATA MOV DS,AX MOV DI,1 MOV AL,ARRAY MOV AH,ARRAYDI MOV CX,9 CMP AL,AH JAE DAXIAO: MOV MIN,AL MOV BL,MIN MOV MAX,AH MOV BH,MAX JMP GOONDA: MOV MAX,AL MOV AH,MAX MOV MIN,AH MOV BL,MINGOON: INC DI MOV DL,ARRAYDI CMP DL,MAX JAE BIG CMP

15、DL,MIN JBE LITTLE LOOP GOON JMP TBIG: MOV MAX,DL MOV BH,MAX LOOP GOONLITTLE: MOV MIN,DL MOV BL,DL LOOP GOONT: MOV AH,4CH INT 21HCODE ENDS END START7-1. 数组ARRAY有10个带符号数,数的类型是字,编写程序,将数组按升序进行排列,并显示排序结果。DATA SEGMENTNUM DW 1,2,-3,4,-5,6,7,8,9,0DATA ENDSCODE SEGMENTASSUME DS:DATA,CS:CODESTART:MOV AX,DATAM

16、OV DS,AXMOV CX,9AGAIN:MOV SI,0MOV DI,CXAGAIN1:MOV AX,NUMSICMP AX,NUMSI+2JLE CONTINUEXCHG AX,NUMSI+2MOV NUMSI,AXCONTINUE:ADD SI,2LOOP AGAIN1MOV CX,DILOOP AGAINMOV AH,4CHINT 21HCODE ENDSEND START8-1统计学生成绩,设有20个学生成绩,是编写程序分别统计。 DATA SEGMENT WE DB 45,65,67,85,84,93,49,96,100,74 DB 75,85,82,58,90,100,75,8

17、5,90,91 C0 DB 0 C1 DB 0 C2 DB 0 C3 DB 0 C4 DB 0 C5 DB 0DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AX MOV SI,0 MOV CX,20AS: MOV AL,WESI CMP AL,60 JB S1 CMP AL,70 JB S2 CMP AL,80 JB S3 CMP AL,90 JB S4 CMP AL,100 JB S5 INC C0 JMP EXITS1: INC C1 JMP EXITS2: INC C2 JMP EXITS3:

18、INC C3 JMP EXITS4: INC C4 JMP EXITS5: INC C5 JMP EXITEXIT: INC SI LOOP AS MOV AH,4CH INT 21H CODE ENDS END START8-2显示月份,要求根据用户键入的月份数终端上显示该月的英文缩写。DATA SEGMENT JAN DB JAN$ FEB DB FEB$ MAR DB MAR$ APR DB APR$ MAY DB MAY$ JUN DB JUN$ JUL DB JUL$ AUG DB AUG$ SEP DB SEP$ OCT DB OCT$ NOV DB NOV$ DEC1 DB DE

19、C$ DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AX MOV CX,5A: MOV AH,01H INT 21H SUB AL,30H CMP AL,1 JZ S1 CMP AL,2 JZ S2 CMP AL,3 JZ S3 CMP AL,4 JZ S4 CMP AL,5 JZ S5 CMP AL,6 JZ P6 CMP AL,7 JZ P5 CMP AL,8 JZ P2 CMP AL,9 JZ P1 MOV BX,10 MOV AX,0B: PUSH AX CMP AL,0DH JZ EXIT

20、SUB AL,30H MOV CL,AL MOV CH,0 POP AX MUL BX ADD AX,CX JMP B CMP AL,10 JZ P7 CMP AL,11 JZ P4 CMP AL,12 JZ P3P1: JMP S9P2: JMP S8P4: JMP S11P5: JMP S7P6: JMP S6P7: JMP S10P3: JMP S12EXIT: POP AX MOV AH ,4CH INT 21H LOOP B S1: LEA DX,JAN MOV AH,9 INT 21H JMP OVERS2: LEA DX,FEB MOV AH,9 INT 21H JMP OVER

21、S3: LEA DX,MAR MOV AH,9 INT 21H JMP OVER S4: LEA DX,APR MOV AH,9 INT 21H JMP OVER S5: LEA DX,MAY MOV AH,9 INT 21H JMP OVER S6: LEA DX,JUN MOV AH,9 INT 21H JMP OVER S7: LEA DX,JUL MOV AH,9 INT 21H JMP OVER S8: LEA DX,AUG MOV AH,9 INT 21H JMP OVER S9: LEA DX,SEP MOV AH,9 INT 21H JMP OVERS10: LEA DX,OC

22、T MOV AH,9 INT 21H JMP OVER S11: LEA DX,NOV MOV AH,9 INT 21H JMP OVERS12: LEA DX,DEC1 MOV AH,9 INT 21H JMP OVER OVER: MOV AH,4CH INT 21H CODE ENDS END START9-1从键盘输入10个十进制数,存入BUFFER缓冲区中,计算10个数的和,并用十进制数显示和。 DATA SEGMENTBUFFER DW 10 DUP(?)MEMORY DB 5 DUP(?)SUM DW ?DATA ENDSCODE SEGMENTASSUME CS:CODE,DS

23、:DATASTART: MOV AX,DATAMOV DS,AXMOV CX,10MOV DI,OFFSET BUFFERMOV SI,OFFSET MEMORYMOV BL,0INNUM:MOV AH,01HINT 21HCMP AL,0DHJZ TENTOTWOMOV SI,ALINC SIINC BLJMP INNUMTENTOTWO:MOV SI,OFFSET MEMORYCALL FAR PTR DTOBINMOV DI,AXADD DI,2CALL FAR PTR NEWLINEMOV BL,0MOV SI,OFFSET MEMORYLOOP INNUMMOV DI,OFFSET

24、BUFFERMOV CX,10MOV AX,0JIAHE:ADD AX,DIADD DI,2LOOP JIAHEMOV SUM,AXMOV SI,OFFSET MEMORYMOV AX,SUMCALL FAR PTR BTODEXIT:MOV AH,4CHINT 21HCODE ENDSCODE2 SEGMENTASSUME CS:CODE2NEWLINE PROC FARPUSH AXPUSH DXMOV DL,0DHMOV AH,2INT 21HMOV DL,0AHMOV AH,2INT 21HPOP DXPOP AXRETNEWLINE ENDPDTOBIN PROC FARPUSH C

25、XXOR AX,AXMOV CL,BLXOR CH,CHREST:MOV BX,10MUL BXMOV DL,SIINC SIAND DL,0FHXOR DH,DHADD AX,DXLOOP RESTPOP CXRETDTOBIN ENDPBTOD PROC FARXOR DX,DXMOV CX,0NEXT:MOV BX,10DIV BXMOV SI,DLINC SIINC CXCMP AX,0JZ OKXOR DX,DXJMP NEXTOK:MOV SI,OFFSET MEMORYADD SI,CXSUB SI,1PRINT:MOV DL,SIADD DL,30HMOV AH,2INT 21

26、HSUB SI,1LOOP PRINTRETBTOD ENDPCODE2 ENDSEND START10-1编写一个子程序嵌套结构的程序模块,分别从键盘输入姓名及8个字符的电话号码,并以一定的格式显示出来。 data segmentinbuf db 11,?,11 dup(?)outname db 11 dup(0d),$outnum db 8 dup(0d),$tablehead db name tel.,0dh,0ah,$tishi1 db input name$tishi2 db input num$data endscode segmentassume cs:code,ds:data,

27、es:datastart:mov ax,datamov ds,axmov es,axlea dx,tishi1mov ah,9int 21h;输出提示call inputnamelea dx,tishi2mov ah,9int 21h;输出提示call inpone;显示提示信息input a telephone nmber:call printlinemov ah,4chint 21h;输入姓名inputname proc nearlea dx,inbuf;输入姓名mov ah,10int 21hmov cl,inbuf+1mov ch,0lea si,inbuf+2;将输入的名字存入nam

28、elea di,outnamecldrep movsbretinputname endp;输入电话号码就inpone proc nearlea dx,inbuf;输入号码mov ah,10int 21hlea si,inbuf+2;将输入的名字存入namelea di,outnummov cx,8cldrep movsb;将inbuf中的字符串复制到outnumberretinpone endp;输出姓名和电话号码printline proc nearlea dx,tableheadmov ah,9int 21hlea dx,outnamemov ah,9int 21hlea dx,outnummov ah,9int 21hretprintline endpcode endsend start专心-专注-专业

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁