汇编实现0-9数字的排序(由小到大)

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值