SHARE
TWEET

Untitled

Dari_ Apr 14th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %include "io.inc"
  2.  
  3. section .rodata
  4.     c db "%u", 0
  5. section .bss
  6.     first resd 1
  7.     num resd 1
  8.     i resd 1
  9. section .text
  10.     CEXTERN malloc
  11.     CEXTERN realloc
  12.     CEXTERN printf
  13.     CEXTERN scanf
  14.  
  15. global CMAIN
  16. CMAIN:
  17.     push ebp
  18.     mov ebp, esp
  19.     and esp, -16 ;выравнивает, чтобы был кратен 16
  20.     sub esp, 16
  21.    
  22.     mov dword[num], 8
  23.     mov dword[i], 0
  24.     mov dword[esp], 8
  25.     call malloc
  26.    
  27.     .LOOP:
  28.     mov dword[esp], c
  29.     mov dword[esp + 4], first
  30.     call scanf
  31.    
  32.     cmp dword[first], 0
  33.     je .end
  34.     mov edx, dword[i]
  35.     cmp edx, dword[num]
  36.     jl .skip
  37.    
  38.     mov edx, dword[num]
  39.     add edx, 20
  40.     mov dword[num], edx
  41.     mov dword[esp], eax
  42.     mov dword[esp + 4], edx
  43.     call realloc
  44.     mov ecx, eax
  45.     .skip:
  46.     lea ebx, [ecx + i]
  47.     mov ebx, dword[first]
  48.     mov ebx, dword[i]
  49.     add ebx, 4
  50.     mov dword[i], ebx
  51.    
  52.     jmp .LOOP
  53.     .end:
  54.    
  55.     mov ebx, dword[ecx]
  56.     PRINT_DEC 4, ebx
  57.    
  58.    
  59.    
  60.     mov esp, ebp
  61.     pop ebp    
  62.     xor eax, eax
  63.     ret
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top