《华电保定微机原理总汇编实验.doc》由会员分享,可在线阅读,更多相关《华电保定微机原理总汇编实验.doc(48页珍藏版)》请在课桌文档上搜索。
1、word实验一 、数据块传送1. 将数据段中2000H单元开始存放的10个数8位数传送到3000H开始的10个字节中。源程序:DATAS SEGMENT;此处输入数据段代码 ORG 2000H DATA1 DB 1,2,3,4,5,6,7,8,9,10ORG 3000H DATA2 DB 10 DUP(0)DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码MOV SI,2000HMOV D
2、I,3000HMOV CX,10NEXT:MOV AL,SIMOV DI,ALINC SIINC DIDEC CX JNZ NEXT MOV AH,4CH INT 21HCODES ENDSENDSTART运行结果:2. 将数据段中2000H单元开始存放的10个数16位数传送到3000H开始的10个字中。源程序:DATAS SEGMENT;此处输入数据段代码 ORG 2000H DATA1 DW 1,2,3,4,5,6,7,8,9,10ORG 3000H DATA2 DW 10 DUP(0) DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES
3、SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码MOV SI,2000HMOV DI,3000HMOV CX,10NEXT:MOV AX,SIMOV DI,AXADD SI,2ADD DI,2DEC CX JNZ NEXT MOV AH,4CH INT 21HCODES ENDSENDSTART运行后:3. 将数据DATA1中的10个字节数据传送到数据段DATA2中源数据:DATAS SEGMENT;此处输入数据段代码 DATA1 DB 1,2,3,4,5,6,7,8,9,10ORG 1
4、000H DATA2 DB 10 DUP(0)DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA SI,DATA1LEA DI,DATA2MOV CX,10NEXT:MOV AL,SIMOV DI,ALINC SIINC DIDEC CX JNZ NEXTMOV AH,4CH INT 21HCODES ENDSENDSTART初始值:运行后:4. 将数据段中2000H开始的20个数据
5、传送到2010H开始的20个单元中。源程序:DATAS SEGMENT;此处输入数据段代码 ORG 2000H DATA1 DB 5 DUP(1,2,3,4,5,6) DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码MOV SI,2000HMOV DI,2100HMOV CX,20NEXT1:MOV AL,SIMOV DI,ALINC SIINC DIDEC CX JNZ NEXT1MO
6、V SI,2100HMOV DI,2010HMOV CX,20NEXT2:MOV AL,SIMOV DI,ALINC SIINC DIDEC CX JNZ NEXT2 MOV AH,4CH INT 21HCODES ENDSENDSTART运行结果:实验二 查表实验目的:熟悉实验环境;熟练掌握查表程序1. 015的平方值表,查表求X的平方值,送到Y单元,用两种方法DATAS SEGMENT;此处输入数据段代码 TABLE DB0, 1,4,9,16,25,36,49,64,81,100,121,144,169,255 X DB 3 Y DB 0DATAS ENDSSTACKS SEGMENT;
7、此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA BX,TABLE MOV AL,XMOV AH,0ADD BX,AXMOV AL,BXMOV Y,ALMOV AH,4CH INT 21HCODES ENDSENDSTART运行结果:方法二:源程序:DATAS SEGMENT;此处输入数据段代码 TABLE DB0,1,4,9,16,25,36,49,64,81,100,121,144,169,255 X DB 3 Y DB 0D
8、ATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA BX,TABLE MOV AL,XXLATMOV Y,ALMOV AH,4CH INT 21HCODES ENDSENDSTART运行结果2. 20255的平方值表,查表求X的平方值,送到Y单元源程序DATAS SEGMENT;此处输入数据段代码 TABLE DW 0,1,4,9,16,25,250 DUP(0) X DW 3 Y D
9、W?DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA SI,TABLEMOV AX,XADD AX,AXADD BX,AXMOV AX,BXMOV Y,AXMOV AH,4CH INT 21HCODES ENDSENDSTART运行结果实验三、计算1. 计算1234F000H+98765000H的和源程序:DATAS SEGMENT;此处输入数据段代码 DATA1 DD 1234F
10、000H DATA2 DD 98765000HDATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA SI,DATA1LEA DI,DATA2MOV AX,SIADD AX,DIMOV SI,AXMOV AX,SI+2ADC AX,DI+2MOV SI+2,AXMOV AH,4CH INT 21HCODES ENDSENDSTART运行结果2.源程序:DATAS SEGMENT;此处输入
11、数据段代码 DATA1 DQ DATA2 DQ 99AABBCCDDEEFF00HDATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA SI,DATA1LEA DI,DATA2MOV CX,4 CLCNEXT:MOV AX,SIADC AX,DIMOV SI,AXADD SI,2ADD DI,2DEC CX JNZ NEXTMOV AH,4CH INT 21HCODES ENDSEND
12、START运行结果3.源程序:DATAS SEGMENT;此处输入数据段代码 DATA1 DB 88H,77H,66H,55H,44H,33H,22H,11H DATA2 DB 22H,33H,44H,55H,66H,77H,88H,99HDATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA SI,DATA1LEA DI,DATA2 CLCMOV CX,8NEXT:MOV AL,SIA
13、DC AL,DIDAAMOV SI,ALINC SIINC DIDEC CX JNZ NEXTMOV AH,4CH INT 21HCODES ENDSENDSTART运行结果4. 计算10个字节数据的和数据自己定义源程序:DATAS SEGMENT;此处输入数据段代码 DATA1 DB 1,2,3,4,5,6,7,8,9,10 SUM DB 0 DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码
14、段代码LEA SI,DATA1LEA DI,SUMMOV CX,10 CLCNEXT:MOV AL,SIADC SUM,ALADD SI,1DEC CX JNZ NEXTMOV AH,4CH INT 21HCODES ENDSENDSTART运行结果5. 计算10个字数据的和数据自己定义源程序:DATAS SEGMENT;此处输入数据段代码 DATA1 DW 1,2,3,4,5,6,7,8,9,10 SUM DW 0 DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STA
15、CKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA SI,DATA1LEA DI,SUMMOV CX,10 CLCNEXT:MOV AX,SIADC SUM,AXADD SI,2DEC CX JNZ NEXTMOV AH,4CH INT 21HCODES ENDSENDSTART运行结果实验四、计算表达式的值1. 计算表达式的值,X=10,Y=5。DATAS SEGMENT;此处输入数据段代码 X DB 10 Y DB 5 Z DB?DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUM
16、E CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码MOV AL,XSUB AL,YMOV BL,7MUL BL CBWMOV BL,YADD BL,2IDIV BLMOV Z,ALMOV AH,4CH INT 21HCODES ENDSENDSTART实验五、找最大、最小数1. 找出2040H单元和2041H单元的大数,送2042H单元数据自己定义DATAS SEGMENT;此处输入数据段代码 ORG 2040H DATA1 DB 11 DATA2 DB 12 DATA3 DB?DATAS ENDSSTACKS
17、SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码MOV AL,DATA1CMP AL,DATA2 JG GREATMOV AL,DATA2GREAT:MOV DATA3,AL MOV AH,4CH INT 21HCODES ENDSENDSTART2. 找出10个数8位数里的最大数数据自己定义DATAS SEGMENT;此处输入数据段代码 DATA DB 1,2,3,6,5,4,10,9,8,7 MAX DB?DATAS
18、 ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA BX,DATAMOV CX,9MOV AL,BXNEXT:INC BXCMP AL,BX JG GREATMOV AL,BXGREAT:MOV MAX,ALDEC CX JNZ NEXTMOV AH,4CH INT 21HCODES ENDSENDSTART3. 找出10个数8位数里的最小数数据自己定义DATAS SEGMENT;此处输入数据
19、段代码 DATA DB 3,2,1,6,5,4,10,9,8,7 MIN DB?DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA BX,DATAMOV CX,9MOV AL,BXNEXT:INC BXCMP AL,BX JL LESSMOV AL,BXLESS:MOV MIN,ALDEC CX JNZ NEXTMOV AH,4CH INT 21HCODES ENDSENDSTART
20、4. 找出10个数16位数里的最大数数据自己定义DATAS SEGMENT;此处输入数据段代码 DATA DW 3,2,1,6,5,4,10,9,8,7 MAX DW?DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA BX,DATAMOV CX,9MOV AX,BXNEXT:ADD BX,2CMP AX,BX JG GREATMOV AX,BXGREAT:MOV MAX,AXDEC
21、 CX JNZ NEXTMOV AH,4CH INT 21HCODES ENDSENDSTART5. 找出10个数16位数里的最小数数据自己定义DATAS SEGMENT;此处输入数据段代码 DATA DW 3,2,1,6,5,4,10,9,8,7 MIN DW?DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA BX,DATAMOV CX,9MOV AX,BXNEXT:ADD BX
22、,2CMP AX,BX JL LESSMOV AX,BXLESS:MOV MIN,AXDEC CX JNZ NEXTMOV AH,4CH INT 21HCODES ENDSENDSTART实验六、统计正数、负数个数1. 找出10个数8位数里的正数个数数据自己定义源程序:DATAS SEGMENT;此处输入数据段代码 TABLE DB-1,-2,-3,-4,-5,1,2,3,4,5 NUM DB?DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV
23、 AX,DATASMOV DS,AX;此处输入代码段代码LEA SI,TABLEMOV NUM,0MOV CX,10NEXT2:MOV AL,SI TEST AL,80H JNZ NEXT1INC NUMNEXT1:INC SIDEC CX JNZ NEXT2MOV AH,4CH INT 21HCODES ENDSENDSTART运行结果:2. 找出10个数8位数里的负数个数数据自己定义源程序:DATAS SEGMENT;此处输入数据段代码 TABLE DB-1,-2,-3,-4,-5,1,2,3,4,5 NUM DB?DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STA
24、CKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA SI,TABLEMOV NUM,0MOV CX,10NEXT2:MOV AL,SI TEST AL,80H JZ NEXT1INC NUMNEXT1:INC SIDEC CX JNZ NEXT2MOV AH,4CH INT 21HCODES ENDSENDSTART运行结果:3. 找出10个数16位数里的正数个数数据自己定义源程序:DATAS SEGMENT;此处输入数据段代码 TABLE DW-1,-2
25、,-3,-4,-5,1,2,3,4,5NUM DB?DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA SI,TABLEMOV NUM,0MOV CX,10NEXT2:MOV AX,SI TEST AX,8000H JNZ NEXT1INC NUMNEXT1:ADD SI,2DEC CX JNZ NEXT2MOV AH,4CH INT 21HCODES ENDSENDSTART运行结
26、果:4. 找出10个数16位数里的负数个数数据自己定义源程序:DATAS SEGMENT;此处输入数据段代码 TABLE DW-1,-2,-3,-4,-5,1,2,3,4,5NUM DB?DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA SI,TABLEMOV NUM,0MOV CX,10NEXT2:MOV AX,SI TEST AX,8000H JZ NEXT1INC NUMNE
27、XT1:ADD SI,2DEC CX JNZ NEXT2MOV AH,4CH INT 21HCODES ENDSENDSTART运行结果:实验七、数据块比拟1. 比拟数据段DS与数据段ES中的10个字节的数据是否一致?源程序:DATAS SEGMENT;此处输入数据段代码 TABLE1 DB 1,2,3,4,5,6,7,8,9,10 N DB?DATAS ENDSDATAB SEGMENT TABLE2 DB 1,2,3,4,5,6,8,7,9,10DATAB ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES
28、,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AXMOV BX,DATABMOV ES,BX;此处输入代码段代码LEA SI,TABLE1LEA DI,TABLE2 CLDMOV CX,10MOV N,0NEXT2:CMPSB JNZ NEXT1DEC CX JNZ NEXT2 JMP EXITNEXT1:INC NEXIT:MOV AH,4CH INT 21HCODES ENDSENDSTART运行结果:(一样N=0,不同N=1)2. 比拟数据段DS与数据段ES中的10个字的数据是否一致?源程序:DATAS SEGMENT;此处输入数据段代码 TAB
29、LE1 DW 1,2,3,4,5,6,7,8,9,10 N DB?DATAS ENDSDATAB SEGMENT TABLE2 DW 1,2,3,4,5,6,8,7,9,10DATAB ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AXMOV BX,DATABMOV ES,BX;此处输入代码段代码LEA SI,TABLE1LEA DI,TABLE2MOV CX,10MOV N,0 CLDNEXT2:CMPSW JNZ N
30、EXT1DEC CX JNZ NEXT2 JMP EXITNEXT1:INC NEXIT:MOV AH,4CH INT 21HCODES ENDSENDSTART运行结果:(一样N=0,不同N=1)实验八、逻辑运算与移位1. 将数据段中4000H单元的容拆开,高位送4001H低位,低位送4002H低位,4001H、4002H的高位清零,一般用于把数据送显示缓冲区时使用。源程序:DATAS SEGMENT;此处输入数据段代码 ORG 4000H DATA1 DB 9AH DATA2 DB? DATA3 DB?DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS END
31、SCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码MOV AL,DATA1AND AL,0F0HMOV CL,4SHR AL,CLMOV DATA2,ALMOV AL,DATA1AND AL,0FHMOV DATA3,ALMOV AH,4CH INT 21HCODES ENDSENDSTART运行结果:2. 将4000H、4001H单元的低位送4002H单元的高、低位,一般用于将缓冲区的数据取出拼成一个字节。源程序:DATAS SEGMENT;此处输入数据段代码 ORG 40
32、00H DATA1 DB 9AH DATA2 DB 7BH DATA3 DB?DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码MOV AL,DATA1AND AL,0FHMOV CL,4SHL AL,CLMOV DATA3,ALMOV AL,DATA2AND AL,0FHADD DATA3,ALMOV AH,4CH INT 21HCODES ENDSENDSTART运行结果:实验九、输入
33、输出1. 在显示器上输出字符串HELLO!DATAS SEGMENT;此处输入数据段代码 STRING DBHELLO!$DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA DX,STRINGMOV AH,9 INT 21HMOV AH,4CH INT 21HCODES ENDSENDSTART2. .从键盘输入一组字符串,存入到BUFFER数据区自己定义中。DATAS SEGMEN
34、T;此处输入数据段代码 BUFFER DB 100,0,100 DUP(?) DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA DX,BUFFERMOV AH,10 INT 21HMOV CL,BUFFER+1XOR CH,CHADD DX,CXMOV BX,DXMOV BYTE PTRBX+2,$MOV AH,4CH INT 21HCODES ENDSENDSTART3. .将存
35、单元存放的BCD码25H在显示器上输出(即输出字符25)。 DATAS SEGMENT;此处输入数据段代码 DATA DB 25HDATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA BX,DATAMOV AL,BXAND AL,0F0HMOV CL,4SHR AL,CLADD AL,30HMOV DL,ALMOV AH,2 INT 21HMOV AL,BXAND AL,0FHADD
36、AL,30HMOV DL,ALMOV AH,2 INT 21HMOV AH,4CH INT 21HCODES ENDSENDSTART4. 将存单元存放的十进制数25从显示器上输出(即输出字符25)。DATAS SEGMENT;此处输入数据段代码 DATA DB 25DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA BX,DATAMOV AL,BX CBWMOV CL,10DIV
37、CLADD AL,30HADD AH,30HMOV BL,AHMOV DL,ALMOV AH,2 INT 21HMOV DL,BLMOV AH,2 INT 21HMOV AH,4CH INT 21HCODES ENDSENDSTART5. 从键盘输入10个个位数字09之间的任意数字,并存储到数据区INPUT中。DATAS SEGMENT;此处输入数据段代码 BUFFER DB 20,0,20 DUP(?) INPUT DB 10 DUP(0)DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:
38、DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA SI,BUFFERLEA DI,INPUTMOV AH,10 INT 21HMOV CL,BUFFER+1NEXT:MOV AL,SI+2SUB AL,30HMOV DI,ALINC SIINC DIDEC CL JNZ NEXTMOV AH,4CH INT 21HCODES ENDSENDSTART6. 将数据段中的10个个位数数据从显示器上输出。DATAS SEGMENT;此处输入数据段代码 DATA DB 1,2,3,4,5,6,7,8,9,0DATAS ENDSSTACKS
39、SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA BX,DATAMOV CX,10NEXT:MOV AL,BXADD AL,30HMOV DL,ALMOV AH,2 INT 21HINC BXDEC CX JNZ NEXTMOV AH,2 INT 21HMOV AH,4CH INT 21HCODES ENDSENDSTART7. 输入任意个字符存到BUFFER数据区自己定义,输入时以回车作为完毕标志。DATAS S
40、EGMENT;此处输入数据段代码 BUFFER DB 100,0,100 DUP(?)DATAS ENDSSTACKS SEGMENT;此处输入堆栈段代码STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART:MOV AX,DATASMOV DS,AX;此处输入代码段代码LEA BX,BUFFERMOV AH,10 INT 21HMOV AH,4CH INT 21HCODES ENDSENDSTART实验十、子程序1. 编写8位数求和子程序,并调用它完成10个数的求和程序。DATAS SEGMENT;此处输入数据段代码 ARY DB 1,2,3,4,5,6,7,8,9,10