当前位置:文档之家› 北京理工大学微机原理总汇编语言上机实验题

北京理工大学微机原理总汇编语言上机实验题

实验一请在数据段中定义两个数,要求编写程序分别计算出这两个数的和、差、积、商,并用Debug 的相关命令查询计算结果。

(略)实验二内存自TABLE开始的连续16个单元中存放着0-15的平方值,查表求DATA中任意数X(0≤X ≤15)的平方值,并将结果放在RESULT中。

DATA1 SEGMENTTABLE DB 0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225DATA DB 10RESULT DB ?DATA1 ENDSSTAC SEGMENTDB 100 DUP (?)STAC ENDSCODE SEGMENTASSUME DS:DATA1,SS:STAC,CS:CODESR:MOV AX,DATA1MOV DS,AXMOV AX,STACMOV SS,AXLEA BX,TABLEMOV AH,0MOV AL,DATAXLATMOV RESULT,ALMOV AH,4CHINT 21HCODE ENDSEND SR实验三试编写一程序:比较两个字符串STRING1 和STRING2所含的字符是否相同。

若相同则显示‘MATCH’,否则显示‘NO MATCH’。

DATA1 SEGMENTSTRING1 DB 10,?,10 DUP (?)STRING2 DB 10,?,10 DUP (?)REM1 DB 'PLEASE INPUT STR1: $'REM2 DB 'PLEASE INPUT STR2: $'MESS1 DB 'MATCH$'MESS2 DB 'NO MATCH$'DATA1 ENDSCODE1 SEGMENTASSUME CS:CODE1,DS:DATA1STT: MOV AX,DATA1MOV DS,AXMOV ES,AX LEA DX,REM1 MOV AH,09H INT 21HLEA DX, STRING1 MOV AH, 0AH INT 21HMOV DL, 0DH MOV AH, 6INT 21HMOV DL, 0AH MOV AH, 6INT 21HLEA DX,REM2 MOV AH,09H INT 21HLEA DX, STRING2 MOV AH, 0AH INT 21HMOV DL,0DH MOV AH,6INT 21HMOV DL,0AHMOV AH,6INT 21HLEA SI, STRING1LEA DI,STRING2MOV CL,[SI+1]MOV BL,[DI+1]CMP CL,BLJNE NOMCLDMOV CH,0ADD CL,2REPZ CMPSBJNZ NOM MAT: LEA DX,MESS1JMP SHORT DISP1 NOM: LEA DX,MESS2DISP1: MOV AH,09HINT 21HMOV AH,4CHINT 21HCODE1 ENDSEND STT实验四设有10个学生的成绩分别为:56,69,84,82,73,88,99,63,100,80分。

试编写程序分别统计低于60分、60-69分、70-79分、80-89分、90-99分及100分的人数,并将各分数段的人数在屏幕上显示出来。

