Posted in C
4952
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
99
This Month
362
This Year
585

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
"Let us prepare our minds as if we'd come to the very end of life. Let us postpone nothing. Let us balance life's books each day ... The one who puts the finishing touches on their life each day is never short of time."
Seneca
Random CSS Property

scroll-padding-bottom

The scroll-padding-bottom property defines offsets for the bottom of the optimal viewing region of the scrollport: the region used as the target region for placing things in view of the user. This allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars) or to put more breathing room between a targeted element and the edges of the scrollport.
scroll-padding-bottom css reference