北邮微机原理软件实验报告(精) 下载本文

TAB DB 100 DUP(? DATA ENDS

STACK SEGMENT STACK 'stack' DB 100 DUP ('s' STACK ENDS

CODE SEGMENT PARA 'code'

ASSUME CS:CODE,DS:DATA,SS:STACK START PROC FAR PUSH DS XOR AX,AX PUSH AX MOV AX,DATA MOV DS,AX ;初始化DS LEA DX,STR1

MOV AH,09H;调用DOS 09号功能显示字符串STR1 INT 21H

INPUT: LEA DX,BUFFER

MOV AH,0AH;调用DOS 0A号功能,从键盘输入字符串并存储 INT 21H

LEA DI,TAB XOR CX,CX MOV AH,30H MOV DH,31H LEA BX,BUFFER+2

CALL CHECK ;调用检错子程序 CMP CK,1 JZ INPUT

CALL COM ;调用排序子程序 MOV DL,0DH

MOV AH,02H ;调用DOS 02号功能,显示DL字符 INT 21H MOV DL,0AH MOV AH,02H INT 21H

LEA DX,STR3 ;调用DOS 09号功能,显示字符串STR3 MOV AH,09H INT 21H

CALL DISPY ;调用送显程序

RET

START ENDP

CHECK PROC ;检验子程序 NEXT1: MOV CK,0 MOV [DI],AH INC DI MOV [DI],DH INC DI CMP DH,39H JZ L1 INC DH JMP L2

L1: MOV DH,30H INC AH

L2: MOV AL,[BX] CMP AL,30H JB ERROR CMP AL,39H JA ERROR

MOV [DI],AL INC DI INC BX MOV AL,[BX] CMP AL,30H JB ERROR CMP AL,39H JA ERROR MOV [DI],AL INC DI INC BX INC CX MOV AL,[BX] CMP AL,0DH JZ FINISH1 INC BX JMP NEXT1

ERROR: LEA DX,STR2 ;调用DOS 09号功能,显示字符串STR2 MOV AH,9 INT 21H

MOV CK,1 FINISH1: RET

CHECK ENDP

COM PROC ;调用排序子程序COMP1: PUSH CX MOV VAR1,CX SHL CX,1 SHL CX,1 SUB CX,4 MOV VAR2,CX POP CX DEC DI DEC DI JMP COTI

COMP2: ADD DI,VAR2 COTI: MOV BL,0 MOV CX,VAR1 DEC CX

AGAN: MOV AL,[DI]