Difference between revisions of "User:J Lipscomb"

From eLinux.org
Jump to: navigation, search
m
Line 12: Line 12:
 
|-
 
|-
 
|-
 
|-
| 2-1
+
| 2-21
| 2-6
+
| Hello World, Embedded Style
| Initial Bootloader Serial Output
+
 
| <pre>
 
| <pre>
Insert Listing Here
+
#include <stdio.h>
 +
 
 +
int bss_var;        /* Uninitialized global variable */
 +
 
 +
int data_var = 1;  /* Initialized global variable */
 +
 
 +
int main(int argc, char **argv)
 +
{
 +
  void *stack_var;            /* Local variable on the stack */
 +
 
 +
  stack_var = (void *)main;  /* Don't let the compiler */
 +
                              /* optimize it out */
 +
 
 +
  printf("Hello, World! Main is executing at %p\n", stack_var);
 +
  printf("This address (%p) is in our stack frame\n", &stack_var);
 +
 
 +
  /* bss section contains uninitialized data */
 +
  printf("This address (%p) is in our bss section\n", &bss_var);
 +
 
 +
  /* data section contains initializated data */
 +
  printf("This address (%p) is in our data section\n", &data_var);
 +
 
 +
  return 0;
 +
}
 
</pre>
 
</pre>
|-
 
| 2-2
 
| 2-7
 
| Loading the Linux Kernel
 
|
 
|-
 

Revision as of 19:39, 21 March 2010


I am currently an Electrical Engineering undergraduate student at Rose-Hulman Institute of Technology in Terre Haute, Indiana.

Chapter 2

Number Page Caption Listing
2-21 Hello World, Embedded Style
#include <stdio.h>

int bss_var;        /* Uninitialized global variable */

int data_var = 1;   /* Initialized global variable */

int main(int argc, char **argv)
{
  void *stack_var;            /* Local variable on the stack */
  
  stack_var = (void *)main;   /* Don't let the compiler */
                              /* optimize it out */

  printf("Hello, World! Main is executing at %p\n", stack_var);
  printf("This address (%p) is in our stack frame\n", &stack_var);

  /* bss section contains uninitialized data */
  printf("This address (%p) is in our bss section\n", &bss_var);

  /* data section contains initializated data */
  printf("This address (%p) is in our data section\n", &data_var);

  return 0;
}