Professional Documents
Culture Documents
Assembly
Assembly
Assembly
section .data
numbers db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ;
count dw 0 ;
section .text
global _start
add_number:
mov eax, 3 ;
mov edx, 2 ;)
int 0x80 ;
je end_add_number
jl add_number
inc ax ; 1
mov [count], ax ;
jmp add_number ;
end_add_number:
ret
sort_numbers:
dec ax ;
mov bx, ax ; bx
outer_loop:
mov cx, bx ; cx
inner_loop:
jl swap ;
dec cx ;
cmp cx, 1 ;
jg inner_loop ;
dec bx ;
cmp bx, 0 ;
jg outer_loop ;
jmp end_sort_numbers ;
swap:
dec cx ;
cmp cx, 1 ;
jg inner_loop ;
jmp outer_loop ;
end_sort_numbers:
ret
calculate_statistics:
mov bx, 0 ;
loop_sum:
inc si ;
dec ax ;
jnz loop_sum ;
shl ax, 16 ;
div [count] ;
mov bx, ax ;
mov eax, 4 ;
mov ebx, 1 ;
mov edx, 14 ;
int
0x80 ;
mov eax, 4 ;
mov ebx, 1 ;
mov edx, 1 ;
int 0x80 ;
mov eax, 4 ;
mov ebx, 1 ;
mov edx, 14 ;
int 0x80 ;
mov eax, 4 ;
mov ebx, 1 ;
mov ecx, dx ;
mov edx, 1 ;
int 0x80 ;
mov eax, 4 ;
mov ebx, 1 ;
mov edx, 5 ;
int 0x80 ;
mov eax, 4 ;
mov ebx, 1 ;
mov ecx, bx ;
mov edx, 1 ;
int 0x80 ;
mov eax, 4 ;
mov ebx, 1 ;
mov edx, 8 ;
int 0x80 ;
mov eax, 4 ;
mov ebx, 1 ;
mov ecx, bx ;
mov edx, 1 ;
int 0x80 ;
end_calculate_statistics:
ret
_start:
call add_number ;
call sort_numbers ;
call calculate_statistics ;
mov eax, 1 ;
int 0x80 ;
section .data
```