nihonium
/
mipt_clang
Archived
1
0
Fork 0
master
nihonium 3 years ago
parent adba0bfac6
commit 4fd1a7ed9e
No known key found for this signature in database
GPG Key ID: 0924047F4136012C

@ -5,59 +5,64 @@ extern qsort
section .text
main:
; read N
push n
push readn
call scanf
add esp ,8
add esp, 8
; read loop for x
xor ebx, ebx
loop1:
cmp bx, word [n]
cmp ebx, dword [n]
je nya1
lea eax, [x + 2 * ebx]
dbg1: push eax
lea eax, [x + 4 * ebx]
push eax
push nya
call scanf
add esp, 8
dbg2: inc ebx
jmp loop1
add esp, 8
inc ebx
jmp loop1
nya1:
push compare
push dword 2
push dword 4
push dword [n]
push x
;push x
;push dword [n]
;push dword 2 ; size of element
;push compare
call qsort
add esp, 16
xor ebx, ebx
loop2:
cmp ebx, dword [n]
je nya2
lea eax, [x + 4 * ebx]
push dword [eax]
push write
call printf
add esp, 8
inc ebx
jmp loop2
nya2:
xor eax, eax
ret
compare:
;mov ebp, esp
;sub esp, 16
;pop eax
;pop ebx
;push ebp
;mov ebp, esp
mov eax, dword [esp + 4]
;lea ebx, [ebp - 2]
;mov ebx, [esp + 8]
sub eax, [esp + 8]
mov eax, [esp+4]
mov eax, dword [eax]
mov ebx, [esp + 8]
mov ebx, dword [ebx]
sub eax, ebx
ret
section .data
nya db "%hu", 0
write db "%d ", 0
nya db "%d", 0
readn db "%d", 0
section .bss
n resd 1
x resw 10000
x resd 10000

@ -0,0 +1,78 @@
global main
extern printf
extern scanf
extern qsort
section .text
main:
; read N
push n
push readn
call scanf
add esp ,8
; read loop for x
xor ebx, ebx
loop1:
cmp bx, word [n]
je nya1
lea eax, [x + 4 * ebx]
push eax
push nya
call scanf
add esp, 8
inc ebx
jmp loop1
nya1:
push compare
push dword 4
push dword [n]
push x
call qsort
add esp, 16
xor ebx, ebx
loop2:
cmp ebx, dword [n]
je nya2
lea eax, [x + 4 * ebx]
xor edx, edx
mov edx, dword [eax]
push edx
push write
call printf
add esp, 8
inc ebx
jmp loop2
nya2:
xor eax, eax
ret
compare:
xor edx, edx
xor ecx, ecx
lea eax, [esp+4]
mov eax, [eax]
mov ecx, dword [eax]
lea ebx, [esp+8]
mov ebx, [ebx]
mov edx, dword [ebx]
sub ecx, edx
;mov ax, cx
;cwde
mov eax, ecx
ret
section .data
write db "%d ", 0
nya db "%d", 0
readn db "%d", 0
section .bss
n resd 1
x resd 10000

@ -0,0 +1,34 @@
global main
extern scanf
extern printf
section .text
main:
push y
push x
push scan
call scanf
add esp, 12
fld tword [x]
fld tword [y]
fdiv
sub esp, 12
fstp tword [esp]
push nya
call printf
add esp, 16
xor eax, eax
ret
section .data
scan db "%llf%llf", 0
nya db "%llf", 10, 0
section .bss align=16
x rest 1
resw 1
y rest 1

@ -1,12 +1,30 @@
global main
extern printf
extern scanf
extern printf
section .text
main:
push x
push scan
call scanf
add esp, 8
fld tword [x]
fabs
sub esp, 12
fstp tword [esp]
push nya
call printf
add esp, 16
xor eax, eax
ret
section .data
in "%f", 0
out "%f", 10, 0
scan db "%llf", 0
nya db "%llf", 10, 0
section .bss align=16
x rest 1