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

@ -0,0 +1,52 @@
global main
extern printf
extern scanf
section .text
main:
push x
push nya
call scanf
add esp, 8
push y
push nya
call scanf
add esp, 8
mov ebx, dword [x] ; a
mov ecx, dword [y] ; b
loop:
cmp ecx, 0 ; compare b
je end
mov eax, ebx ; move a to eax
cdq
div ecx ; a / b, remain in edx
mov ebx, ecx ; a = b
mov ecx, edx ; b = remain
jmp loop
end:
mov eax, dword [x]
mul dword [y]
cdq
div ebx
push eax
push nya
call printf
add esp, 8
xor eax, eax
ret
section .data
nya db "%u", 0
section .bss
x resd 1
y resd 1

@ -0,0 +1,63 @@
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 + 2 * ebx]
dbg1: push eax
push nya
call scanf
add esp, 8
dbg2: inc ebx
jmp loop1
nya1:
push compare
push dword 2
push dword [n]
push x
;push x
;push dword [n]
;push dword 2 ; size of element
;push compare
call qsort
add esp, 16
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]
ret
section .data
nya db "%hu", 0
readn db "%d", 0
section .bss
n resd 1
x resw 10000

@ -0,0 +1,33 @@
global main
extern scanf
extern printf
section .text
main:
push y
push x
push scan
call scanf
add esp, 12
fld dword [x]
fld dword [y]
fdiv
sub esp, 8
fst qword [esp]
push nya
call printf
add esp, 12
xor eax, eax
ret
section .data
scan db "%f%f", 0
nya db "%f", 10, 0
section .bss
x resd 1
y resd 1