1、微型计算机原理实验实验一:输出字符 A的源程序如下:PROG SEGMENTASSUME CS:PROGSTART: MOV DL,AMOV AH , 2INT 21HMOV AH , 4CHINT 21HPROG ENDSEND START实验二:1.把 BX 中的二进制数转换成十进制数,在屏幕上显示出来,只考虑无符号数。程序如下:CODE SEGMENTASSUMECS:CODESTART: MOVBX,0FFFHMOVCX,10000CALLDEC_DIVMOVCX, 1000CALLDEC_DIVMOVCX,100CALLDEC_DIVMOVCX,10CALLDEC_DIVMOVCX,
2、1CALLDEC_DIVMOVAH,4CHINT21HDEC_DIV PROCNEARMOVAX,BXMOVDX,0DIVCXMOVBX,DXMOVDL,ALADDDL,30HMOVAH,2INT21HRETDEC_DIV ENDPCODE ENDSENDSTART2.把 BX中的带符号数转换成十进制数,在屏幕上显示出来。程序如下:CODE SEGMENT ASSUME CS:CODESTART: MOVBX,8001HMOVAX,8000HANDAX,BXJNZMINUSJMPDISPMINUS: MOVDL,-MOVAH,2INT21HNEGBXJMPDISPDISP: MOVCX,100
3、00CALLDEC_DIVMOVCX, 1000CALLDEC_DIVMOVCX,100CALLDEC_DIVMOVCX,10CALLDEC_DIVMOVCX,1CALLDEC_DIVMOVAH,4CHINT21HDEC_DIV PROCNEARMOVAX,BXMOVDX,0DIVCXMOVBX,DXMOVDL,ALADDDL,30HMOVAH,2INT21HRETDEC_DIV ENDPCODE ENDSENDSTART3.求一个数据块(由 10 个单字节的无符号数组成)中的最大元素,并将结果在屏幕上显示出来,程序如下:DATA SEGMENTBLOCK DB1,0,5,7,10,30,10
4、0,127,90,80RESULT DB?DATA ENDSCODE SEGMENTASSUMECS:CODE,DS:DATABEGIN PROCFARMOVAX,DATAMOVDS,AXMOVCX,9LEASI,BLOCKMOVAL,SIX1: INCSICMPAL,SIJAEX2MOVAL,SIX2: LOOPX1MOVRESULT,ALMOVAH ,0MOVBX,AXCALLXIANSHIMOVAH,4CHINT21HBEGIN ENDPXIANSHI PROCNEARMOVAL,80HANDAL,BLJNZMINUSJMPDISPMINUS: MOVDL,-MOVAH,2INT21HN
5、EGBLJMPDISPDISP: MOVCX,100CALLDEC_DIVMOVCX,10CALLDEC_DIVMOVCX,1CALLDEC_DIVMOVAH,4CHINT21HXIANSHI ENDPDEC_DIV PROCNEARMOVAX,BXMOVDL,0DIVMOVMOVMOVADDMOVINTCLBL,AHBH,0DL,ALDL,30HAH,221HRETDEC_DIV ENDPCODE ENDSEND BEGIN4.求一个数据块(由 20 个单字节的带符号数组成)中的正数和(字)和负数和(字),并在屏幕上用十进制的形式显示出两个和。程序如下:DATA SEGMENTBLOCK D
6、W -100,100,200,-200,5,6,7,8,9,10DW 11,12,13,14,15,50,-50,150,-150,-200POSIT DW ?NEGAT DW ?ST1 DB The sum of all the positive numbers:$ST2 DB The sum of the negative numbers:$MOV AX,DATAMOV DS,AXMOV BX,OFFSET BLOCKMOV SI,0MOV DI,0MOV CX,20X1: MOV AX,BXCMP AX,0JGE X3ADD DI,AXJMP X2X3: ADD SI,AXX2: ADD
7、 BX,2LOOP X1MOV POSIT,SIMOV NEGAT,DIMOVMOVMOVBX,SIDX,OFFSET ST1AH,9INT21HCALLXIANSHIMOVDL,0DHMOVAH,2INT21HMOVDL,0AHMOVAH,2INT21HMOVBX,NEGATNEGBXANDBX,7FFFHMOVDX,OFFSET ST2MOVAH,9INT21HMOVDL,-MOVAH,2INT21HCALLXIANSHIMOVAH,4CHINT21HSTART ENDPXIANSHI PROCNEARMOVCX,100CALLDEC_DIVMOVCX,10CALLDEC_DIVMOVCX
8、,1CALLDEC_DIVRETXIANSHI ENDPDEC_DIV PROCNEARMOVAX,BXMOVDX,0DIVCXMOVBX,DXMOVDL,ALADDDL,30HMOVAH,2INT21HRETDEC_DIV ENDPCODE ENDSEND START5.将寄存器 BX中的二进制数转换成十六进制数并在屏幕上显示出来。程序如下:CODE SEGMENTASSUMECS:CODEBINHEX PROCFARMOVCH,4MOVBX,1000ROTATE: MOVCL,4ROLBX,CLMOVDL,BLANDDL,0FHADDDL,30HCMPDL,3AHJLOUTPUTADDDL
9、,7OUTPUT: MOVAH,2INT21HDECCHJNEROTATEMOVDL,HMOVAH,2INT21HMOVAH,4CHINT21HBINHEX ENDPCODE ENDSENDBINHEX实验三:1.从键盘上输入一个十进制数( 065535),转换成二进制数并放入寄存器BX中,其程序框图如下:程序如下:CODE SEGMENTASSUME CS:CODESTART PROCCALL DECBINCALL XIANSHIMOV AH,4CHINT 21HSTART ENDPDECBIN PROCNEARMOVCX,10MOVBX,0LOP1: MOVAH,1INT21HCMPAL,
10、30HJLEXITCMPAL,39HJGEXITSUBAL,30HMOVAH,00HXCHGAX,BXMULCXADDBX,AXJMPLOP1EXIT: RETDECBIN ENDPXIANSHI PROC NEARLP1: MOV CX,10000CALL DEC_DIVMOV CX,1000CALL DEC_DIVMOV CX,100CALL DEC_DIVMOV CX,10CALL DEC_DIVMOV CX,1CALL DEC_DIVRETXIANSHI ENDPDEC_DIV PROC NEARMOV AX,BXMOV DX,0DIV CXMOV BX,DXMOV DL,ALADD
11、DL,30HMOV AH,2INT 21HRETDEC_DIV ENDPCODE ENDSEND START2.从键盘上输入 0 65535 范围的一个十进制数,在屏幕上显示出相应的十六进制数。程序如下:CODE SEGMENTASSUME CS:CODESTART PROCCALL DECBINMOV CH,4CALL ROTATEMOV AH,4CHINT 21HSTART ENDPDECBIN PROCNEARMOVCX,10MOVBX,0LOP1: MOVAH,1INT21HCMPAL,30HJLEXITCMPAL,39HJGEXITSUBAL,30HMOVAH,00HXCHGAX,B
12、XMULCXADDBX,AXJMPLOP1EXIT: RETDECBIN ENDPROTATE PROCLOP2: MOVCL,4ROLBX,CLMOVDL,BLANDDL,0FHADDDL,30HCMPDL,3AHJLOUTPUTADDDL,7OUTPUT: MOVAH,2INT21HDECCHJNELOP2MOVDL,HMOVAH,2INT21HMOVAH,4CHINT21HROTATE ENDPCODE ENDSENDSTART实验四:1.在内存中存有一字符串,以0 为结尾,程序开始输出 HELLO然后等待从键盘输入一字符,再改字符串中寻找该字符,若找到,输出yes;若找不到,输出 no
13、 ,然后再输入下一字符。程序如下:DATASEGMENTSTR1DBHELLO,0DH,0AH,$STR2DB20H,YES,0DH,0AH,$STR3DB20H,NO,0DH,0AH,$STR4DB1 2 3 0 4 5 A B a=! ?,00HDATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART PROCFARMOVAX,DATAMOVDS,AXMOVDX,OFFSET STR1MOVAH,9INT21HLOOP1: MOVAH,1INT21HMOVBX,OFFSET STR4GON:MOVAH,BXCMPAH,0JZNOINCBXCMPAH,ALJ
14、NZGONMOVDX,OFFSET STR2GO:MOVAH,9INT21HJMPLOOP1NO:MOVDX,OFFSET STR3JMPGOSTART ENDPCODEENDSENDSTART2.实验内容 1 的程序是个无限循环程序,若按ESC键,让程序退出循环,是系统返回 DOS。已知 ESC键的键值是1BH,按照上面要求对实验内容1 的程序进行修改,然后重新汇编、链接和运行。程序如下:DATASEGMENTSTR1DBHELLO,0DH,0AH,$STR2DB20H,YES,0DH,0AH,$STR3DB20H,NO,0DH,0AH,$STR4DB1 2 3 0 4 5 A B a=! ?,00HDATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART PROCFARMOVAX,DATAMOVDS,AXMOVDX,OFFSET STR1MOVAH,9INT21HLOOP1: MOVAH,1INT21HMOVBX,OFFSET STR4GON:MOVAH,BXCMPAH,0JZNOINCBXCMPJNZMOVGO: MOVINTJMPNO: MOVJMPSTART ENDPCODE ENDSENDAH,ALGONDX,OFFSET STR2AH,921HLOOP1DX,OFFSET STR3GOSTART
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1