asm/main.c
changeset 5 d752cbe8208e
child 9 c3fecc82ade6
equal deleted inserted replaced
4:236f8f747073 5:d752cbe8208e
       
     1 /**
       
     2  * $Id: main.c,v 1.1.1.1 2008-04-28 17:32:52 mbroeker Exp $
       
     3  * $Source: /development/c/asm/main.c,v $
       
     4  *
       
     5  */
       
     6 
       
     7 #include <stdio.h>
       
     8 #include <stdlib.h>
       
     9 #include <unistd.h>
       
    10 #include <signal.h>
       
    11 
       
    12 #ifndef TIMEOUT
       
    13 #define TIMEOUT 500
       
    14 #endif
       
    15 
       
    16 int get_sp ();
       
    17 
       
    18 void sigendian ()
       
    19 {
       
    20     unsigned short word = 0x1234;
       
    21     unsigned char *p = (unsigned char *)&word;
       
    22 
       
    23     signal (SIGUSR1, sigendian);
       
    24     printf ("%s Endian System\n", (p[0] == 0x34) ? "Little" : "Big");
       
    25 }
       
    26 
       
    27 void sigproc ()
       
    28 {
       
    29     signal (SIGINT, sigproc);
       
    30     printf ("Stack-Pointer is at %08x\n", get_sp ());
       
    31 }
       
    32 
       
    33 void sigquit ()
       
    34 {
       
    35     printf ("Hmm... You got it, man!\n");
       
    36     exit (0);
       
    37 }
       
    38 
       
    39 int main (int argc, char **argv)
       
    40 {
       
    41     signal (SIGINT, sigproc);
       
    42     signal (SIGUSR1, sigendian);
       
    43     signal (SIGQUIT, sigquit);
       
    44 
       
    45     for (;;)
       
    46         usleep (TIMEOUT);
       
    47 
       
    48     return EXIT_FAILURE;
       
    49 }