Advertisement
Slapoguzov

Lab3_LSP

Nov 20th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .686
  2. include libc.inc
  3. .model flat
  4.  
  5.  
  6. public _sort_gen_asm
  7. public _print_array
  8.  
  9. data segment "data"
  10.  
  11. format db "%d", 10,13,0
  12.  
  13.  
  14. data ends
  15.  
  16. text segment "code"
  17.  
  18. _sort_gen_asm_arg1 = 8
  19. _sort_gen_asm_arg2 = 12
  20. _print_array_arg1 = 8
  21. _print_array_arg2 = 12
  22.  
  23. _sort_gen_asm PROC
  24.     push ebp
  25.     mov ebp, esp
  26.     push esi
  27.     push edi
  28.    
  29.     mov edi, DWORD PTR _sort_gen_asm_arg1[ebp]
  30.     xor esi, esi
  31.     cmp DWORD PTR [edi], esi
  32.     jbe SHORT LN4
  33.     push ebx
  34.     mov ebx, DWORD PTR _sort_gen_asm_arg2[ebp]
  35. LL5:
  36.     test esi, esi
  37.     je  SHORT LN2
  38.  
  39.     mov eax, DWORD PTR [edi+4]
  40.     lea eax, DWORD PTR [eax+esi*4]
  41.  
  42.     push    eax
  43.     add eax, -4                
  44.     push    eax
  45.     call    ebx
  46.     add esp, 8
  47.     cmp eax, -1
  48.     je  SHORT LN2
  49.  
  50.     mov eax, DWORD PTR [edi+4]
  51.     lea eax, DWORD PTR [eax+esi*4]
  52.  
  53.     push    eax
  54.     add eax, -4                
  55.     push    eax
  56.     call    ebx
  57.     add esp, 8
  58.     test    eax, eax
  59.     je  SHORT LN2
  60.  
  61.     mov eax, DWORD PTR [edi+4]
  62.     mov edx, DWORD PTR [eax+esi*4]
  63.     lea ecx, DWORD PTR [eax+esi*4]
  64.  
  65.     mov eax, DWORD PTR [ecx-4]
  66.     mov DWORD PTR [ecx], eax
  67.  
  68.     mov eax, DWORD PTR [edi+4]
  69.     mov DWORD PTR [eax+esi*4-4], edx
  70.  
  71.     dec esi
  72.     jmp SHORT LN1
  73. LN2:
  74.     inc esi
  75. LN1:
  76.     cmp esi, DWORD PTR [edi]
  77.     jb  SHORT LL5
  78.     pop ebx
  79. LN4:
  80.     pop edi
  81.     pop esi
  82.  
  83.     pop ebp
  84.     ret 0
  85. _sort_gen_asm ENDP
  86.  
  87. _print_array PROC
  88.  
  89.     push ebp
  90.     mov ebp, esp
  91.  
  92.    
  93.     mov ebx, _print_array_arg1[ebp]
  94.     mov ecx, _print_array_arg2[ebp]
  95.     test ecx, ecx
  96.     je exit
  97.     mov edx, 0
  98.  
  99. loopchik:
  100.     push edx
  101.     push ecx   
  102.     push  [ebx+edx]
  103.     push offset format
  104.     call _printf
  105.     add esp, 8
  106.     pop ecx
  107.     pop edx
  108.     add edx, 4
  109. loop loopchik
  110. exit:
  111.     mov esp, ebp
  112.     pop ebp
  113.  
  114.     ret
  115. _print_array ENDP
  116.  
  117. text ends
  118.  
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement