/[gxemul]/upstream/0.3.5/doc/hello_mips.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /upstream/0.3.5/doc/hello_mips.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13 - (hide annotations)
Mon Oct 8 16:18:43 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 889 byte(s)
0.3.5
1 dpavlin 12 /*
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 dpavlin 2
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 dpavlin 12

  ViewVC Help
Powered by ViewVC 1.1.26