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