The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: sinsi on May 05, 2007, 07:16:26 AM

Title: Using ESP as a general register within a proc
Post by: sinsi on May 05, 2007, 07:16:26 AM
As long as I save and restore ESP and don't use any CALLs nothing will interrupt my proc and stuff up because of ESP?
This was a problem in DOS (INTs interrupting your proc) but Win32 doesn't have this problem does it?
Title: Re: Using ESP as a general register within a proc
Post by: hutch-- on May 05, 2007, 07:31:41 AM
Yu can use ESP without any problems in win32 as long as you preserve it somewhere, either a global variable or in another type of register. For the obvious reason you cannot use the stack while ESP is in use elsewhere.
Title: Re: Using ESP as a general register within a proc
Post by: sinsi on May 05, 2007, 07:46:52 AM
As I surmised. Thanks.
Title: Re: Using ESP as a general register within a proc
Post by: daydreamer on May 05, 2007, 09:17:05 AM
instead of have your timecriticalcode that is speedup by using ESP in main or a proc and need to restore stack alot and easily a cause to crash the app , put that code inside a workerthread which the OS keeps with its own separate set of general regs, you can have the rest of your app do all apicalling and none-timecritical-code