assume CS: code, DS: data
code segment
begin:
mov AX, data
mov DS, AX
mov AH, 09h
mov DX, offset mes1
int 21h
mov cx,10
mov si,0
show_primary:
mov dx,mas[si]
add dl,30h
mov ah,02h
int 21h
add si,2
loop show_primary
internal:
mov j,9
jmp cycl_j
exchange:
mov bx,i
shl bx,1
mov ax,mas[bx]
mov bx,j
shl bx,1
cmp ax,mas[bx]
jle lesser
mov bx,i
shl bx,1
mov temp,ax
mov bx,j
shl bx,1
mov ax,mas[bx]
mov bx,i
shl bx,1
mov mas[bx],ax
mov bx,j
shl bx,1
mov ax,temp
mov mas[bx],ax
lesser:
dec j
cycl_j:
mov ax,j
cmp ax,i
jg exchange
inc i
cmp i,n
jl internal
mov AH, 09h
mov DX, offset mes2
int 21h
mov cx,10
mov si,0
show:
mov dx,mas[si]
add dl,30h
mov ah,02h
int 21h
add si,2
loop show
mov AH, 08h
int 21h
mov AH, 4Ch
mov AL, 00h
int 21h
code ends
data segment
mes1 db 'Primary Massiv:$',10,13
mes2 db 'Massiv After Sorted:$'
n equ 9
mas dw 2,7,4,0,1,9,3,6,5,8
i dw 0
j dw 0
temp dw 0
data ends
stk segment stack
dw 128 dup (0)
stk ends
end begin
Сортировка в соответствии с ASCII кодом |