Posted in
6464
12:25 pm, December 12, 2021
Hello world in C and seeing what it is actually doing
One of the most simple C applications, how to compile it and how to objdump it.
C
#include
int main()
{
int i;
for(i=0;i < 10; i++)
{
puts("Hello Mac\n");
}
return 0;
}
This will return the string Hello Mac
10 times.
lets compile and run it
gcc firstprog.c
ls -l
./a.out
now see what its really doing
objdump -D a.out | grep -A20 main.:
Random Fact about 32 vs 64 bit processors.
32-bit processors have 232 (or 4,294,967,296) possible addresses
64-bit ones have 264 (1.84467441 x 1019) possible addresses
Each byte is shown in hexadecimal notation which is a base 16 numbering system, rather than the normal system we are used to which is base-10. Hex uses 0 - 9 and also A - F for 10 - 15.
Show what it would look like with intel formatting
objdump -M intel -D a.out | grep -A20 main.:
Note this will throw an error on arm based mac's, for obvious reasons.
objdump: error: 'a.out': Unrecognized disassembler option: intel
.
View Statistics
This Week
273
This Month
796
This Year
2097
Add Comment
Other Items in C
Related Search Terms
Other Categories in Code
alpine js apps c css factorio font awesome images linux quick modals sqlite site bugs site updates slick slider sliders testing windows apps apache api apps asp bat bootstrap bootstrap templates charts cookies core css css filters css grid design elements docker domains emoji fancybox fonts foundation framework gimp git html icons ideas image formatting images javascript javascript functions jquery js linux mac misc modals mysql nginx node php php errors php function php functions php simple html dom pi400 python react regex sections simple_html_dom simplepie php site bugs site documentation slick slider sql sqlite ssh sublime svg svg css templates tools virtual box vscode vue webdev windows windows 11 windows commands wordpress