masm
.model small
.stack 100h
.data
mes1 db 'Vvedite massiv iz 10 simvolov',0ah,0dh,'$'
mes db 0ah,0dh,'Rezultat',0ah,0dh,'$'
pr db '$'
mas dw 39 dup (?)
mas1 dw 10 dup(?)
m dw ?
n equ 9
tmp dw 0
i dw 0
j dw 0
k dw 0
minus db '-$'
er db 'error$'
.code
main:
mov ax,@data
mov ds,ax
xor ax, ax
mov ah,09h
lea dx,mes1
int 21h
xor di,di
mov m,1
mov si,0
mov cx,10
cycl:
jcxz internal
xor ax,ax
mov ah,01h
int 21h
mov mas[si],ax
cmp al,minus
je k1
jne k2
k1:
mov m,-1
add si,2
jmp cycl
k2:
cmp al,20h
je k3
jne k4
k3:
add si,2
jmp cycl
k4:
mov dx,mas[si]
cmp dl,30h
jb k5
cmp dl,39h
ja k5
jbe k6
k5:
mov ah,09h
lea dx,er
int 21h
jmp cycl
k6:
sub dx,30h
shl dx,4
add si,2
mov ah,01h
int 21h
mov mas[si],ax
add dx,mas[si]
imul m
mov m,1
mov mas[di],dx
add di,2
add si,2
dec cx
jmp cycl
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]
jge bol
mov bx,i
shl bx,1
mov tmp,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,tmp
mov mas[bx],ax
bol:
dec j
cycl_j:
mov ax,j
cmp ax,i
jg exchange
inc i
cmp i,n
jl internal
show:
mov ah,09h
lea dx,mes
int 21h
add dl,30h
mov ah,02h
int 21h
mov ah,08h
int 21h
exit:
mov ax,4c00h
int 21h
end main