效果:
STACK SEGMENT
STACK ENDS;本来打算用push和pop来交换元素的写到后面突然觉悟,好像用不到。。。
DATA SEGMENT
SHUZU DB 9,8,7,6,5,4,3,2,1,0
GESHU DW 10
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,SS:STACK
START:
MOV AX,STACK
MOV SS,AX
MOV AX,DATA
MOV DS,AX
MOV CX,GESHU
DEC CX
MOV SI,OFFSET SHUZU
LL:
CALL MPPX
MOV DL,0AH
MOV AH,02H
INT 21H
MOV DL,0DH
INT 21H
LOOP LL
MOV AH,4CH
INT 21H
MPPX PROC
PUSH CX
MOV SI,OFFSET SHUZU
MOV DI,OFFSET SHUZU
INC DI
MOV CX,GESHU
DEC CX
AA:
MOV AH,[SI]
MOV AL,[DI]
CMP AH,AL
JL NEXT
MOV [SI],AL
MOV [DI],AH
NEXT:
INC SI
INC DI
LOOP AA
CALL SHUCHU
POP CX
RET
MPPX ENDP
SHUCHU PROC
PUSH CX
MOV SI,OFFSET SHUZU
MOV CX,GESHU
XX:
MOV AH,02H
MOV DL,[SI]
ADD DL,30H
INT 21H
INC SI
LOOP XX
POP CX
RET
SHUCHU ENDP
CODE ENDS
END START
微机原理汇编小成.继续努力
|