DATA SEGMENTSCORE DB 56,69,84,82,73,88,99,63,100,80NUM_UNDER60 DB 0NUM_60TO69 DB 0NUM_70TO79 DB 0NUM_80TO89 DB 0NUM_90TO99 DB 0NUM_100 DB 0DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART:MOV AX,DATAMOV DS,AXXOR AX,AXMOV CX,10LEA BX,SCORECOMPARE:CMP BYTE PTR [BX],60 JL UNDER60JMP IS60TO69IS60TO69:CMP BYTE PTR [BX],70 JL _60TO69JMP IS70TO79IS70TO79:CMP BYTE PTR [BX],80 JL _70TO79JMP IS80TO89IS80TO89:CMP BYTE PTR [BX],90 JL _80TO89JMP IS90TO99IS90TO99:CMP BYTE PTR [BX],100 JL _90TO99JZ EQUAL100UNDER60:ADD NUM_UNDER60,1 JMP CON_60TO69:ADD NUM_60TO69,1 JMP CON_70TO79:ADD NUM_70TO79,1 JMP CON_80TO89:ADD NUM_80TO89,1 JMP CON_90TO99:ADD NUM_90TO99,1 JMP CONEQUAL100:ADD NUM_100,1 CON:LEA BX,[BX+1]LOOP COMPARELAST:MOV DL,NUM_UNDER60 ADD DL,30HMOV AH,2INT 21HMOV DL,' 'MOV AH,2INT 21HMOV DL,NUM_60TO69 ADD DL,30HMOV AH,2INT 21HMOV DL,' 'MOV AH,2INT 21HMOV DL,NUM_70TO79 ADD DL,30HMOV AH,2INT 21HMOV AH,2INT 21HMOV DL,NUM_80TO89 ADD DL,30HMOV AH,2INT 21HMOV DL,' 'MOV AH,2INT 21HMOV DL,NUM_90TO99 ADD DL,30HMOV AH,2INT 21HMOV DL,' 'MOV AH,2INT 21HMOV DL,NUM_100 ADD DL,30HMOV AH,2INT 21HMOV AH,4CHCODE ENDSEND START实验5设有10个学生的成绩分别为88.75.95.63.98.78.87.73.90.60编写程序分别排出他们的名次,并分别存放在后续的10个单元中DATA SEGMENTSCORE DB 88,75,95,63,98,78,87,73,90,60ORDER DB 10 DUP(?)DISPLAY DB '$'DATA ENDSSTACK SEGMENTDB 100 DUP(?)STACK ENDSCODE SEGMENTASSUME CS:CODE,DS:DATA,ES:DATA,SS:STACKSTART:MOV AX,DATAMOV DS,AXMOV ES,AXMOV AX,STACK MOV SS,AXLEA DI,ORDERLEA BX,SCORE MOV DX,10L2:MOV AL,[BX]LEA SI,SCORE MOV CX,10MOV BYTE PTR[DI],1 L1:CMP AL,[SI]JNC TTL:INC BYTE PTR[DI] TT:INC SILOOP L1INC BXINC DIDEC DXMOV CX,10 LEA DX,DISPLAY MOV AH,9INT 21HLEA SI,ORDER L3:MOV AL,[SI] CMP AL,10 JAE TEN MOV DL,[SI] ADD DL,30H MOV AH,2INT 21HJMP DOU TEN:DAAPUSH AX PUSH CX MOV CL,4 SHR AL,CLADD AL,30H MOV DL,AL MOV AH,2 INT 21H POP AX AND AL,0FH ADD AL,30H MOV DL,AL MOV AH,2 INT 21HDOU:INC SICMP CX,1JZ FMOV DL,',' MOV AH,2 INT 21H LOOP L3F:MOV AH,4CHINT 21HCODE ENDSEND START实验六编写程序:要求完成从键盘输入字符,若输入的是数字N,则响铃N次。

如输入不是数字,则不响铃。

DATA SEGMENTNUM DB ?DATA ENDSCODE SEGMENTASSUME DS:DATA,CS:CODESTART: MOV AX,DATAMOV DS,AXMOV AH,1INT 21HXOR CX,CXCMP AL,30HJL L1CMP AL,3AHJGE L1SUB AL,30HMOV CL,ALRING: MOV DL,07HMOV AH,2INT 21HCALL DELAYLOOP RINGDELAY PROCDLAY: PUSH CXMOV BX,0FFFFH LP2: MOV CX,176HLP1: PUSHFPOPFLOOP LP1DEC BXJNZ LP2POP CXRETDELAY ENDPL1: MOV AH,4CHINT 21HCODE ENDSCODE ENDSEND START实验七子程序调用:从键盘输入字符串(包括数字,大写字母,小写字母,标点符号),要求调用子程序将其中的小写字母转换成大写字母,然后将结果输出。

DATA SEGMENTBUF DB 100,?,100 DUP(?)CR DB 13,10,'$'DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX,DATAMOV DS,AXLEA DX,BUFMOV AH,0AHINT 21HMOV DL,0DHMOV AH,6INT 21HMOV DL,0AHMOV AH,6INT 21HXOR BX,BXLEA SI,BUF+2XOR CX,CXMOV CL,BUF+1 L1: MOV DL,[SI]CMP DL,'a'JB NCMP DL,'z'JA NCALL CHANGE N:MOV AH,02HINT 21HINC SILOOP L1JMP LAST CHANGE PROC PUSH CXSUB DL,20HPOP CXRETCHANGE ENDP LAST: LEA DX,CRMOV AH,9INT 21HMOV AH,4CHINT 21H CODE ENDSEND START。

相关主题