一.实验目的:
1.掌握几种最基本的代码转换方法;
2.运用子程序进行程序设计.
二.实验内容:
1.从键盘上输入若干两位十进制数,寻找其中的最小值,然后在屏幕上显示出来.
2.两个十进制数之间的分隔符,输入结束标志自定,但要在报告中说明.
3.对输入要有检错措施,以防止非法字符输入,并有适当的提示.
4.将整个程序分解为若干模块,分别用子程序实现.在报告中要给出模块层次图.
源程序:
(以后一定养成写注释的好习惯)
DATA SEGMENT
BUFFER DB 100
DB 0
DB 100 DUP (0)
MIN DB 0
STRING DB ' INPUT WRONG,PLEASE INPUT ',0DH,0AH,'$'
STRING1 DB 'THE MUNBER IS ',0DH,0AH,'$'
DATA ENDS
STACK SEGMENT STACK 'STACK'
DB 100 DUP (?)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK,ES:DATA
MAIN: MOV AX,DATA
MOV DS,AX
CALL INPUT
CALL JUDGE
CALL BIJIAO
CALL OUTPUT
MOV AX,4C00H
INT 21H
INPUT PROC
MOV DX,SEG BUFFER
MOV DS,DX
MOV DX,OFFSET BUFFER
MOV AH,0AH
INT 21H
RET
INPUT ENDP
JUDGE PROC
LEA BX,BUFFER
JUDGE1: MOV AL,[BX+2]
CMP AL,'!'
JZ C
CMP AL,','
JZ B
CMP AL,29H
JBE A
CMP AL,40H
JAE A
JMP B
A: MOV AH,09H
MOV DX,SEG STRING
MOV DS,DX
MOV DX,OFFSET STRING
INT 21H
JMP C
B: INC BX
JMP JUDGE1
C: NOP
RET
JUDGE ENDP
BIJIAO PROC
LEA BX,BUFFER
CALL JIA
MOV MIN,AL
G: CALL JIA
CMP AL,MIN
JGE D
MOV MIN,AL
D: INC BX
INC BX
MOV AL,[BX+2]
CMP AL,'!'
JZ F
INC BX
JMP G
JIA: MOV AL,[BX+2]
SUB AL,30H
ADD AL,AL
MOV CH,AL
MOV CL,2
SHL AL,CL
ADD AL,CH
MOV AH,[BX+3]
SUB AH,30H
ADD AL,AH
RET
F: NOP
RET
BIJIAO ENDP
OUTPUT PROC
MOV AH,09H
MOV DX,SEG STRING1
MOV DS,DX
MOV DX,OFFSET STRING1
INT 21H
MOV AL,MIN
CBW
MOV BL,10
DIV BL
MOV BH,AH
ADD AL,30H
MOV AH,02H
MOV DL,AL
INT 21H
MOV AL,BH
ADD AL,30H
MOV AH,02H
MOV DL,AL
INT 21H
RET
OUTPUT ENDP
CODE ENDS
END MAIN