summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2014-04-28 13:49:15 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2014-04-28 13:49:15 -0700
commitc7d69efacf81a8f83687235d9fe57a3816460791 (patch)
treea18053346a28441122f11906f4e34f8caaf4f00d
parent6b7d46a874bb4c1d5c64ed931a868d40cdfaedfa (diff)
downloadtest16-c7d69efacf81a8f83687235d9fe57a3816460791.tar.gz
test16-c7d69efacf81a8f83687235d9fe57a3816460791.tar.xz
test16-c7d69efacf81a8f83687235d9fe57a3816460791.zip
hello.c: try to provoke an error on fouling of the high bits of %espHEADmaster
To try to help track down the problem with the high bits of %esp, explicitly try to error out on fouling. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--test16/hello.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/test16/hello.c b/test16/hello.c
index b79e7be..c5860c8 100644
--- a/test16/hello.c
+++ b/test16/hello.c
@@ -1,7 +1,31 @@
extern void puts(const char *);
+static const char *hexstr(unsigned int v)
+{
+ const char hexdigits[] = "0123456789abcdef";
+ static char hexbuf[9];
+ char *p = hexbuf;
+
+ for (i = 0; i < 8; i++) {
+ *p++ = hexdigits[v >> 28];
+ v <<= 4;
+ }
+ *p = '\0';
+
+ return hexbuf;
+}
+
+static inline unsigned int esp(void)
+{
+ unsigned int v;
+ asm volatile("movl %%esp,%0 ; movzwl %%sp,%%esp" : "=rm" (v));
+ return v;
+}
+
int main(void)
{
- puts("Hello, World!\n");
+ puts("Hello, World, esp = %\n");
+ asm("movl (%%esp),%%eax" : : : "eax");
+ puts("Hello, Afterworld!\n");
return 0;
}