Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global main
- extern printf
- extern scanf
- section .text
- read:
- mov ebx, esp
- sub ebx, 4
- push ebx
- push fmt_scanf
- call scanf
- pop eax
- pop eax
- ret
- main:
- call read
- mov edx, eax ; put number N to edx
- xor eax, eax
- mov ecx, edx
- loop:
- dec ecx
- push edx
- push ecx
- call read
- pop ecx
- pop edx
- push eax
- cmp ecx, 0
- jne loop
- mov ecx, edx
- L1:
- dec ecx
- pop eax ; number that i want to print now
- push ecx ; to save the counter
- push eax
- push fmt_printf
- call printf
- pop eax
- pop eax
- pop ecx
- xor eax,eax
- cmp ecx, 0
- jne L1
- xor eax, eax
- ret
- section .data
- here: db "here", 0x0A, 0
- fmt_scanf: db "%ld", 0
- fmt_printf: db "%ld ", 0
- fmt_printf_n: db "%ld", 0x0A, 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement