Archived
1
0
Fork 0

Merge branch 'private'

This commit is contained in:
nihonium 2022-04-08 12:16:09 +03:00
commit 98b3a21582
Signed by: nihonium
GPG key ID: 0924047F4136012C
22 changed files with 1088 additions and 0 deletions

32
nasm/D.asm Normal file
View file

@ -0,0 +1,32 @@
extern printf
extern scanf
global main
section .text
main:
push y
push x
push nya1
call scanf
add esp, 12
mov eax, [x]
;mov ebx, [y]
cdq
idiv dword [y]
push eax
push nya
call printf
add esp, 8
xor eax, eax
ret
section .data
nya db "%d", 10, 0
nya1 db "%d %d", 0
section .bss
x resd 1
y resd 1

32
nasm/E.asm Normal file
View file

@ -0,0 +1,32 @@
extern printf
extern scanf
global main
section .text
main:
push y
push x
push nya1
call scanf
add esp, 12
mov eax, [x]
;mov ebx, [y]
cdq
idiv dword [y]
push edx
push nya
call printf
add esp, 8
xor eax, eax
ret
section .data
nya db "%d", 10, 0
nya1 db "%d %d", 0
section .bss
x resd 1
y resd 1

44
nasm/G64.asm Normal file
View file

@ -0,0 +1,44 @@
global main
extern scanf
extern printf
section .text
main:
; scanf
sub rsp, 8
mov rdi, nya
mov rsi, x
mov rdx, y
call scanf wrt ..plt
add rsp, 8
; comparsion
mov rax, qword [rel x]
add rax, [rel y]
jb meow
push rbp
mov rdi, no
call printf wrt ..plt
pop rbp
jmp end
meow:
push rbp
mov rdi, yes
call printf wrt ..plt
pop rbp
end:
xor rax, rax
ret
section .data
nya dq "%llu %llu", 0
yes db "YES", 10, 0
no db "NO", 10, 0
section .bss
x resq 1
y resq 1

52
nasm/H.asm Normal file
View file

@ -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

59
nasm/I.asm Normal file
View file

@ -0,0 +1,59 @@
global main
extern printf
extern scanf
section .text
main:
; read N
push n
push read
call scanf
add esp ,8
; read loop for x
xor ebx, ebx
;mov bx, word [n]
loop1:
cmp bx, word [n]
je nya1
lea eax, [x + 2 * ebx]
dbg1: push eax
push read
call scanf
add esp, 8
dbg2: inc ebx
jmp loop1
nya1:
xor ebx, ebx
mov bx, word [n]
dec ebx
loop2:
cmp bx, 0
jl nya2
lea eax, [x + 2 * ebx]
;push word [eax]
mov dx, word [eax]
push edx
push write
call printf
add esp, 8
dec ebx
jmp loop2
nya2:
push EOL
call printf
add esp, 4
xor eax, eax
ret
section .data
read db "%hu", 0
write db "%hu ", 0
EOL db 10, 0
section .bss
n resw 1
x resw 10000

68
nasm/J.asm Normal file
View file

@ -0,0 +1,68 @@
global main
extern printf
extern scanf
extern qsort
section .text
main:
push n
push readn
call scanf
add esp, 8
xor ebx, ebx
loop1:
cmp ebx, dword [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]
push dword [eax]
push write
call printf
add esp, 8
inc ebx
jmp loop2
nya2:
xor eax, eax
ret
compare:
mov eax, [esp+4]
mov eax, dword [eax]
mov ebx, [esp + 8]
mov ebx, dword [ebx]
sub eax, ebx
ret
section .data
write db "%d ", 0
nya db "%d", 0
readn db "%d", 0
section .bss
n resd 1
x resd 10000

78
nasm/J1.asm Normal file
View file

@ -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

33
nasm/K.asm Normal file
View file

@ -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

34
nasm/K1.asm Normal file
View file

@ -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

30
nasm/M.asm Normal file
View file

@ -0,0 +1,30 @@
global main
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
scan db "%llf", 0
nya db "%llf", 10, 0
section .bss align=16
x rest 1

130
nasm/N.asm Normal file
View file

@ -0,0 +1,130 @@
global main
extern scanf
extern printf
<<<<<<< Updated upstream
section .text
main:
xor ebx, ebx
loop1:
cmp ebx, 8
jge nya1
inc ebx
; read element
lea edx, [a + 1*ebx]
push edx
push template
call scanf
add esp, 8
push word [edx]
push output
call printf
add esp, 8
jmp loop1
nya1:
; xor ebx, ebx
;
;loop2:
; cmp ebx, 8
; jge nya2
; inc ebx
;
; ; read element
; push b
; push template
; call scanf
; add esp, 8
;
; jmp loop1
;
;nya1:
; xor ebx, ebx
;loop3:
; output
; push word [a]
; push output
; call printf
; add esp, 8
xor eax, eax
ret
section .data
template db "%d", 0
output db "%d", 10, 0
t db "%d", 10, 0
section .bss
a resw 8
b resw 8
=======
section .text
main:
xor ebx, ebx
loop1:
cmp ebx, 8
je nya1
lea eax, [a + ebx]
push eax
push input
call scanf
add esp, 8
inc ebx
jmp loop1
nya1:
xor ebx, ebx
loop2:
cmp ebx, 8
je nya2
lea eax, [b + ebx]
push eax
push input
call scanf
add esp, 8
inc ebx
jmp loop2
nya2:
movq mm0, [a]
movq mm1, [b]
paddsb mm0, mm1
movq [a], mm0
xor ebx, ebx
loop3:
cmp ebx, 8
je nya3
lea eax, [a + ebx]
mov dl, byte [eax]
push edx
push output
call printf
add esp, 8
inc ebx
jmp loop3
nya3:
push EOL
call printf
add esp, 4
dbg: xor eax, eax
ret
section .data
input dd "%hhu", 0
output dd "%hhu ", 0
EOL dd 10
section .bss
a resb 8
b resb 8
>>>>>>> Stashed changes

30
nasm/O.asm Normal file
View file

@ -0,0 +1,30 @@
global _start
section .text
_start:
; input
mov eax, 3
xor ebx, ebx
mov ecx, nya
mov edx, 1
int 0x80
; modification
mov ax, word [nya]
or ax, 0111b
mov [nya], ax
; output
mov eax, 4
mov ebx, 1
mov ecx, nya
mov edx, 1
int 0x80
; program exit
mov eax, 1 ; sys_exit = 1
xor ebx, ebx
int 0x80
section .bss
nya resb 1