《微型计算机原理实验(共11页).doc》由会员分享,可在线阅读,更多相关《微型计算机原理实验(共11页).doc(11页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上实验一:输出字符A的源程序如下:PROG SEGMENTASSUME CS:PROGSTART: MOV DL,A MOV AH , 2 INT 21H MOV AH , 4CH INT 21H PROG ENDS END START实验二:1.把BX中的二进制数转换成十进制数,在屏幕上显示出来,只考虑无符号数。程序如下: CODE SEGMENT ASSUME CS:CODE START: MOV BX,0FFFH MOV CX,10000 CALL DEC_DIV MOV CX, 1000 CALL DEC_DIV MOV CX,100 CALL DEC_DIV
2、MOV CX,10 CALL DEC_DIV MOV CX,1 CALL DEC_DIV MOV AH,4CH INT 21H DEC_DIV PROC NEAR MOV AX,BX MOV DX,0 DIV CX MOV BX,DX MOV DL,AL ADD DL,30H MOV AH,2 INT 21H RET DEC_DIV ENDP CODE ENDS END START2.把BX中的带符号数转换成十进制数,在屏幕上显示出来。程序如下: CODE SEGMENT ASSUME CS:CODE START: MOV BX,8001H MOV AX,8000H AND AX,BX JNZ
3、 MINUS JMP DISP MINUS: MOV DL,- MOV AH,2 INT 21H NEG BX JMP DISP DISP: MOV CX,10000 CALL DEC_DIV MOV CX, 1000 CALL DEC_DIV MOV CX,100 CALL DEC_DIV MOV CX,10 CALL DEC_DIV MOV CX,1 CALL DEC_DIV MOV AH,4CH INT 21H DEC_DIV PROC NEAR MOV AX,BX MOV DX,0 DIV CX MOV BX,DX MOV DL,AL ADD DL,30H MOV AH,2 INT 2
4、1H RET DEC_DIV ENDP CODE ENDS END START3.求一个数据块(由10个单字节的无符号数组成)中的最大元素,并将结果在屏幕上显示出来,程序如下: DATA SEGMENT BLOCK DB 1,0,5,7,10,30,100,127,90,80 RESULT DB ? DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA BEGIN PROC FAR MOV AX,DATA MOV DS,AX MOV CX,9 LEA SI,BLOCK MOV AL,SI X1: INC SI CMP AL,SI JAE X2 MOV AL
5、,SI X2: LOOP X1 MOV RESULT,AL MOV AH ,0 MOV BX,AX CALL XIANSHI MOV AH,4CH INT 21H BEGIN ENDP XIANSHI PROC NEAR MOV AL,80H AND AL,BL JNZ MINUS JMP DISP MINUS: MOV DL,- MOV AH,2 INT 21H NEG BL JMP DISP DISP: MOV CX,100 CALL DEC_DIV MOV CX,10 CALL DEC_DIV MOV CX,1 CALL DEC_DIV MOV AH,4CH INT 21H XIANSH
6、I ENDP DEC_DIV PROC NEAR MOV AX,BX MOV DL,0 DIV CL MOV BL,AH MOV BH,0 MOV DL,AL ADD DL,30H MOV AH,2 INT 21H RET DEC_DIV ENDP CODE ENDS END BEGIN4.求一个数据块(由20个单字节的带符号数组成)中的正数和(字)和负数和(字),并在屏幕上用十进制的形式显示出两个和。程序如下: DATA SEGMENT BLOCK DW -100,100,200,-200,5,6,7,8,9,10 DW 11,12,13,14,15,50,-50,150,-150,-200
7、 POSIT DW ? NEGAT DW ? ST1 DB The sum of all the positive numbers:$ ST2 DB The sum of the negative numbers:$ DATA ENDS CODE SEGMENT ASSUME CS:CODE ,DS:DATA START PROC MOV AX,DATA MOV DS,AX MOV BX,OFFSET BLOCK MOV SI,0 MOV DI,0 MOV CX,20 X1: MOV AX,BX CMP AX,0 JGE X3 ADD DI,AX JMP X2 X3: ADD SI,AX X2
8、: ADD BX,2 LOOP X1 MOV POSIT,SI MOV NEGAT,DI MOV BX,SI MOV DX,OFFSET ST1 MOV AH,9 INT 21H CALL XIANSHI MOV DL,0DH MOV AH,2 INT 21H MOV DL,0AH MOV AH,2 INT 21H MOV BX,NEGAT NEG BX AND BX,7FFFH MOV DX,OFFSET ST2 MOV AH,9 INT 21H MOV DL,- MOV AH,2 INT 21H CALL XIANSHI MOV AH,4CH INT 21H START ENDP XIAN
9、SHI PROC NEAR MOV CX,100 CALL DEC_DIV MOV CX,10 CALL DEC_DIV MOV CX,1 CALL DEC_DIV RET XIANSHI ENDP DEC_DIV PROC NEAR MOV AX,BX MOV DX,0 DIV CX MOV BX,DX MOV DL,AL ADD DL,30H MOV AH,2 INT 21H RET DEC_DIV ENDP CODE ENDS END START5.将寄存器BX中的二进制数转换成十六进制数并在屏幕上显示出来。程序如下: CODE SEGMENT ASSUME CS:CODE BINHEX
10、 PROC FAR MOV CH,4 MOV BX,1000 ROTATE: MOV CL,4 ROL BX,CL MOV DL,BL AND DL,0FH ADD DL,30H CMP DL,3AH JL OUTPUT ADD DL,7 OUTPUT: MOV AH,2 INT 21H DEC CH JNE ROTATE MOV DL,H MOV AH,2 INT 21H MOV AH,4CH INT 21H BINHEX ENDP CODE ENDS END BINHEX专心-专注-专业实验三:1.从键盘上输入一个十进制数(065535),转换成二进制数并放入寄存器BX中,其程序框图如下:
11、程序如下: CODE SEGMENT ASSUME CS:CODE START PROC CALL DECBIN CALL XIANSHI MOV AH,4CH INT 21H START ENDP DECBIN PROC NEAR MOV CX,10 MOV BX,0 LOP1: MOV AH,1 INT 21H CMP AL,30H JL EXIT CMP AL,39H JG EXIT SUB AL,30H MOV AH,00H XCHG AX,BX MUL CX ADD BX,AX JMP LOP1 EXIT: RET DECBIN ENDP XIANSHI PROC NEAR LP1:
12、 MOV CX,10000 CALL DEC_DIV MOV CX,1000 CALL DEC_DIV MOV CX,100 CALL DEC_DIV MOV CX,10 CALL DEC_DIV MOV CX,1 CALL DEC_DIV RET XIANSHI ENDP DEC_DIV PROC NEAR MOV AX,BX MOV DX,0 DIV CX MOV BX,DX MOV DL,AL ADD DL,30H MOV AH,2 INT 21H RET DEC_DIV ENDP CODE ENDS END START2.从键盘上输入065535范围的一个十进制数,在屏幕上显示出相应的
13、十六进制数。程序如下: CODE SEGMENT ASSUME CS:CODE START PROC CALL DECBIN MOV CH,4 CALL ROTATE MOV AH,4CH INT 21H START ENDP DECBIN PROC NEAR MOV CX,10 MOV BX,0 LOP1: MOV AH,1 INT 21H CMP AL,30H JL EXIT CMP AL,39H JG EXIT SUB AL,30H MOV AH,00H XCHG AX,BX MUL CX ADD BX,AX JMP LOP1 EXIT: RET DECBIN ENDP ROTATE P
14、ROC LOP2: MOV CL,4 ROL BX,CL MOV DL,BL AND DL,0FH ADD DL,30H CMP DL,3AH JL OUTPUT ADD DL,7 OUTPUT: MOV AH,2 INT 21H DEC CH JNE LOP2 MOV DL,H MOV AH,2 INT 21H MOV AH,4CH INT 21H ROTATE ENDP CODE ENDS END START实验四:1.在内存中存有一字符串,以0为结尾,程序开始输出HELLO然后等待从键盘输入一字符,再改字符串中寻找该字符,若找到,输出yes;若找不到,输出no,然后再输入下一字符。程序如
15、下: DATA SEGMENT STR1 DB HELLO,0DH,0AH,$ STR2 DB 20H,YES,0DH,0AH,$ STR3 DB 20H,NO,0DH,0AH,$ STR4 DB 1 2 3 0 4 5 A B a=! ?,00H DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START PROC FAR MOV AX,DATA MOV DS,AX MOV DX,OFFSET STR1 MOV AH,9 INT 21H LOOP1: MOV AH,1 INT 21H MOV BX,OFFSET STR4 GON: MOV AH,B
16、X CMP AH,0 JZ NO INC BX CMP AH,AL JNZ GON MOV DX,OFFSET STR2 GO: MOV AH,9 INT 21H JMP LOOP1 NO: MOV DX,OFFSET STR3 JMP GO START ENDP CODE ENDS END START2.实验内容1的程序是个无限循环程序,若按ESC键,让程序退出循环,是系统返回DOS。已知ESC键的键值是1BH,按照上面要求对实验内容1的程序进行修改,然后重新汇编、链接和运行。程序如下: DATA SEGMENT STR1 DB HELLO,0DH,0AH,$ STR2 DB 20H,YES
17、,0DH,0AH,$ STR3 DB 20H,NO,0DH,0AH,$ STR4 DB 1 2 3 0 4 5 A B a=! ?,00H DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START PROC FAR MOV AX,DATA MOV DS,AX MOV DX,OFFSET STR1 MOV AH,9 INT 21H LOOP1: MOV AH,1 INT 21H MOV BX,OFFSET STR4 GON: MOV AH,BX CMP AH,0 JZ NO INC BX CMP AH,AL JNZ GON MOV DX,OFFSET STR2 GO: MOV AH,9 INT 21H JMP LOOP1 NO: MOV DX,OFFSET STR3 JMP GO START ENDP CODE ENDS END START