You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
667 B
NASM
60 lines
667 B
NASM
3 years ago
|
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
|