DATAS SEGMENT
STRING DB 'Please input number:',13,10,'$'
STRING2 DB 'after numbers:',13,10,'$'
ARRAY DB 0,0,0,0,0,0,0,0,0,0,0,0,0,'$'
COUNT DW 0
DATAS ENDS
STACKS SEGMENT PARA STACK
DD 128 DUP(0)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
LEA AX,STRING
CALL DISPSTRING
CALL READNUMBER
LEA AX,STRING2
CALL DISPSTRING
CALL PAIXU
CALL PRINT
READNUMBER PROC
LEA SI,ARRAY
MOV CX,0
FLAG1:
MOV AH,01H
INT 21H
CMP AL,13
JZ R
SUB AL,30H
MOV [SI],AL
INC SI
INC CX
JMP FLAG1
R:
MOV COUNT,CX
RET
READNUMBER ENDP
PAIXU PROC
PUSH AX
PUSH CX
PUSH SI
MOV CX,COUNT
DEC CX
LOPSEX:
PUSH CX
XOR SI,SI
LOPSIN:
MOV AH,ARRAY[SI]
MOV AL,ARRAY[SI+1]
CMP AH,AL
JBE CC
XCHG AH,AL
CC:
MOV ARRAY[SI],AH
MOV ARRAY[SI+1],AL
INC SI
LOOP LOPSIN
POP CX
LOOP LOPSEX
POP SI
POP CX
POP AX
RET
PAIXU ENDP
DISPSTRING PROC
汇编实现0-9数字的排序(由小到大)
最新推荐文章于 2023-04-25 15:06:46 发布