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

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

.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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.