0

Basically I have to take in N and bring it to power of K so N^K
i have the c++
i have the basic assembly
but something is wrong the math doesn't come out right

.386p
.model flat
.code
_func proc near
push ebp
mov ebp, esp
mov eax, [ebp+12]
mov ecx, [ebp+8]
cmp ecx, 0
ja L1
jmp L2
L1:
dec ecx
push eax
push ecx
CALL _func
add esp, 8
mov ebx, [ebp+8]
mul ebx
L2:
pop ebp
ret
_func endp
END

is what i have..can anyone please help

2
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by Assemblyn00b
0

You would appear to have a program which goes something like:


_func
;push registers
;load eax and ecx
;if ecx > 0
; decrement ecx
; push registers
; jump back up to _func

;else
; pop ebp
ret

Chewing up large amounts of stack as it goes. So far as I can see the following lines never get executed:
mov ebx, [ebp+8]
mul ebx

0

.386p
.model flat
.code
_func proc near
mov edx, 0
push ebp
mov ebp, esp
mov eax, [ebp+12]
mov ecx, [ebp+8]
cmp ecx, 0
ja L1
mov eax, 1
jmp L2
L1:
dec ecx
push eax
push ecx
CALL _func
add esp, 8
mov ebx, [ebp+12]
mul ebx
L2:
pop ebp
ret
_func endp
END


is my modified code.. .works sometimes but 52^0 comes out 0 and 6^4 comes out to 8^4

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.