Archived
1
0
Fork 0
This repository has been archived on 2022-06-20. You can view files and clone it, but cannot push or open issues or pull requests.
mipt_clang/nasm/I.asm
2022-03-31 17:53:59 +03:00

59 lines
667 B
NASM

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