-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha_power_b.asm
48 lines (40 loc) · 939 Bytes
/
a_power_b.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
global power
SECTION .text
power:
push ebx
push esi
push edi
push ebp
mov eax, [esp + 20] ;a
mov ebx, [esp + 24] ;b
mov edi, [esp + 28] ;callback
push edi
mov ebp, eax
mov ecx, eax
mov esi, 1
mov edi, 1
_cycle:
mov edi, 1
_in_cycle:
add ebp, ecx ; ebp - accum
js overflow
inc edi ; edi - _in_cycle iterator
cmp edi, eax ; esi - _cycle iterator
jl _in_cycle
mov ecx, ebp
inc esi
cmp esi, ebx
jl _cycle
end:
pop edi
push ebp; answer
call edi
add esp, 4
pop ebp
pop edi
pop esi
pop edx
ret
overflow:
mov ebp, -1
jmp end