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