Facebook
From Ample Zebra, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 72
  1.  
  2. .intel_syntax noprefix
  3. .section .data
  4.  
  5. .section .text
  6. .global feladat
  7. feladat: // int feladat(int* array, int length, int* output)
  8.     push ebp
  9.     mov ebp, esp
  10.  
  11.     push ebx    //loop counter
  12.     push ecx    //result counter
  13.     push edx
  14.     push esi
  15.     push edi
  16.  
  17.     mov esi, [ebp + 4*2]    // int* array => esi
  18.     mov edx, [ebp + 4*3]    // int length => ecx
  19.     mov edi, [ebp + 4*4]    // int* output => edi
  20.        
  21.         mov ebx,0       //loop counter
  22.         mov ecx,0       //result counter
  23. loop:
  24.         cmp ebx, ecx  
  25.         jge end
  26.        
  27.         cmp 2,[esi+ebx*4]       //bemenet[i]>=2
  28.         jge NAGYOBB
  29.  
  30.         inc ebx         //i++
  31.         jmp loop
  32.        
  33. NAGYOBB: //bemenet[i]>=2
  34.         mov edi[ecx*4],[esi+ebx*4]      //kimenet[szamlalo]=bemenet[i]
  35.         add ecx,1               //szamalo novelese
  36.         inc ebx         //i++
  37.         jmp loop
  38.  
  39.        
  40. end:    //ha nagyobb vagy egyenlÅ‘ mint a length
  41.     mov eax, ecx              // result!
  42.  
  43.     pop edi
  44.     pop esi
  45.     pop edx
  46.     pop ecx
  47.     pop ebx
  48.  
  49.     mov esp, ebp
  50.     pop ebp
  51.     ret