Advertisement
Guest User

rip

a guest
May 24th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CPU 386
  2. GLOBAL permut
  3.  
  4.  
  5.  
  6. SECTION .data
  7.  
  8.  
  9. SECTION .text
  10.  
  11. permut:
  12.    
  13.     push ebp
  14.     mov ebp, esp
  15.  
  16.     mov ecx, [ebp + 12]; n
  17.     cmp ecx, 0
  18.     je afficher
  19.  
  20. loop1:
  21.     mov edx, [ebp + 8]      ; adresse du debut tableau
  22.     mov eax, [ebp+12]       ; n
  23.  
  24.     mov ebx, [(edx+eax*4)-4]; derniere elem du tableau
  25.     mov esi,[(edx+ecx*4)-4]; v[i]
  26.  
  27.     ;swap le ieme et le dernier
  28.     mov [edx + (eax*4)-4] , esi
  29.     mov [(edx+ecx*4)-4], ebx
  30.  
  31.     ;sauvegarde de contexte
  32.     push ecx;
  33.  
  34.     ;push param pour appeller permut
  35.     dec, eax; n-1
  36.     push eax
  37.     push edx; v
  38.  
  39.     ;appel recursif
  40.     call permut
  41.  
  42.     ; restaure le context
  43.     pop edx
  44.     pop eax
  45.     pop ecx
  46.  
  47.     mov eax, [ebp+12]
  48.  
  49.     mov esi; [edx+(ecx*4)-4]; v[i]
  50.     mov ebx, [(edx+eax*4)-4]; derniere elem du tableau
  51.  
  52.     mov [edx + (eax*4)-4] , esi
  53.     mov [(edx+ecx*4)-4], ebx
  54.  
  55.     loop loop1
  56.  
  57. afficher:
  58.     ;afficher
  59.     push BYTE[ebp +8]
  60.     call afficher
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement