1、江苏大学 微机原理课程设计报告微机原理课程设计报告班级: 姓名: 学号:一、目的结合微机原理课程的学习,进一步巩固所学只是,掌握汇编语言的编程要领,熟悉汇编程序上机过程以及进行程序调试。二、设计任务,程序清单,流程图任务1(具体题目要求):字符串匹配设计 为掌握提示信息的设置方法及读取键入信息的方法。编写程序实现两个字符串比较。如相同,则显示:“MATCH”,否则,则显示“NO MATCH” 程序清单:DATA SEGMENT INPUT1 DB INPUT STRING1!,0DH,0AH,$ INPUT2 DB INPUT STRING2!,0DH,0AH,$ MAT DB 0DH,0AH
2、,MATCH!$ MISMAT DB 0DH,0AH,NO MATCH!$ LEN1 DB 20 STRING1 DB 20 DUP(?) LEN2 DB 20 STRING2 DB 20 DUP(?)DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATA,ES:DATAMAIN PROC FAR MOV AX,DATA MOV DS,AX MOV ES,AX MOV AH,09H MOV DX,OFFSET INPUT1 INT 21H MOV AL,LEN1 MOV BX,OFFSET STRING1 MOV BX,AL MOV AH,0AH MOV DX
3、,OFFSET STRING1 INT 21H CALL CRLF MOV AH,09H MOV DX,OFFSET INPUT2 INT 21H MOV AL,LEN2 MOV BX,OFFSET STRING2 MOV BX,AL MOV AH,0AH MOV DX,OFFSET STRING2 INT 21H CALL CRLF CLD LEA SI,STRING1 LEA DI,STRING2 MOV CX,5 REPE CMPSB JNE NOMAT MOV AH,9 MOV DX,OFFSET MAT INT 21H JMP EXITNOMAT:MOV AH,9 LEA DX,MI
4、SMAT INT 21HEXIT: MOV AH,4CH INT 21HCRLF PROC NEAR MOV DL,0DH MOV AH,2 INT 21H MOV DL,0AH MOV AH,2 INT 21HRETCRLF ENDP MAIN ENDPCODE ENDSEND MAIN流程图: .任务2(具体题目要求)将键盘输入的小写字母转换为大写字母的设计为了解小写字母和大写字母在计算机内的表示方法,并学习如何进行转换。编写程序,接收键盘字符,并将其中的小写字母转变为大写字母,然后显示在屏幕上。程序清单:CRLF MACRO MOV DL,0DH MOV AH,02H INT 21H M
5、OV AH,02H MOV DL,0AH INT 21HENDMDATA SEGMENTINPUT1 DB 100 DB 0 DB 100 DUP($)MES1 DB Please Input a String:,0DH,0AH,$MES2 DB The Output Is:,0DH,0AH,$DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AXTISHI: MOV AH,09H MOV DX,OFFSET MES1 INT 21H INPUT: MOV DX,OFFSET INPUT1 MOV AH,
6、0AH INT 21H CRLF MOV CX,00H MOV CL,INPUT1+1 LEA SI,INPUT1+2 NEXT: CMP BYTE PTR SI,a JB CONT CMP BYTE PTR SI,z JA CONT SUB BYTE PTR SI,20HCONT: INC SI LOOP NEXTTISHI1:MOV AH,09H MOV DX,OFFSET MES2 INT 21H OUTPUT:LEA DX,INPUT1+2 MOV AH,09H INT 21HEXIT: MOV AH,4CH INT 21HCODE ENDS END START流程图:任务3(具体题目
7、要求)键盘输入数据并显示的设计为掌握接收键盘数据的方法,并了解将键盘数据显示时须转换为ASCII码的原理。编写程序,将键盘接收到的四位十六进制数据转换为等值的二进制数,再显示在终端上。程序清单: CRLF MACRO MOV AH,02H MOV DL,0DH INT 21H MOV AH,02H MOV DL,0AH INT 21HENDMDATA SEGMENT MES1 DB Please Input The number:$ MES2 DB The Result Are:$DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATAMAIN PROC FAR
8、START:MOV AX,DATA MOV DS,AXTISHI: MOV DX, OFFSET MES1 MOV AH,09H INT 21H CRLF MOV BX,0 MOV CX,4INPUT: mov Ah,07H INT 21H CMP AL,48 JB INPUT CMP AL,57 JNA TRANS CMP AL,97 JB INPUT CMP AL,102 jA INPUT JMP ENGTRANS : MOV DL,AL MOV AH,02H INT 21H SUB AL,30H JMP FBIENG: MOV DL,AL MOV AH,02H INT 21H SUB A
9、L,57H FBI: CBW XCHG AX,BX MOV DX,16 MUL DX XCHG AX,BX ADD BX,AX LOOP INPUT CRLFDISP: LEA DX,MES2 MOV AH,09H INT 21H CRLF MOV CX,16BINARY :TEST BX,8000H JNZ XONE MOV DL,0 MOV AH,02H INT 21H JMP NEXTXONE: MOV DL,l MOV AH,02H INT 21HNEXT: SHL BX,1 LOOP BINARY CRLFEXIT: MOV AH,4CH INT 21H MAIN ENDPCODE
10、ENDS END START流程图:任务4(具体题目要求)为掌握字符和数据的显示方法。编写程序,先显示信息:INPUT STRING,THE END FLAG IS $,再接收字符。如为0-9,则计数器加1,并显示数据;如为非数字,则直接显示,但不计数。程序清单:CRLF MACRO MOV AH,02H MOV DL,0DH INT 21H MOV AH,02H MOV DL,0AH INT 21HENDMDATA SEGMENT MES DB INPUT STRING,THE END FLAG IS$! MES1 DB The Data Nunmber Count Is:$ NUM DB
11、0 DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AXTISHI: LEA DX,MES MOV AH,09H INT 21H CRLFINPUT: MOV Ah,01H INT 21H CMP AL,$ JZ DISP CMP AL,48 JB NEXT CMP AL,57 JA NEXT INC NUMNEXT: JMP INPUTDISP: CRLFTISHI1: LEA DX,MES1 MOV AH,09H INT 21H CRLF MOV AL,NUM MOV BL,AL MOV CL,4
12、ROL AL,CL AND AL,0FH ADD AL,30H CMP AL,39H JBE K1 ADD AL,7K1: MOV DL,AL MOV AH,02H INT 21H AND BL,0FH ADD BL,30H CMP BL,39H JBE K2 ADD BL,7K2: MOV DL,BL MOV AH,02H INT 21H MOV DL,H MOV AH,02H INT 21H CRLFEXIT: MOV AH,4CH INT 21HCODE ENDS END START流程图: 任务5(具体题目要求)为掌握字符和数据的显示方法。编写程序,先显示信息:INPUT STRING
13、,THE END FLAG IS$,再接收字符。如为0-9,则计数器加一,并显示数据;如为非数字,则直接显示,但不计数。程序清单:CRLF MACRO MOV DL,0DH MOV AH,02H INT 21H MOV AH,02H MOV DL,0AH INT 21HENDMDATA SEGMENT MES DB Please Input A Number,Press C To Exit:,$ MES1 DB The Input Is Not A Number,Please Input Again:,$DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATAS
14、TART: MOV AX,DATA MOV DS,AX MOV DX, OFFSET MES MOV AH,09H INT 21H CRLFL3: MOV AH,01H INT 21H CMP AL,C JE EXIT CMP AL,30H JB L2 CMP AL,39H JA L2 AND AL,0FH CMP AL,0 JE EXIT MOV BL,ALL1: MOV DL,07H MOV AH,02H INT 21H CALL DELAY DEC BL JNZ L1 JMP L3 CRLFEXIT: MOV AH,4CH INT 21HL2: CRLF MOV DX, OFFSET MES1 MOV AH,09H INT 21H JMP L3DELAY PROC NEAR MOV DX ,02FFFHK2: MOV AX,0FFFFHK1: DEC AX NOP JNZ K1 DEC dx JNZ K2 RET DELAY ENDPCODE ENDS END START流程图:三、小结
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1