实验1 顺序程序设计
一、实习题目
两个多位十进制数相加。
二、实习目的和要求
1. 学习数据传送和算术运算指令的用法。
2. 熟悉在PC机上建立、汇编、链接、调试和运行8088/8086汇编语言程序的过程。
三、实习内容
将两个多位十进制数相加,要求被加数、加数均以ASCⅡ码形式各自顺序存放在以DATA1和DATA2为首的五个内存单元中(低位在前),结果送回DATA1处。
data segment DATA1 DB "2","2","3","4","5","$"; DATA2 DB "1","9","2","1","3","$"; DATA3 DB "0","0","0","0","0","$"; STR1 DB "THE RESULT IS :",0AH,"$"; STR2 DB "THE FIRST NUM :",0AH,"$"; STR3 DB "THE SECOND NUM :",0AH,"$"; data ends code segment assume cs:code,ds:data; start: MOV AX,DATA; MOV DS,AX; MOV CX,5; MOV DL,0; MOV BX,0; MOV AH,09H; 提示信息 LEA DX,STR2; INT 21H; STR1 INPUT1: ;输入第一个数 MOV AH,01H; INT 21H; MOV DATA1[BX],AL; INC BX; LOOP INPUT1; MOV AH,02H; MOV DL,32; INT 21H; MOV BX,0; MOV CX,5; MOV AH,09H; 提示信息 LEA DX,STR3; INT 21H; STR1 INPUT2: ;输入第二个数 MOV AH,01H; INT 21H; MOV DATA2[BX],AL; INC BX; LOOP INPUT2; MOV CX,5; MOV DL,0; MOV BX,0; MOV AH,02H; MOV DL,0AH; INT 21H; PLUS: MOV DL,DATA1[BX]; ADD DL,DATA2[BX]; SUB DL,48; INC BX; CMP DL,'9'; JB NOUP ADD DATA1[BX],1;进位 SUB DL,10; NOUP: MOV DATA1[BX-1],DL; LOOP PLUS; MOV AH,09H; 提示信息 LEA DX,STR1; INT 21H; STR1 LEA DX,DATA1; MOV AH,09H; INT 21H; MOV AX,4C00H INT 21H; CODE ENDS END START;