Reduce stack usage in call16().
authorKevin O'Connor <kevin@koconnor.net>
Sat, 1 Mar 2008 19:56:07 +0000 (14:56 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 1 Mar 2008 19:56:07 +0000 (14:56 -0500)
Tell gcc that registers are clobbered instead of using push/popal.

TODO
src/util.h

diff --git a/TODO b/TODO
index 08aaf91d8b55fc9b80eeb373852b161ebc9719b1..fa013925098da5905e9c83667371302eecc56013 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,10 +1,7 @@
 Find out why ubuntu compiles are failing.  Find work around.
 
-See if it is better to tell gcc that call16 clobbers all registers
-instead of having the code call pushal/popal.
-
-The __call16 code does a long jump to the interrupt handlers - this is
-unnecessary.
+The __call16 code does a long jump to the interrupt trampolines - this
+is unnecessary.
 
 Fix makefiles so that they rebuild the required files automatically.
 
index 7de577bb0f9e6ec97f028f3d92759d7c0679688d..6c707bd53276c41680875e7f5a1f6448110658e1 100644 (file)
@@ -65,16 +65,18 @@ static inline
 void call16(struct bregs *callregs)
 {
     asm volatile(
-        "pushfl\n"   // Save flags
-        "pushal\n"   // Save registers
+        "pushl %%ebp\n" // Save state
+        "pushfl\n"
 #ifdef MODE16
         "calll __call16\n"
 #else
         "calll __call16_from32\n"
 #endif
-        "popal\n"
-        "popfl\n"
-        : : "a" (callregs), "m" (*callregs));
+        "popfl\n"       // Restore state
+        "popl %%ebp\n"
+        : "=a" (callregs), "=m" (*callregs)
+        : "a" (callregs), "m" (*callregs)
+        : "ebx", "ecx", "edx", "esi", "edi");
 }
 
 static inline