| | |
c++/ assembly recursive troubles
![]() |
•
•
Join Date: May 2007
Posts: 3
Reputation:
Solved Threads: 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
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
•
•
Join Date: Nov 2006
Posts: 134
Reputation:
Solved Threads: 3
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
_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
•
•
Join Date: May 2007
Posts: 3
Reputation:
Solved Threads: 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
.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
![]() |
Similar Threads
- how to recursive search of subdiretories in BASH script (Shell Scripting)
- Assembly, machine code and compilers (Assembly)
- Help for quicksort in assembly 8085 (Assembly)
- Recursive prime number f(x) (C)
- LCD troubles..works with monitor... (Monitors, Displays and Video Cards)
Other Threads in the Assembly Forum
- Previous Thread: Printing Uppercase Characters
- Next Thread: Need help with 8086 assembly language
| Thread Tools | Search this Thread |





