-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9_04.asm
71 lines (58 loc) · 978 Bytes
/
9_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
62
63
64
65
66
67
68
69
70
71
%include "io.inc"
section .text
global CMAIN
CMAIN:
mov ebp, esp; for correct debugging
;write your code here
GET_UDEC 4, eax
push eax
call SOLVE
pop eax
PRINT_UDEC 4, ecx
xor eax, eax
ret
SOLVE:
push ebp
mov ebp, esp
mov esi, [ebp+8]
mov ecx, 0
.l2:
inc ecx
push eax
push ecx
call ISBAD
pop ecx
sub esi, eax
pop eax
test esi, esi
jnz .l2
pop ebp
ret
ISBAD:
push ebp
mov ebp, esp
mov eax, [ebp+8]
mov ecx, 1
xor ebx, ebx
.l1:
cmp ecx, eax
je .done
push eax
xor edx, edx
div ecx
test edx, edx
jnz .skip
add ebx, ecx
.skip:
pop eax
inc ecx
jmp .l1
.done:
mov edx, eax
xor eax, eax
cmp edx, ebx
jbe .l4
inc eax
.l4:
pop ebp
ret