PDA

View Full Version : Quick Question


PhilT
August 11th, 2014, 02:58
I am trying to re-write some functions from a 16 bit DLL using an IDA dead listing, I'm not a 'programmer' as such more of a hobbyist.
I have managed to re-write a few functions ok but have hit a problem on one of them which i dont understand hence the question.

I have this code..

push word ptr [bp+6] //this is the 16 seed value
call SeedToKey //calculates the key value and places the answer in ax
add sp, 2
mov [bp+6], ax // copies ax to BP+6

This code loops around based on another value.

My question is, does adding 2 to the stack pointer affect the contents of the ax register before its copied back to BP+6??

Sorry if this is a basic question but i'm still trying to learn!

Thanks

Kayaker
August 11th, 2014, 04:09
I would say that is just standard _cdecl calling convention, where the caller cleans up the stack. add sp, 2 resets the stack pointer from the word-size push before the call. The return value in AX will not be affected.

PhilT
August 11th, 2014, 04:13
Many thanks, i thought it wouldn't have an affect but just wanted to be sure.

Must be my code not working then