1、1微机实验报告实验 2.1 汇编语言程序的调试与运行思考题: 1、带进位加法程序:DISP MACRO XMOV DL,XMOV AH,02HINT 21HENDMDATA SEGMENTDATA1 DB65087DATA2 DB75087N EQU $-DATA2DATA ENDSSTACK SEGMENT STACKSTA DB 20 DUP (?)TOP EQU $-STASTACK ENDSCODE SEGMENTASSUME CS:CODE,DS:DATA,SS:STACK,ES:DATASTART:MOV AX,DATAMOV DS,AXMOV AX,STACKMOV SS,AXM
2、OV AX,TOPMOV SP,AXLEA SI,DATA1MOV BX,0MOV CX,NCALL DISPLDISP +LEA SI,DATA2MOV BX,0MOV CX,NCALL DISPLDISP =2LEA DI,DATA1MOV CX,NCALL ADDALEA SI,DATA1MOV BX,0MOV CX,NCMP DL,0JZ NEXTDISP 1NEXT: CALL DISPLDISP 0DHDISP 0AHMOV AX,4C00HINT 21HDISPL PROCDS1:MOV AH,02HMOV DL,SI+BXINT 21HINC BXLOOP DS1RETDISP
3、L ENDPADDA PROCPUSH CXMOV BX,0AD1:SUB BYTE PTR SI+BX,30HSUB BYTE PTR DI+BX,30HINC BXLOOP AD1POP CXPUSH CXMOV BX,N-1CLCAD2:MOV AL,SI+BXADC AL,DI+BXAAAMOV DI+BX,ALDEC BXLOOP AD2POP CXPUSH CXMOV BX,0MOV DL,0JNC AD33MOV DL,1AD3:ADD BYTE PTR DI+BX,30HINC BXLOOP AD3POP CXRETADDA ENDPCODE ENDSEND START结果截图
4、:2、上机步骤,调试方法:1、写代码完成功能要求,文件格式为.asm 文件(如 21si.asm) ,将文件放入带汇编工具的文件夹中,即含有汇编工具(MASM.EXE)和链接工具(LINK.EXE)的文件夹。2、将文件用 TC.EXE 打开,保存,在 File 中选择 Os shell,启动命令行,进入上述文件夹,输入 masm 21si 回车后编译产生 21si.obj 文件,再输入 link 21si 回车后链接产生 21si.exe 文件,最后输入 21si,回车后运行即可4实验 2.2 分支程序设计思考题1、计算百分比程序:DISP MACRO XMOV DL,XMOV AH,02HI
5、NT 21HENDMDISP1 MACROADD AL,30HDISP ALDISP 0DISP %MOV DL,0DHMOV AH,02HINT 21HMOV DL,0AHMOV AH,02HINT 21HENDM DATA SEGMENTGRADE DW 95H,60H,75H,92H,71H,86H,54H,89H,83H,76HN EQU ($-GRADE)/2ORG 30HS5 DW 0S6 DW 0S7 DW 0S8 DW 0S9 DW 0S10 DW 0DATA ENDSSTACK SEGMENT STACKSTA DB 20 DUP (0)TOP EQU $-STASTACK
6、ENDSCODE SEGMENTMAIN PROC FARASSUME CS:CODE,DS:DATA,SS:STACKSTART: PUSH DSSUB AX,AXPUSH AX5MOV AX,DATAMOV DS,AXMOV CX,NLEA BX,GRADECOMPARE:MOV AX,BXCMP AX,60HJL FIVECMP AX,70HJL SIXCMP AX,80HJL SEVENCMP AX,90HJL EIGHTCMP AX,100HJNE NINEINC S10JMP CHANINE: INC S9JMP CHAEIGHT: INC S8JMP CHASEVEN: INC
7、S7JMP CHASIX: INC S6JMP CHAFIVE: INC S5JMP CHACHA: ADD BX,2LOOP COMPAREDISP AMOV AX,S10DISP1DISP BMOV AX,S9DISP1DISP CMOV AX,S8DISP1DISP DMOV AX,S7DISP1DISP EMOV AX,S6DISP16DISP FMOV AX,S5DISP1RETMAIN ENDPCODE ENDSEND START截图:2、计算平均成绩程序:DATA SEGMENTGRADE DW 95H,60H,75H,92H,71H,86H,54H,89H,83H,76HN E
8、QU ($-GRADE)/2ORG 30HS5 DW 0S6 DW 0S7 DW 0S8 DW 0S9 DW 0S10 DW 0DATA ENDSSTACK SEGMENT STACKSTA DB 20 DUP (0)TOP EQU $-STASTACK ENDSCODE SEGMENTMAIN PROC FARASSUME CS:CODE,DS:DATA,SS:STACKSTART: PUSH DS7SUB AX,AXPUSH AXMOV AX,DATAMOV DS,AXMOV DX,0MOV DI,NLEA SI,GRADEL1: MOV BX,SIPUSH BXAND BL,0F0HMO
9、V CL,4SHR BL,CLADD DH,BLPOP BXAND BL,0FHADD DL,BLINC SIINC SIDEC DIJNZ L1MOV AL,DHMOV AH,0MOV CL,10DIV CLMOV BH,ALMOV AL,AHMUL CLADD DL,ALMOV AH,0MOV AL,DLMOV CL,10DIV CLMOV BL,ALADD BH,30HMOV DL,BHMOV AH,2INT 21HADD BL,30HMOV DL,BLMOV AH,2INT 21HMOV CX,NLEA BX,GRADE8COMPARE:MOV AX,BXCMP AX,60HJL FI
10、VECMP AX,70HJL SIXCMP AX,80HJL SEVENCMP AX,90HJL EIGHTCMP AX,100HJNE NINEINC S10JMP CHANINE: INC S9JMP CHAEIGHT: INC S8JMP CHASEVEN: INC S7JMP CHASIX: INC S6JMP CHAFIVE: INC S5JMP CHACHA: ADD BX,2LOOP COMPARERETMAIN ENDPCODE ENDSEND START结果截图:9实验 2.3 循环程序设计1、 键盘输入,显示成绩和名次:程序:DATA SEGMENTGRADE DW 10
11、DUP(0)COUNT EQU ($-GRADE)/2ORG 20HRANK DW 10 DUP(?)HH DB 10,13,$MEG1 DB PLEASE INPUT 10 GRADE,10,13,$MEG2 DB GRADE,10,13,$MEG3 DB RANK,10,13,$DATA ENDS;STACK SEGMENT STACKSTA DB 20 DUP(20H)TOP EQU $-STASTACK ENDS;CODE SEGMENTASSUME CS:CODE,SS:STACK,DS:DATASTART: MOV AX,DATAMOV DS,AXMOV AX,STACKMOV S
12、S,AX10MOV SP,TOPLEA DX,MEG1MOV AH,9INT 21HLEA SI,GRADEAGAIN:MOV AH,1INT 21HCMP AL,#JZ EXITCMP AL, JZ L1MOV SI,ALINC SIJMP AGAINL1:MOV AL,SI-2MOV AH,SI-1MOV SI-2,AHMOV SI-1,ALJMP AGAINEXIT:MOV DI,COUNTMOV BX,0LOOP1:MOV AX,GRADEBXMOV CX,COUNTLEA SI,GRADENEXT:MOV DX,SICMP AX,DXJA NO_COUNTINC WORD PTR R
13、ANKBXNO_COUNT:ADD SI,2LOOP NEXTADD RANKBX,30H ADD BX,2DEC DIJNZ LOOP1LEA DX,HHMOV AH,9INT 21HLEA DX,MEG2MOV AH,9INT 21HLEA SI,GRADEMOV CX,10LOOP2:MOV DL,SI+1MOV AH,211INT 21HMOV DL,SIMOV AH,2INT 21HLEA DX,HHMOV AH,9INT 21HINC SIINC SILOOP LOOP2LEA DX,HHMOV AH,9 INT 21HLEA DX,MEG3MOV AH,9INT 21HLEA SI,RANKMOV CX,20LOOP3:MOV DL,SICMP DL,3AHJZ L2MOV AH,2INT 21HJMP L3L2:MOV DL,31HMOV AH,2INT 21HMOV DL,30HMOV AH,2INT 21HL3:INC SILOOP LOOP3MOV AH,1INT 21HMOV AH,4CHINT 21HCODE ENDSEND STARTEND结果截图:122、控制循环程序的方法:计数条件控制法综合3、程序的四个组成部分:a、循环初始化b、循环体c、循环控制部分d、循环结束部分