sseg segment stack 'stack'
dw 256 dup(?)
sseg ends
data segment
str1 db 10,13,'Telephone: $'
str2 db 10,13,'Name: $'
str3 db 10,13,'Sort array of record: $'
mes db 10,13,'Nosort array of record: $'
spacer db 10,13,'Press ENTER $'
telephone struc
name_ db 256 dup(0)
number_ dd ?
ends
tempstr db 256 dup(0)
mas_tel telephone <"Name1",567878>
telephone <"Name2",435654>
telephone <"Name3",342345>
telephone <"Name4",123456>
telephone <"Name5",431233>
telephone <"Name6",123434>
telephone <"Name7",128978>
telephone <"Name8",346467>
telephone <"Name9",128888>
telephone <"Name10",345656>
temp dd ?
data ends
code segment
assume cs:code,ds:data,es:data,ss:sseg
start: mov ax,data
mov ds,ax
mov es,ax
.386
call begin_init
mov cx,10
mov dx,offset mes
mov ah,09h
int 21h
call output_telephone
lea dx,spacer
mov ah,09h
int 21h
mov ah,1h
int 21h
mov cx,9
call begin_init
sortirovka: call sort
call begin_init
loop sortirovka
call begin_init
mov cx,10
push ax
push dx
mov dx,offset str3
mov ah,09h
int 21h
pop dx
pop ax
call output_telephone
mov ah,4ch
int 21h
output_telephone proc
o_tel: lea dx,str2
mov ah,09h
int 21h
lea si,[di].name_
dalee1:
lodsb
cmp al,0
jle exit
mov dl,al
mov ah,02h
int 21h
jmp dalee1
exit:
lea dx,str1
mov ah,9h
int 21h
mov eax,[di].number_
push ecx
xor ecx,ecx
push ebx
mov ebx,10
loop1: xor edx,edx
div ebx
add dl,30h
push dx
inc cl
cmp eax,ebx
jnl loop1
add al,30h
push ax
inc cl
xor eax,eax
mov ah,02h
loop2: pop dx
int 21h
loop loop2
pop ebx
pop ecx
add di,bx
loop o_tel
ret
output_telephone endp
begin_init proc
mov bx,type telephone
lea di,mas_tel
ret
begin_init endp
input_tel proc
push eax
push ebx
push ecx
push edx
xor eax,eax
xor edx,edx
mov cx,6
mov bx,10
mov temp,00000000h
comon: xor eax,eax
mov ah,1h
int 21h
sub al,30h
mov ah,00h
add edx,eax
mov eax,edx
push edx
xor edx,edx
mul ebx
pop edx
mov edx,eax
loop comon
xor edx,edx
div ebx
mov temp,eax
pop edx
pop ecx
pop ebx
pop eax
ret
input_tel endp
sort proc
push cx
L1: mov eax,[di].number_
mov edx,[di+bx].number_
cmp eax,edx
jl dalee
mov [di].number_,edx
mov [di+bx].number_,eax
; а в этом месте должен быть следующий обмен
; tempstr <- [di].name_
; [di].name_ <- [di+bx].name_
; [di+bx].name_ <- tempstr
; а как это сделать не знаю
dalee:
add di,bx
loop L1
pop cx
ret
sort endp
code ends
end start