1 |
/* |
2 |
* $Id: hello_mips.c,v 1.3 2005/08/09 18:29:20 debug Exp $ |
3 |
* |
4 |
* MIPS Hello World for GXemul. |
5 |
* |
6 |
* Compile: |
7 |
* mips64-unknown-elf-gcc -O2 hello_mips.c -mips4 -mabi=64 -c |
8 |
* |
9 |
* and link: |
10 |
* mips64-unknown-elf-ld -Ttext 0xa800000000030000 -e f |
11 |
* hello_mips.o -o hello_mips --oformat=elf64-bigmips |
12 |
* |
13 |
* Run: |
14 |
* gxemul -E testmips hello_mips |
15 |
*/ |
16 |
|
17 |
/* Note: The cast to a signed int causes the address to be sign-extended |
18 |
correctly to 0xffffffffb00000xx when compiled in 64-bit mode */ |
19 |
#define PUTCHAR_ADDRESS ((signed int)0xb0000000) |
20 |
#define HALT_ADDRESS ((signed int)0xb0000010) |
21 |
|
22 |
void printchar(char ch) |
23 |
{ |
24 |
*((volatile unsigned char *) PUTCHAR_ADDRESS) = ch; |
25 |
} |
26 |
|
27 |
void halt(void) |
28 |
{ |
29 |
*((volatile unsigned char *) HALT_ADDRESS) = 0; |
30 |
} |
31 |
|
32 |
void printstr(char *s) |
33 |
{ |
34 |
while (*s) |
35 |
printchar(*s++); |
36 |
} |
37 |
|
38 |
void f(void) |
39 |
{ |
40 |
printstr("Hello world\n"); |
41 |
halt(); |
42 |
} |
43 |
|