The MASM Forum

General => The Campus => Topic started by: Lonewolff on April 15, 2018, 12:55:53 PM

Title: Problems returning from a proc
Post by: Lonewolff on April 15, 2018, 12:55:53 PM
Hi Guys,

I have my main program invoking a custom proc. I can 'ret' from it fine.

But if try to invoke another proc from inside the first proc the application seems to lose its way and crash if I also 'ret' from inside that.


; psuedo code

; a's proc
invoke b
ret

; b's proc
ret


; main program
invoke a
; program doesn't make it back to here


Hopefully this makes sense.

As always, any advice is considered truly awesome  8)


Title: Re: Problems returning from a proc
Post by: Lonewolff on April 15, 2018, 01:36:35 PM
My bad. It turns out I was using 'call' instead of 'invoke' somewhere along the line.
Title: Re: Problems returning from a proc
Post by: zedd151 on April 15, 2018, 01:57:55 PM
When strange problems like that occur, I usually turn to olly(or other debugger) for help tracking down the bug.

:greensml:
Title: Re: Problems returning from a proc
Post by: Lonewolff on April 15, 2018, 02:00:16 PM
Good idea, I'll have to get familiar with OllyDebug  :t
Title: Re: Problems returning from a proc
Post by: zedd151 on April 15, 2018, 02:02:58 PM
Then again, looking at your code...  :badgrin:


; psuedo code

; a's proc
invoke b
ret

; b's proc
ret


; main program
invoke a
; program doesn't make it back to here


Assuming linear flow, The code starts by invoking b, then returning to Neverland.    :greensml:
Title: Re: Problems returning from a proc
Post by: Lonewolff on April 15, 2018, 02:06:22 PM
Yeah, that's why I put 'pseudo code' in there.

I am making my procs as self contained functions. So it doesn't matter where they are getting called from or returning to.
Title: Re: Problems returning from a proc
Post by: zedd151 on April 15, 2018, 02:10:30 PM
It's all good, I know that you apparently know what your doing.

I'm glad that got it all sorted out.   :t
Title: Re: Problems returning from a proc
Post by: Lonewolff on April 15, 2018, 02:11:34 PM
Hehe, I try.

Much to learn on the ASM from though.  :lol: