-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6_04.asm
61 lines (56 loc) · 890 Bytes
/
6_04.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
%include "io.inc"
section .bss
arr resd 1000
section .text
global CMAIN
CMAIN:
mov ebp, esp
GET_UDEC 4, ecx
xor edx, edx
.l1:
cmp edx, ecx
je .exit
GET_UDEC 4, eax
mov [arr+4*edx], eax
inc edx
jmp .l1
.exit:
GET_UDEC 4, esi
xor edi, edi
xor edx, edx
.l2:
cmp edx, ecx
je .ex
mov eax, [arr+4*edx]
push ecx
push eax
call COUNTOFZ
add esp, 4
pop ecx
cmp eax, esi
jne .sk
inc edi
.sk:
inc edx
jmp .l2
.ex:
PRINT_UDEC 4, edi
xor eax, eax
ret
COUNTOFZ:
push ebp
mov ebp, esp
mov eax, [ebp+8]
xor ecx, ecx
.l1:
test eax, eax
jz .done
shr eax, 1
jc .skip
inc ecx
.skip:
jmp .l1
.done:
mov eax, ecx
pop ebp
ret