21H的源码
❶ DOS加法的编程代码
DATA SEGMENT ;数据段
MSG1 DB 'PLEASE INPUT A',0DH,0AH,'$'
MSG2 DB 0DH,0AH,'PLEASE INPUT B',0DH,0AH,'$'
MSG3 DB 0DH,0AH,'RESULT IS',0DH,0AH,'$'
MSG4 DB 0DH,0AH,'ERROR',0DH,0AH,'$'
DATA ENDS
EXTRA SEGMENT;附加段
EXTRA ENDS
STACK SEGMENT;堆栈段
STAPN DB 100 DUP (00H) ;定义100字节空间
TOP EQU LENGTH STAPN
STACK ENDS
CODE SEGMENT
MAIN PROC FAR ;过程定义语句
ASSUME CS:CODE,DS:DATA,ES:EXTRA,SS:STACK
START:
MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
MOV AX,STACK
MOV SS,AX
;写入代码
LEA DX,MSG1 ;将MSG1首地址值赋给DX
MOV AH,09H ;调用09H指令,显示字符串,DS:DX=串指令
INT 21H
MOV AH,01H
INT 21H ;读入一个数,放在AL中,读进来的数为ASCII码
SUB AL,30H ;转为原来的数,因为30H为0的ASCLL码
MOV BL,AL ;由于后期AL需要再度被赋值,固将操作数A存放在BL中
MOV DX,OFFSET MSG2 ;将首地址存放在DX中
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
SUB AL,30H ;转为原来的数,例如34H,原来的数实际上为我们由键盘输入的4
ADD AL,BL ;两数相加,根据条件(8)假如数字只和大于10则显示错误
CMP AL,0AH ;假如大于等于10则错误
JAE ERROR ;相加之和大于等于10则跳转到ERROR,否则顺序执行
MOV BL,AL
MOV DX,OFFSET MSG3
MOV AH,09H
INT 21H
ADD BL,30H ;将BL众数据转换为ASCII码,因为输出结果是个位数且只输出一个字符
MOV DL,BL ;将待显示字符的ASCLL码放入DL中
MOV AH,02H
INT 21H
;退出DOS系统
MOV AH,4CH
INT 21H
RET
ERROR:LEA DX,MSG4
MOV AH,09H
INT 21H
RET
MAIN ENDP;MAIN过程结束
CODE ENDS ;代码段结束
END START ;整个源代码结束
❷ 帮我看看我的源代码错在哪里
语法都有错误
DATA SEGMENT
ERADE DB 50 DUP(?)
RANK DB 100 DUP(?)
X1 DB 'please input the numbers of student:$'
X2 DB 'please input the schoolnumbers of student one by one:$'
HC DB 0DH,0AH,'$';0DH回车,0AH换行,$字符串结束
DATA ENDS
STACK SEGMENT PARA STACK'STACK'
DB 50 DUP(?)
STACK ENDS
;换行宏定义
SHOW MACRO TT
LEA DX,TT
MOV AH,09H
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
INPUT PROC FAR
MOV DX,OFFSET X1
MOV AH,09H
INT 21H
SHOW HC
MOV AH,01H
INT 21H
mov ah, 0
sub ax, 30h
MOV CX,ax
SHOW HC
MOV DX,OFFSET X2
MOV AH,09H
INT 21H
SHOW HC
MOV SI,OFFSET RANK
CON: MOV AH,01H
INT 21H
MOV [SI],AL
INC SI
MOV AH,01H
INT 21H
MOV [SI],AL
INC SI
DEC CX
JZ AGN1
MOV AH,01H
INT 21H
CMP AL,20H
JZ CON
AGN1:
MOV DL,1H
MOV AH,02H
INT 21h
RET
INPUT ENDP
MAIN:
MOV AX,DATA
MOV DS,AX
CALL INPUT
MOV AH,4cH
INT 21H
CODE ENDS
END MAIN