Guest User

Untitled

a guest
Aug 13th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %include "io.inc"
  2. section .bss
  3. a resd 11
  4. exist resd 11
  5. n resd 1
  6. m resd 1
  7. k resd 1
  8.  
  9. section .text
  10. global CMAIN
  11.  
  12. CMAIN:
  13. GET_UDEC 4, [n]
  14. GET_UDEC 4, [k]
  15. GET_UDEC 4, [m]
  16.  
  17. xor edx, edx; cur = edx
  18. xor edi, edi
  19.  
  20. push edi
  21. call GEN
  22. pop edi
  23.  
  24. xor eax, eax
  25. ret
  26.  
  27. GEN:
  28. push ebp
  29. mov ebp,esp
  30.  
  31. push ebx
  32. sub esp, 8
  33.  
  34. mov eax, [ebp + 8]
  35. cmp dword[k], eax
  36. jne L
  37.     inc edx
  38.     ; ++cur
  39.     cmp edx, dword[m]
  40.     ; if (cur == m)
  41.     jne .2
  42.             xor ecx, ecx
  43.             .4:
  44.             cmp ecx, dword[k]
  45.             jae .3
  46.                 mov ebx, dword[a + 4 * ecx]
  47.                 inc ebx
  48.                 PRINT_UDEC 4, ebx
  49.                 PRINT_CHAR ' '
  50.                 ; printf(a[i] + 1)
  51.                 inc ecx
  52.                 jmp .4
  53.                 .3:
  54.                 NEWLINE
  55.         .2:
  56.         jmp quit
  57. L:
  58. xor ecx, ecx
  59. cmp ecx, dword[n]
  60. jae quit
  61.         .6:
  62.         cmp dword[exist + 4 * ecx], 0
  63.         jne quit
  64.             mov dword[exist + 4 * ecx], 1
  65.             ; exist[i] = i
  66.            
  67.             mov eax, dword[ebp + 8]
  68.             mov dword[a + 4 * ecx], ecx
  69.             ; a[pos] = i
  70.            
  71.             inc eax
  72.             mov dword[esp + 4], ecx
  73.             mov dword[esp], eax
  74.             call GEN
  75.             mov ecx, dword[esp + 4]
  76.             ; gen(pos + 1)
  77.            
  78.             mov dword[exist + 4 * ecx], 0
  79.             ; exist[i] = 0
  80.             inc ecx
  81.             jmp .6
  82. quit:
  83.     add esp, 8
  84.     pop ebx
  85.     pop ebp
  86.     ret
Add Comment
Please, Sign In to add comment