Re: Asm called by c_func
- Posted by Bernie Ryan <xotron at bluefrog.com> Apr 25, 2007
- 511 views
Juergen Luethje wrote: > > Larry Miller wrote: > > > Thanks to Bernie and Robert. I suspected that all registers should be saved > > but was not certain. Bit.e by Juergen Luethje in the recent contributions > > uses > > ECX but does not save it. > > Yes, since I have the same information as Rob regarding this point. > Also, I never have encountered any problem by not saving the values of > AX, CX, DX (in the old 16-bit world) or EAX, ECX, EDX respectively. > Hi Juergen If you are mixing programming langauges with assembler and the langauge is using fast calls the parameters are pass back and forth in the registers. If you destroy a registers you may crash the code. You should always preserve any register that you use. If you use a register that changes the direction flag you should do a CLD a clear the direction flag before you return because some lanagauges are depending on the direction flag to be clear. If your not concerned about speed you can use the pushad / popad to preserve the 32bit registers. pushfd / popfd to preserve the flag registers. Or preserve just the registers that you disturb. This being in addition to returning with stack be setup in the correct condition. Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan