diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d63009e86687f980e010a052fd2b031f0ce7ed7c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*.s +display_stack \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..25b8148038585c950484d4759a865516a4709d53 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +all: display_stack + +display_stack : display_stack.o + gcc -o $@ $^ + +%.o:%.c + gcc -c $< + +clean: + rm -f *.o *.s display_stack diff --git a/display_stack.c b/display_stack.c new file mode 100644 index 0000000000000000000000000000000000000000..4256cbd70b978251bb86aab50e23c9de62dffc79 --- /dev/null +++ b/display_stack.c @@ -0,0 +1,21 @@ +#include <stdio.h> + +int display(int pa, int pb, int pc) +{ + printf("pa=%p; pb=%p; pc=%p\n", &pa, &pb, &pc); + return 0; +} + +int main() +{ + int a, b; + int la, lb, lc; + asm("movl %%esp, %0" + "\n\t" + "movl %%ebp, %1" + : "=r"(a), "=r"(b)); + printf("esp=%p; ebp=%p\n", &a, &b); + printf("la=%p; lb=%p; lc=%p\n", &la, &lb, &lc); + + return display(la, lb, lc); +}