add lab1-ex2
This commit is contained in:
parent
e3a158064f
commit
d1cd830da5
40
related_info/lab1/lab1-ex2.c
Executable file
40
related_info/lab1/lab1-ex2.c
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void A();
|
||||||
|
void B(int a, int b, int c);
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
A();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void A()
|
||||||
|
{
|
||||||
|
unsigned int a = 1;
|
||||||
|
unsigned int b = 2;
|
||||||
|
unsigned int c = 3;
|
||||||
|
B(a,b,c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void B(int d, int e, int f)
|
||||||
|
{
|
||||||
|
int g;
|
||||||
|
unsigned int _ebp;
|
||||||
|
__asm__(
|
||||||
|
"movl %%ebp,%0\n\t" \
|
||||||
|
:"=r" (_ebp));
|
||||||
|
g=4;
|
||||||
|
|
||||||
|
printf(" [ebp-12] --?? = %p --- %d \n [ebp-08] --?? = %p --- %d \n [ebp-04] --?? = %p --- %d \n [ebp+00] -oebp= %p --- %p \n [ebp+04] -ret = %p --- %p \n [ebp+08] -- d = %p --- %d \n [ebp+12] -- e = %p --- %d \n [ebp+16] -- f = %p --- %d \n ",
|
||||||
|
(unsigned *)(_ebp-12), *(unsigned *)(_ebp-12),
|
||||||
|
(unsigned *)(_ebp-8), *(unsigned *)(_ebp-8),
|
||||||
|
(unsigned *)(_ebp-4), *(unsigned *)(_ebp-4),
|
||||||
|
(unsigned *)(_ebp), *(unsigned *)(_ebp),
|
||||||
|
(unsigned *)(_ebp+4), *(unsigned *)(_ebp+4),
|
||||||
|
(unsigned *)(_ebp+8), *(unsigned *)(_ebp+8),
|
||||||
|
(unsigned *)(_ebp+12), *(unsigned *)(_ebp+12),
|
||||||
|
(unsigned *)(_ebp+16), *(unsigned *)(_ebp+16));
|
||||||
|
|
||||||
|
}
|
8
related_info/lab1/lab1-ex2.md
Normal file
8
related_info/lab1/lab1-ex2.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# lab1-ex2
|
||||||
|
Try below command (stack)
|
||||||
|
|
||||||
|
```
|
||||||
|
gcc -m32 -o lab1-ex2.exe lab1-ex2.c
|
||||||
|
```
|
||||||
|
|
||||||
|
Try to analysis the means of these output log.
|
Loading…
x
Reference in New Issue
Block a user