Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/share/examples



"Julio Merino" <jmmv%netbsd.org@localhost> writes:

> Module Name:  src
> Committed By: jmmv
> Date:         Sat Nov 12 01:18:41 UTC 2011
>
> Modified Files:
>       src/share/examples: Makefile
> Added Files:
>       src/share/examples/asm: Makefile Makefile.inc.inst README
>       src/share/examples/asm/hello: Makefile Makefile.inst powerpc.s
>
> Log Message:
> Add assembly language examples in a new 'asm' subdirectory.
>
> At the moment this only provides an example for a "Hello world" program
> for powerpc.  (Bear with me: this is my very first assembly program in
> powerpc; if you find anything stupid in the code, please fix it!)
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.19 -r1.20 src/share/examples/Makefile
> cvs rdiff -u -r0 -r1.1 src/share/examples/asm/Makefile \
>     src/share/examples/asm/Makefile.inc.inst src/share/examples/asm/README
> cvs rdiff -u -r0 -r1.1 src/share/examples/asm/hello/Makefile \
>     src/share/examples/asm/hello/Makefile.inst \
>     src/share/examples/asm/hello/powerpc.s

...

> Index: src/share/examples/asm/hello/Makefile.inst
> diff -u /dev/null src/share/examples/asm/hello/Makefile.inst:1.1
> --- /dev/null Sat Nov 12 01:18:41 2011
> +++ src/share/examples/asm/hello/Makefile.inst        Sat Nov 12 01:18:41 2011
> @@ -0,0 +1,12 @@
> +# $NetBSD: Makefile.inst,v 1.1 2011/11/12 01:18:41 jmmv Exp $
> +
> +.include <bsd.own.mk>
> +
> +.if exists(${MACHINE_ARCH}.s)
> +PROG=                hello
> +MAN=         # empty
> +LDFLAGS=     -nostdlib
> +SRCS=                ${MACHINE_ARCH}.s
> +.endif
> +
> +.include <bsd.prog.mk>
> Index: src/share/examples/asm/hello/powerpc.s
> diff -u /dev/null src/share/examples/asm/hello/powerpc.s:1.1
> --- /dev/null Sat Nov 12 01:18:41 2011
> +++ src/share/examples/asm/hello/powerpc.s    Sat Nov 12 01:18:41 2011
> @@ -0,0 +1,74 @@
> +# $NetBSD: powerpc.s,v 1.1 2011/11/12 01:18:41 jmmv Exp $
> +#
> +# Copyright (c) 2011 The NetBSD Foundation, Inc.
> +# All rights reserved.
> +#
> +# Redistribution and use in source and binary forms, with or without
> +# modification, are permitted provided that the following conditions are
> +# met:
> +#
> +# 1. Redistributions of source code must retain the above copyright
> +#    notice, this list of conditions and the following disclaimer.
> +# 2. Redistributions in binary form must reproduce the above copyright
> +#    notice, this list of conditions and the following disclaimer in the
> +#    documentation and/or other materials provided with the distribution.
> +#
> +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
> +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
> +# PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
> +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
> +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
> +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
> +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
> +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
> +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> +#
> +
> +# ------------------------------------------------------------------------
> +
> +.section ".note.netbsd.ident", "a"
> +     # This ELF section is used by the kernel to determine, among other
> +     # things, the system call interface used by the binary.
> +     #
> +     # See http://www.netbsd.org/docs/kernel/elf-notes.html for more
> +     # details.
> +
> +     .int 7                  # Length of the OS name field below.
> +     .int 4                  # Length of the description field below.
> +     .int 0x01               # The type of the note: NetBSD OS Version.
> +     .ascii  "NetBSD\0\0"    # The OS name, padded to 8 bytes.
> +     .int 0x23b419a0         # The description value; 5.99.56.
> +
> +# ------------------------------------------------------------------------

#include <sys/syscall.h>
#ifdef __NetBSD_Version__
.section ".note.netbsd.ident", "a"
        .long   2f-1f
        .long   4f-3f
        .long   1
1:      .asciz  "NetBSD"
2:      .p2align 2
3:      .long   __NetBSD_Version__
4:      .p2align 2
#endif

"#ifdef" because it works (worked, at least) in FreeBSD as well.

But then it should be called "<something>.S".
Note capital "S", standard rule is to run that through CPP.


-- 
HE CE3OH...

Attachment: pgp1lcUhQ07Jf.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index