汇编97,78,-1,0,32,14,21,27,-20,99 从小到大进行排序 然后逐位加5并输出显示 有知道的吗DATA SEGMENTA DB 97,78,-1,0,32,14,21,27,-20,99B DB 5,5,5,5,5,5,5,5,5,5D DB 10 DUP(?)N EQU 10LEN EQU $-ADATA ENDSCODE SEGMENTASSUME CS:CODE,DS:
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 07:39:44
汇编97,78,-1,0,32,14,21,27,-20,99 从小到大进行排序 然后逐位加5并输出显示 有知道的吗DATA SEGMENTA DB 97,78,-1,0,32,14,21,27,-20,99B DB 5,5,5,5,5,5,5,5,5,5D DB 10 DUP(?)N EQU 10LEN EQU $-ADATA ENDSCODE SEGMENTASSUME CS:CODE,DS:
汇编97,78,-1,0,32,14,21,27,-20,99 从小到大进行排序 然后逐位加5并输出显示 有知道的吗
DATA SEGMENT
A DB 97,78,-1,0,32,14,21,27,-20,99
B DB 5,5,5,5,5,5,5,5,5,5
D DB 10 DUP(?)
N EQU 10
LEN EQU $-A
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MOV CH,LEN
DEC CH
LOP0:MOV SI,OFFSET A
MOV CL,CH
XOR BL,BL
LOP1:MOV AL,[SI]
CMP AL,[SI+1]
JLE NEXT
XCHG AL,[SI+1]
MOV [SI],AL
OR BL,01H
NEXT:INC SI
DEC CL
JNZ LOP1
AND BL,BL
JZ ADD1
DEC CH
JNZ LOP0
ADD1:
MOV SI,OFFSET A
MOV DI,OFFSET B
MOV BX,OFFSET D
CLC
ADD2:MOV AL,[SI]
ADC AL,[DI]
DAA
MOV [BX],AL
INC SI
INC DI
INC BX
LOOP NEXT
MOV AH,2CH
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
这个调试的话回出现错误.
不好意思.分没有了.帮助的话以后一定补上
汇编97,78,-1,0,32,14,21,27,-20,99 从小到大进行排序 然后逐位加5并输出显示 有知道的吗DATA SEGMENTA DB 97,78,-1,0,32,14,21,27,-20,99B DB 5,5,5,5,5,5,5,5,5,5D DB 10 DUP(?)N EQU 10LEN EQU $-ADATA ENDSCODE SEGMENTASSUME CS:CODE,DS:
Output macro X
mov dx,offset X
mov ah,9
int 21h
EndM
;
STACKS SEGMENT STACK ;堆栈段
DW 128 DUP(?) ;注意这里只有128个字节
STACKS ENDS
;
DATAS SEGMENT;数据段
Old db 13,10,9,'Old:$'
Num DB 97,78,-1,0,32,14,21,27,-20,99
New db 13,10,9,'New:$'
DATAS ENDS
;
CODES SEGMENT;代码段
ASSUME CS:CODES,DS:DATAS
START:MOV AX,DATAS ;初始化
MOV DS,AX
Output Old
call Show
call Sort
call @ADD
Output New
call Show
mov ah,7
int 21h
MOV AX,4C00H ;退出程序
INT 21H
Show:;逐位输出显示
mov si,offset Num
mov cx,10
next1:lodsb
cbw
call crt
mov ax,0e20h
int 10h
loop next1
ret
Sort:;从小到大进行排序
MOV CX,10 ;内循环变量存于CX中,初值为N-1
DEC CX
LOOP1:
MOV DI,CX ;外循环变量存于DI中,初值为N-1
MOV BX,0;地址指针置为0
LOOP2:
MOV Al,Num[BX] ;取相邻两数比较
CMP Al,Num[BX+1]
JLE CONT ;被减数不大于减数则转移
XCHG Al,Num[BX+1] ;不符合,交换
MOV Num[BX],Al ;存大数
CONT:
INC BX ;修改地址指针
LOOP LOOP2 ;若一遍未比较完,继续
MOV CX,DI
LOOP LOOP1 ;若N-1遍未作完,继续
RET
@ADD:;然后逐位加5
mov si,offset Num
mov cx,10
mov al,5
next2:
add [si],al
inc si
loop next2
ret
;
crt:;输出一个字数据
push dx
push cx
push bx
or ax,ax
jns @div
push ax
mov al,'-' ;输出负号
mov ah,0eh
int 10h
pop ax
neg ax ;求补
@div:xor cx,cx
mov bx,10
nx1:xor dx,dx
div bx
or dx,0e30h
push dx
inc cx
cmp ax,0
jnz nx1
nx2:pop ax
int 10h
loop nx2
pop bx
pop cx
pop dx
ret
CODES ENDS
END START