mirror of
https://github.com/cfenollosa/os-tutorial.git
synced 2024-10-27 20:34:19 +00:00
lesson 12
This commit is contained in:
parent
dec0890a90
commit
0fc3af3f22
@ -55,8 +55,11 @@ More
|
||||
|
||||
I encourage you to write more small programs, which feature:
|
||||
|
||||
- Local variables
|
||||
- Function calls
|
||||
- Pointers
|
||||
- Local variables `localvars.c`
|
||||
- Function calls `functioncalls.c`
|
||||
- Pointers `pointers.c`
|
||||
|
||||
Then compile and disassemble them, and examine the resulting machine code.
|
||||
Then compile and disassemble them, and examine the resulting machine code. Follow
|
||||
the os-guide.pdf for explanations. Try to answer this question: why does the
|
||||
disassemblement of `pointers.c` not resemble what you would expect? Where is
|
||||
the ASCII `0x48656c6c6f` for "Hello"?
|
||||
|
7
12-kernel-c/functioncalls.c
Normal file
7
12-kernel-c/functioncalls.c
Normal file
@ -0,0 +1,7 @@
|
||||
void caller() {
|
||||
my_func(0xdede);
|
||||
}
|
||||
|
||||
int my_func(int arg) {
|
||||
return arg;
|
||||
}
|
4
12-kernel-c/localvars.c
Normal file
4
12-kernel-c/localvars.c
Normal file
@ -0,0 +1,4 @@
|
||||
int my_function() {
|
||||
int my_var = 0xbaba;
|
||||
return my_var;
|
||||
}
|
3
12-kernel-c/pointers.c
Normal file
3
12-kernel-c/pointers.c
Normal file
@ -0,0 +1,3 @@
|
||||
void func() {
|
||||
char* string = "Hello";
|
||||
}
|
Loading…
Reference in New Issue
Block a user