Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "io.inc"
- section .rodata
- c db "%u", 0
- section .bss
- first resd 1
- num resd 1
- i resd 1
- section .text
- CEXTERN malloc
- CEXTERN realloc
- CEXTERN printf
- CEXTERN scanf
- global CMAIN
- CMAIN:
- push ebp
- mov ebp, esp
- and esp, -16 ;выравнивает, чтобы был кратен 16
- sub esp, 16
- mov dword[num], 8
- mov dword[i], 0
- mov dword[esp], 8
- call malloc
- .LOOP:
- mov dword[esp], c
- mov dword[esp + 4], first
- call scanf
- cmp dword[first], 0
- je .end
- mov edx, dword[i]
- cmp edx, dword[num]
- jl .skip
- mov edx, dword[num]
- add edx, 20
- mov dword[num], edx
- mov dword[esp], eax
- mov dword[esp + 4], edx
- call realloc
- mov ecx, eax
- .skip:
- lea ebx, [ecx + i]
- mov ebx, dword[first]
- mov ebx, dword[i]
- add ebx, 4
- mov dword[i], ebx
- jmp .LOOP
- .end:
- mov ebx, dword[ecx]
- PRINT_DEC 4, ebx
- mov esp, ebp
- pop ebp
- xor eax, eax
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement