Advertisement
anechka_ne_plach

Untitled

Nov 24th, 2021
1,505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         .text
  2.         .global partition, arr
  3. partition:
  4.         push    %ebp
  5.         mov     %esp, %ebp
  6.         sub     $4, %esp
  7.  
  8.         /*mov     (%edi), %eax
  9.         call    writei32*/
  10.  
  11.         // the second element for while
  12.         mov     %esi, -4(%ebp)
  13.         sub     $1, -4(%ebp)
  14.         mov     $0, %eax    
  15. while:
  16.         cmp     %eax, -4(%ebp)
  17.         jl      fin
  18.  
  19.         /*call    writei32
  20.         mov     %eax, %ecx
  21.         mov     -4(%ebp), %eax
  22.         call    writei32
  23.         mov     %ecx, %eax
  24.         mov     $0, %ecx*/
  25.  
  26.         mov     %eax, %ecx
  27.         mov     -4(%ebp), %eax
  28.         call    writei32
  29.         mov     %ecx, %eax
  30.         mov     $0, %ecx
  31.  
  32.         mov     (%ebx, %eax, 2), %cx
  33.  
  34.         /*mov     %eax, %edx
  35.         mov     $0, %eax
  36.         mov     %cx, %ax
  37.         call    writei32
  38.         mov     %edx, %eax*/
  39.  
  40.         cmp     (%edi), %ecx
  41.         jl      swap
  42.  
  43.         /*mov     %eax, %edx
  44.         mov     (%edi), %eax
  45.         call    writei32
  46.         mov     %edx, %eax*/
  47.  
  48.         inc     %eax
  49.         jmp     while
  50. swap:
  51.         mov     %eax, %edx
  52.         mov     $228, %eax
  53.         call    writei32
  54.         mov     %edx, %eax
  55.  
  56.         sub     $1, -4(%ebp)
  57.         jmp     while
  58. fin:
  59.         mov     %ebp, %esp
  60.         pop     %ebp
  61.         ret
  62.  
  63.         .global main
  64. main:
  65.         call    readi32
  66.         mov     %eax, %esi
  67.         mov     $0, %ebx
  68. readloop:
  69.         call    readi32
  70.         mov     %ax, arr(, %ebx, 2)
  71.         inc     %ebx
  72.         cmp     %esi, %ebx
  73.         jne     readloop
  74.         mov     $0, %ebx
  75.         call    readi32
  76.         mov     %eax, (%edi)
  77.         mov     $arr, %ebx
  78.         call    partition
  79. writeloop:
  80.         xor     %eax, %eax
  81.         mov     arr(, %ebx, 2), %ax
  82.         call    writei32
  83.         inc     %ebx
  84.         cmp     %esi, %ebx
  85.         jne     writeloop
  86. end:
  87.         mov     %edx, %eax
  88.         call    writei32
  89.         call    finish
  90.  
  91.         .data
  92. arr:
  93.         .skip 64
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement