arch/m68k-all: Add a stub fenv.c implementation for softfloat
[AROS.git] / test / uae / test.c
blob10b21ab98f23aabd24d7787b4665ba71cb645cff
3 #include <stdio.h>
4 #include "types.h"
5 #include "lists.h"
7 /* Print the contents of a piece of memory. */
8 void hexdump (const void * start, int size)
10 int t;
11 const unsigned char * ptr = (const unsigned char *)start;
13 for (t=0; size > 0; t++, size--)
15 if (!(t & 15)) printf ("%08lx: ", ((long)ptr));
16 printf ("%02x", *ptr++);
17 if ((t & 3) == 3) putchar (' ');
18 if ((t & 15) == 15) putchar ('\n');
21 if (t & 15) putchar ('\n');
24 int main (int argc, char ** argv)
26 int a;
27 short b;
28 APTR ptr;
29 WORD c;
30 struct List l;
31 ListPtr lptr;
32 struct Node n;
34 /* Store an int in a BE 16bit data type */
35 c = 15;
36 a = c; // Check if all conversions work
37 b = c;
39 // Try to print the data
40 printf ("Must be 15 15 15: %d %d %d\n", a, b, (int)c);
41 putchar ('\n');
43 // Same with a pointer
44 ptr = &lptr;
46 // Note that the pointer must be casted but the compiler will print
47 // a warning if the cast is missing:
48 // warning: cannot pass objects of type `APTR' through `...'
49 // These three lines must print the same values.
50 printf ("APTR %p %p\n", &lptr, (void *)ptr);
51 hexdump (&ptr, sizeof (ptr));
52 ptr.print (); putchar ('\n');
53 putchar ('\n');
55 // Same with a pointer
56 char * p1;
57 STRPTR p2;
59 p1 = "hello";
60 p2 = p1;
62 // Note that the pointer must be casted but the compiler will print
63 // a warning if the cast is missing:
64 // warning: cannot pass objects of type `STRPTR' through `...'
65 // The first line must print two equal pointers and the second line
66 // must print two times "hello".
67 printf ("string %p %p\n", p1, (void *)p2);
68 printf ("%s %s\n", p1, (const char *)p2);
69 putchar ('\n');
71 // Show the contents of the memory (to prove that the actual data is BE)
72 printf ("Contents of p1 (host endianess) and p2 (big endian):\n");
73 hexdump (&p1, sizeof (p1));
74 hexdump (&p2, sizeof (p2));
75 putchar ('\n');
77 // Same with a structure
78 lptr = &l;
79 // Print address of list header
80 printf ("&lptr %p\n", &lptr);
81 // Print list pointers (host and BE) which must be equal (otherwise the
82 // BE pointer is not converted correctly).
83 printf ("List %p %p\n", &l, (void *)lptr);
84 // Show that it's really a BE pointer
85 hexdump (&lptr, sizeof (lptr));
86 // Print the real contents of the variable in host endianess
87 lptr.print ();
88 putchar ('\n');
89 putchar ('\n');
91 // Try some functions on the list
92 NEWLIST(lptr);
93 printf ("NewList %p %p %p\n", (void *)(l.lh_Head), (void *)l.lh_Tail, (void *)l.lh_TailPred);
94 printf ("NewList %p %p %p\n", (void *)(lptr->lh_Head), (void *)lptr->lh_Tail, (void *)lptr->lh_TailPred);
95 hexdump (&l, sizeof (struct List));
96 putchar ('\n');
98 ADDHEAD(lptr, &n);
99 printf ("&Node %p\n", &n);
100 printf ("AddHead %p %p %p\n", (void *)l.lh_Head, (void *)l.lh_Tail, (void *)l.lh_TailPred);
101 putchar ('\n');
103 return 0;