Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "io.inc"
- section .bss
- a resd 11
- exist resd 11
- n resd 1
- m resd 1
- k resd 1
- section .text
- global CMAIN
- CMAIN:
- GET_UDEC 4, [n]
- GET_UDEC 4, [k]
- GET_UDEC 4, [m]
- xor edx, edx; cur = edx
- xor edi, edi
- push edi
- call GEN
- pop edi
- xor eax, eax
- ret
- GEN:
- push ebp
- mov ebp,esp
- push ebx
- sub esp, 8
- mov eax, [ebp + 8]
- cmp dword[k], eax
- jne L
- inc edx
- ; ++cur
- cmp edx, dword[m]
- ; if (cur == m)
- jne .2
- xor ecx, ecx
- .4:
- cmp ecx, dword[k]
- jae .3
- mov ebx, dword[a + 4 * ecx]
- inc ebx
- PRINT_UDEC 4, ebx
- PRINT_CHAR ' '
- ; printf(a[i] + 1)
- inc ecx
- jmp .4
- .3:
- NEWLINE
- .2:
- jmp quit
- L:
- xor ecx, ecx
- cmp ecx, dword[n]
- jae quit
- .6:
- cmp dword[exist + 4 * ecx], 0
- jne quit
- mov dword[exist + 4 * ecx], 1
- ; exist[i] = i
- mov eax, dword[ebp + 8]
- mov dword[a + 4 * ecx], ecx
- ; a[pos] = i
- inc eax
- mov dword[esp + 4], ecx
- mov dword[esp], eax
- call GEN
- mov ecx, dword[esp + 4]
- ; gen(pos + 1)
- mov dword[exist + 4 * ecx], 0
- ; exist[i] = 0
- inc ecx
- jmp .6
- quit:
- add esp, 8
- pop ebx
- pop ebp
- ret
Add Comment
Please, Sign In to add comment