I want to compile a C program so simple I can explain all of the assembly
1–10 of 39 posts
Re: I want to compile a C program so simple I can explain all of the assembly
#2Re: I want to compile a C program so simple I can explain all of the assembly
#3reminds me of a really old article (before the term 'blog' even existed) about a person exploring why the heck a 'hello world' Linux ELF binary was so darn big. i think it's an interesting exercise to figure out why 'hello world' in your favorite language/runtime environment is the size that it is (e.g., what initialization code is being called, are any VMs or intepreters being setup, etc.)
Re: I want to compile a C program so simple I can explain all of the assembly
#4reminds me of a really old article (before the term 'blog' even existed) about a person exploring why the heck a 'hello world' Linux ELF binary was so darn big. i think it's an interesting exercise to figure out why 'hello world' in your favorite language/runtime environment is the size that it is (e.g., what initialization code is being called, are any VMs or intepreters being setup, etc.)
That was my first thought as well. That article is found at http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm... (if that's the one you were thinking of)
Re: I want to compile a C program so simple I can explain all of the assembly
#5Re: I want to compile a C program so simple I can explain all of the assembly
#6That was a really cool article, anyone with more knowledge on the subject want to comment on how sound the author's thought process is? Thanks.
Re: I want to compile a C program so simple I can explain all of the assembly
#7reminds me of a really old article (before the term 'blog' even existed) about a person exploring why the heck a 'hello world' Linux ELF binary was so darn big. i think it's an interesting exercise to figure out why 'hello world' in your favorite language/runtime environment is the size that it is (e.g., what initialization code is being called, are any VMs or intepreters being setup, etc.)
That was my first thought as well. That article is found at http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm... (if that's the one you were thinking of)
Re: I want to compile a C program so simple I can explain all of the assembly
#8That was a really cool article, anyone with more knowledge on the subject want to comment on how sound the author's thought process is? Thanks.
It all looks correct to me. Some of it is a little "needlessly-surprised", honestly, like the bit about having to make a syscall trap to exit the program. Programs don't exit on their own: something needs to tell the kernel that the process is done.
It's disturbing how many Pascal-isms still pervade my thinking, even 20 years since I last (willingly) touched the language.
Re: I want to compile a C program so simple I can explain all of the assembly
#9That was a really cool article, anyone with more knowledge on the subject want to comment on how sound the author's thought process is? Thanks.
As a preview, to provide the correct C ABI to main() you need to zero the BSS (this is how your static variables get initialized), maybe copy the initalized data, call the constructors and destructors for C++ / C (gcc extension), provide memcpy() and others stdlib functions (which gcc will use even if you don't), etc. You can do all of this without assembly in C, but it does take some effort.