1 1.1 jmmv # $NetBSD: powerpc.s,v 1.1 2011/11/12 01:18:41 jmmv Exp $ 2 1.1 jmmv # 3 1.1 jmmv # Copyright (c) 2011 The NetBSD Foundation, Inc. 4 1.1 jmmv # All rights reserved. 5 1.1 jmmv # 6 1.1 jmmv # Redistribution and use in source and binary forms, with or without 7 1.1 jmmv # modification, are permitted provided that the following conditions are 8 1.1 jmmv # met: 9 1.1 jmmv # 10 1.1 jmmv # 1. Redistributions of source code must retain the above copyright 11 1.1 jmmv # notice, this list of conditions and the following disclaimer. 12 1.1 jmmv # 2. Redistributions in binary form must reproduce the above copyright 13 1.1 jmmv # notice, this list of conditions and the following disclaimer in the 14 1.1 jmmv # documentation and/or other materials provided with the distribution. 15 1.1 jmmv # 16 1.1 jmmv # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 1.1 jmmv # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 1.1 jmmv # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 19 1.1 jmmv # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 20 1.1 jmmv # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 1.1 jmmv # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 1.1 jmmv # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 1.1 jmmv # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 1.1 jmmv # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 1.1 jmmv # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 1.1 jmmv # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 1.1 jmmv # 28 1.1 jmmv 29 1.1 jmmv # ------------------------------------------------------------------------ 30 1.1 jmmv 31 1.1 jmmv .section ".note.netbsd.ident", "a" 32 1.1 jmmv # This ELF section is used by the kernel to determine, among other 33 1.1 jmmv # things, the system call interface used by the binary. 34 1.1 jmmv # 35 1.1 jmmv # See http://www.netbsd.org/docs/kernel/elf-notes.html for more 36 1.1 jmmv # details. 37 1.1 jmmv 38 1.1 jmmv .int 7 # Length of the OS name field below. 39 1.1 jmmv .int 4 # Length of the description field below. 40 1.1 jmmv .int 0x01 # The type of the note: NetBSD OS Version. 41 1.1 jmmv .ascii "NetBSD\0\0" # The OS name, padded to 8 bytes. 42 1.1 jmmv .int 0x23b419a0 # The description value; 5.99.56. 43 1.1 jmmv 44 1.1 jmmv # ------------------------------------------------------------------------ 45 1.1 jmmv 46 1.1 jmmv .section ".data" 47 1.1 jmmv 48 1.1 jmmv message: 49 1.1 jmmv .ascii "Hello, world!\n" 50 1.1 jmmv .set MESSAGE_SIZE, . - message 51 1.1 jmmv 52 1.1 jmmv # ------------------------------------------------------------------------ 53 1.1 jmmv 54 1.1 jmmv .section ".text" 55 1.1 jmmv 56 1.1 jmmv .balign 4 57 1.1 jmmv 58 1.1 jmmv .globl _start 59 1.1 jmmv .type _start, @function 60 1.1 jmmv _start: 61 1.1 jmmv # write(STDOUT_FILENO, message, MESSAGE_SIZE) 62 1.1 jmmv li %r0, 4 # r0: write(2) syscall number. 63 1.1 jmmv li %r3, 1 # r3: first argument. 64 1.1 jmmv addis %r4, %r0, message@h # r4: second argument. 65 1.1 jmmv ori %r4, %r4, message@l 66 1.1 jmmv li %r5, MESSAGE_SIZE # r5: third argument. 67 1.1 jmmv sc 68 1.1 jmmv 69 1.1 jmmv # exit(EXIT_SUCCESS) 70 1.1 jmmv li %r0, 1 # r0: exit(2) syscall number. 71 1.1 jmmv li %r3, 0 # r3: first argument. 72 1.1 jmmv sc 73 1.1 jmmv 74 1.1 jmmv .size _start, . - _start 75