代码如下。。。。。。。。
DATA SEGMENT
XX DB 10, 9, 8, 7, 6, 5, 4, 3, 2,1, 0DH, 0AH, '$'
I DB 9
J DB 0
LASTXCHG DB ?
STACK SEGMENT
DB 100 DUP(?)
STACK ENDS
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
G: MOV LASTXCHG,0
MOV CL,I
LOP:
MOV AL,XX+J+1
MOV BL,XX+J
CMP XX+J+1,BL
JGE LE1
XCHG XX+J+1,BL
MOV XX+J,BL
LE1: MOV LASTXCHG,J
INC J
CMP J,I
JL LOP
MOV I,LASTXCHG
CMP I,0
JG G
MOV CX,10
MOV DX,OFFSET XX
MOV AH,09H
INT 21H
CODE ENDS
END START
LOOP LOP
JMP START
LE:MOV CX,10
MOV DX OFFSET XX
MOV AH,09H
INT 21H
CODE ENDS
END START
错误:
Microsoft (R) Macro Assembler Version 5.00
Copyright (C) Microsoft Corp 1981-1985, 1987. All rights reserved.
Object filename [1.OBJ]: link 1.obj
Cross-reference [NUL.CRF]:
1.asm(20): error A2039: One operand must be constant
1.asm(21): error A2039: One operand must be constant
1.asm(22): error A2039: One operand must be constant
1.asm(24): error A2039: One operand must be constant
1.asm(25): error A2039: One operand must be constant
1.asm(26): error A2052: Improper operand type
1.asm(28): error A2052: Improper operand type
1.asm(30): error A2052: Improper operand type
50040 + 416104 Bytes symbol space free
0 Warning Errors
8 Severe Errors
D:\1asm>
给一段相当精简的排序程序给你:
不过执行效率不是太好,应为有些字符串指令在里面有影响
CLD
MOV BX,N-1
NEXT1:LEA SI,NUM
MOV CX,BX
NEXT2:LODSB
CMP [SI],AL
JAE NEXT3
XCHG [SI],AL
MOV [SI-1],AL
NEXT3:LOOP NEXT2
DEC BX
JNE NEXT1
要显示的话,再加一段将数字转化为ASCALL的程序,
这个算是我以前弄得,
数字放在NUM里面,相当好用,当年我们考试的时候还考了这一段,
考试程序的一部分,短,读懂后思路也简单,冒泡排序