From bd66b63a05b2852a76df2e44bb8ea0cf6f02d62b Mon Sep 17 00:00:00 2001 From: nihonium Date: Thu, 31 Mar 2022 17:53:59 +0300 Subject: [PATCH] I,M,N --- nasm/I.asm | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ nasm/M.asm | 12 +++++++++++ nasm/N.asm | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 nasm/I.asm create mode 100644 nasm/M.asm diff --git a/nasm/I.asm b/nasm/I.asm new file mode 100644 index 0000000..1e4dbad --- /dev/null +++ b/nasm/I.asm @@ -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 diff --git a/nasm/M.asm b/nasm/M.asm new file mode 100644 index 0000000..e4a8780 --- /dev/null +++ b/nasm/M.asm @@ -0,0 +1,12 @@ +global main +extern printf +extern scanf + +section .text + + xor eax, eax + ret + +section .data +in "%f", 0 +out "%f", 10, 0 diff --git a/nasm/N.asm b/nasm/N.asm index 461edfe..2b8e0aa 100644 --- a/nasm/N.asm +++ b/nasm/N.asm @@ -2,6 +2,7 @@ global main extern scanf extern printf +<<<<<<< Updated upstream section .text main: @@ -66,3 +67,64 @@ 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