www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/17/22:39:53

To: djgpp AT delorie DOT com
Subject: Custom Stack?
Message-ID: <19970217.193154.4951.0.chambersb@juno.com>
From: chambersb AT juno DOT com (Benjamin D Chambers)
Date: Mon, 17 Feb 1997 22:29:32 EST

Let's say I want to use my own buffer as a temporary stack (I would, of
course, switch back to the main stack when I'm done).  Would I simply
load %esp with the location of my buffer, plus the size if the buffer?

Ie:
int buf[10];
int old;
asm("
	movl	%%esp,		(%%eax)
	movl	%%ebx,		%%esp
	addl	$40,		%%esp
. . .
	movl	(%%eax),	%%esp
"
:: "a" (&old), "b" (buf):"memory");

I tried this, but when the instructions in place of the ellipses pushed
values onto the stack (buf), and I checked the values afterwards, they
were random - not anything like what I had pushed (I tried compiling with
-O0, but not with anything else).
Any ideas?

...Chambers

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019