Hello World 2
Table 1. | ||||
# | Label | Memory Address | Binary value stored at address | Interpretation |
---|---|---|---|---|
# | 0x0000 0000 | 0000 0000 0000 0000 0000 0000 0000 0000 | ... | |
# | ... | ... | Text Segment | |
# | 0x0000 0FFC | 0000 0000 0000 0000 0000 0000 0000 0000 | ... | |
# | 0x0000 1000 | 0000 0000 0000 0000 0000 0000 0000 0000 | ... | |
# | ... | ... | Data | |
# | 0x0000 1FFC | 0000 0000 0000 0000 0000 0000 0000 0000 | ... | |
# | 0x0001 0000 | 0000 0000 0000 0000 0000 0000 1000 0000 | circle2.center.x | |
# | 0x0001 0004 | 0000 0000 0000 0000 0000 0000 0000 0000 | circle2.center.y | |
# | 0x0001 0008 | 0000 0000 0000 0001 0000 0000 0001 0000 | circle2.alt = 0x0001 0010 | |
# | 0x0001 000C | 0000 0000 0000 0000 0000 0000 0000 0000 | circle2.radius | |
# | 0x0001 0010 | 0000 0000 0000 0000 0000 0000 0100 0000 | alt.x | |
# | 0x0001 0014 | 0000 0000 0000 0000 0000 0000 0100 0000 | alt.y | |
# | ... | ... | ||
# | 0x0001 FFFC | 0000 0000 0000 0000 0000 0000 0000 0000 | ... | |
# | ... | ... | ||
# | ... | ... | ||
# | circle2: | 0xFFFF EFCC | 0000 0000 0000 0000 0000 0000 1000 0000 | 0x???? ???? |
# | circle1: | 0xFFFF EFD0 | 0000 0000 0000 0000 0000 0000 1000 0000 | 128 |
# | 0xFFFF EFD4 | 0000 0000 0000 0000 0000 0000 0100 0000 | 64 | |
# | 0xFFFF EFD8 | 0000 0000 0000 0000 0000 0000 0000 0010 | alt 0x0000 0000 | |
# | 0xFFFF EFDC | 0000 0000 0000 0000 0000 0000 0000 0010 | 2 | |
# | c1: | 0xFFFF EFE0 | 0000 0000 0000 0000 0000 0000 0000 0100 | 4 |
# | 0xFFFF EFE4 | 0000 0000 0000 0000 0000 0000 0000 1000 | 8 | |
# | y1: | 0xFFFF EFE8 | 0000 0000 0000 0000 0000 0000 0010 0000 | 32 |
# | x1: | 0xFFFF EFEC | 0000 0000 0000 0000 0000 0000 0001 0000 | 16 |
# | 0xFFFF EFF0 | 0000 0000 0000 0000 0000 0000 ???? ???? | Return address | |
# | 0xFFFF EFF4 | 1111 1111 1111 1111 1111 1111 1111 ???? | char** argv = 0x0000 ???? | |
# | 0xFFFF EFF8 | 0000 0000 0000 0000 0000 0000 0000 0010 | 0x0000 i.e., int argc | |
# | 0xFFFF EFFC | 0000 0000 0000 0000 0000 0000 0000 0000 | Return value | |
# | ... | ... |
$ ./hello "Hello world"
hello.c
/* * Coordinates * A program to find the distance between two pairs of coordinates. * * Usage: coordinates "x1" "y1" "x2" "y2" */ #include#include #include #include struct coordinate { int x; int y; }; struct circle { struct coordinate center; struct coordinate* alt; int radius; }; int main( int argc, char** argv ) { int x1 = 16; int y1 = 32; struct coordinate c1; c1.x = 4; c1.y = 8; struct circle circle1; circle1.center.x = 128; circle1.center.y = 64; circle1.alt = NULL; circle1.radius = 2; struct circle* circle2 = (struct circle*) calloc( 1, sizeof( struct circle ) ); circle2->alt = (struct coordinate*) calloc( 1, sizeof( struct coordinate ) ); circle2->center.x = 128; circle2->center.y = 128; circle2->alt->x = 64; circle2->alt->y = 64; return 0; }
References