微机原理,键盘输入实现任意两个数相加
发布时间:2024-11-21
发布时间:2024-11-21
微型计算机原理与接口技术,微型计算机系统原理及应用-上机实验
用汇编语言,从键盘输入任意两个十进制数,实现两个数相加 DATAS SEGMENT
X DB 100 DUP(0)
Y DB 100 DUP(0)
Z DB 100 DUP(?),'$'
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV BX,0
X1: MOV AH,01H
INT 21H
CMP AL,'+'
JZ X2
PUSH AX
INC BX
JMP X1
X2: MOV CX,BX
MOV SI,99
X3: POP AX
MOV X[SI],AL
DEC SI
LOOP X3
MOV BX,0
X4: MOV AH,01H
INT 21H
CMP AL,'='
JZ X5
PUSH AX
INC BX
JMP X4
X5: MOV CX,BX
MOV SI,99
X6: POP AX
MOV Y[SI],AL
DEC SI
LOOP X6
CLC
PUSHF
微型计算机原理与接口技术,微型计算机系统原理及应用-上机实验
MOV CX,100
MOV SI,99 MOV DI,99
X7: MOV AL,X[SI]
MOV DL,Y[SI]
POPF
ADC AL,DL
AAA
PUSHF
ADD AL,30H
MOV Z[DI],AL
DEC SI
DEC DI
LOOP X7
MOV SI,0
X8: CMP Z[SI],30H
JNZ X9
INC SI
JMP X8
X9: LEA DX,Z[SI]
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
CODES ENDS
END START
上一篇:电力电子技术实验报告