汇编语言冒泡排序,怎么masm,link完生成的exe执行起来没有答案?
DATASEGMENTADB8,1,2,7,6,3,2,5,4,3DATAENDSCSEGSEGMENTASSUMECS:CSEG,DS:DATASTART:MOVAX,...
DATA SEGMENT
A DB 8,1,2,7,6,3,2,5,4,3
DATA ENDS
CSEG SEGMENT
ASSUME CS:CSEG,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV CX,10
DEC CX
LOOP1: MOV DI,CX
MOV BX,0
LOOP2: MOV AL,A[BX]
CMP AL,A[BX+1]
JGE CONTINUE
XCHG AL,A[BX+1]
MOV A[BX],AL
CONTINUE: ADD BX,1
LOOP LOOP2
MOV CX,DI
LOOP LOOP1
MOV AH,1
INT 21H
MOV AX,4CH
INT 21H
CSEG ENDS
END START 展开
A DB 8,1,2,7,6,3,2,5,4,3
DATA ENDS
CSEG SEGMENT
ASSUME CS:CSEG,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV CX,10
DEC CX
LOOP1: MOV DI,CX
MOV BX,0
LOOP2: MOV AL,A[BX]
CMP AL,A[BX+1]
JGE CONTINUE
XCHG AL,A[BX+1]
MOV A[BX],AL
CONTINUE: ADD BX,1
LOOP LOOP2
MOV CX,DI
LOOP LOOP1
MOV AH,1
INT 21H
MOV AX,4CH
INT 21H
CSEG ENDS
END START 展开
1个回答
展开全部
你的退出语句错误,应该是mov ax,4c00h
另外,由于没有输出语句,所以程序没有结果显示出来,为便于检查结果,下面将你的程序改写为com文件格式的程序,便于在debug中调试检查结果是否正确:
CSEG SEGMENT
ASSUME CS:CSEG,DS:cseg,es:cseg
org 100h
start: jmp start1
A DB 8,1,2,7,6,3,2,5,4,3
START1:
push cs
pop ds
push cs
pop es
MOV CX,10
DEC CX
LOOP1: MOV DI,CX
MOV BX,offset a
LOOP2: MOV AL,es:[BX]
CMP AL,es:[BX+1]
JGE CONTINUE
XCHG AL,es:[BX+1]
MOV es:[BX],AL
CONTINUE: ADD BX,1
LOOP LOOP2
MOV CX,DI
LOOP LOOP1
MOV AH,1
INT 21H
int 20h
CSEG ENDS
END START
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询