The MASM Forum

Projects => Easy Code IDE 32/64-bit => Topic started by: greco558 on October 03, 2012, 10:36:38 PM

Title: saving registers
Post by: greco558 on October 03, 2012, 10:36:38 PM
rsala,

I was looking at the easycode manual, and I noticed that it said you do not have to save edi, esi, ebx registers in a
visual project if you use them in your procedure.
So easycode will take care to save these registers for you even in your own procedures in the visual
project?
I Have been saving them on entry to my procedures and restoring them. I assume from what I read I do not
need to do this?

Thanks
greco558
Title: Re: saving registers
Post by: rsala on October 07, 2012, 06:28:56 AM
Hi greco558,

When the code execution comes to a window procedure, Ebx, Edi and Esi registers have been saved and they will be restored at the end of the proc. Also they are saved when calling an Easy Code method in visual projects. However, in your own procedures you are the responsible for saving them if you want to keep their values in any part of your code (saving them or not has no effect on EC). As said before, when the code execution returns to EC the values for Ebx, Edi and Esi are restored to the values they had when the window procedure was called.

Fo example:

Window1Procedure Proc Private hWnd:HWND, ...
    .If uMsg == WM_CREATE
        Invoke GlobalAlloc, GPTR, 1024
        Mov Ebx, Eax
        Invoke YourProc, ...

        Invoke GlobalFree, Ebx

    .EndIf
    Return FALSE
Window1 EndP


In the example above, if you are going to modify Ebx in YourProc, you must save it as it contains the address of the allocated memory that has to be freed later.

Regards,

Ramon