Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "io.inc"
- section .bss
- N resd 1
- K resd 1
- m resd 1
- r resd 1
- res resd 1
- deg resd 1
- prom resd 1
- i resd 1
- section .text
- global CMAIN
- CMAIN:
- GET_DEC 4, [N]
- GET_DEC 4, [K]
- mov dword[m], 0
- mov dword[deg], 1
- mov dword[res], 0
- .ret:
- mov esi, dword[deg]
- cmp esi, dword[N]
- jg .st
- mov eax, dword[deg]
- mov esi, 2
- mul esi
- mov dword[deg], eax
- inc dword[m]
- jmp .ret
- .st:
- mov eax, dword[deg]
- mov esi, 2
- div esi
- mov dword[deg], eax
- dec dword[m]
- PRINT_DEC 4, [m]
- NEWLINE
- LOOP:
- mov dword[prom], 1
- mov ebp, 1
- inc dword[m]
- .ret1:
- cmp ebp, dword[m]
- je .factor
- mov eax, dword[prom]
- mul ebp
- mov dword[prom], eax
- inc ebp
- jmp .ret1
- .factor:
- PRINT_DEC 4, [prom]
- NEWLINE
- dec dword[m]
- mov ebp, 1
- mov esi, dword[K]
- add esi, 2
- .ret2:
- cmp ebp, esi
- je .factor1
- mov eax, dword[prom]
- div ebp
- mov dword[prom], eax
- inc ebp
- jmp .ret2
- .factor1:
- mov ebp, 1
- mov esi, dword[m]
- sub esi, dword[K]
- dec esi
- add esi, 2
- .ret3:
- cmp ebp, esi
- je .factor2
- mov eax, dword[prom]
- div ebp
- mov dword[prom], eax
- inc ebp
- jmp .ret3
- .factor2:
- mov esi, dword[res]
- add esi, dword[prom]
- mov dword[res], esi
- PRINT_DEC 4, [res]
- NEWLINE
- mov ebx, dword[N]
- sub ebx, dword[deg]
- mov dword[r], 0
- mov dword[prom], 1
- .ret:
- mov esi, dword[prom]
- cmp esi, ebx
- jg .st
- mov eax, dword[prom]
- mov esi, 2
- mul esi
- mov dword[prom], eax
- inc dword[r]
- jmp .ret
- .st:
- mov eax, dword[prom]
- mov esi, 2
- div esi
- mov dword[prom], eax
- dec dword[r]
- PRINT_DEC 4, [K]
- PRINT_STRING ' = K'
- NEWLINE
- mov esi, dword[K]
- sub esi, dword[m]
- add esi, dword[r]
- inc esi
- mov dword[K], esi
- PRINT_DEC 4, [K]
- PRINT_STRING ' = K'
- NEWLINE
- mov esi, dword[r]
- mov dword[m], esi
- PRINT_DEC 4, [m]
- PRINT_STRING ' = m'
- NEWLINE
- mov dword[N], ebx
- PRINT_DEC 4, [N]
- PRINT_STRING ' = N'
- NEWLINE
- mov esi, dword[K]
- cmp esi, dword[m]
- jne .cont
- inc dword[res]
- .cont:
- cmp esi, dword[m]
- jl LOOP
- PRINT_DEC 4, [res]
- xor eax, eax
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement