extern io_get_udec, io_print_udec, io_newline
section .bss
N resd 1
K resd 1
res resd 1
k_zero resd 1
section .text
global main
main:
call io_get_udec
mov dword[N], eax
call io_get_udec
mov dword[K], eax
mov dword[k_zero], 0
mov dword[res], 0
mov ebx, 0
.start:
cmp ebx, dword[N] ; ebx = i
je .start_print
xor ecx, ecx
mov eax, ebx
bsr edx, eax; edx = инд самого старшего бита
.start_check:
dec edx; след бит
js .end_check ; i<0
cmp edx, 1
je .if_1
inc dword[k_zero]
.if_1:
jmp .start_check
.end_check:
mov ecx, dword[k_zero]
cmp ecx, dword[K]
jne .next_num
inc dword[res]
jmp .next_num
.next_num:
inc ebx
jmp .start
.start_print:
mov eax, dowrd[res]
call io_print_udec
call io_newline
xor eax, eax
ret