Subject: Re: Assembly Language Programs
To: Ben Collver <collver@peak.org>
From: Martin Husemann <martin@duskware.de>
List: tech-kern
Date: 04/12/2006 14:45:46
On Wed, Apr 12, 2006 at 05:29:55AM -0700, Ben Collver wrote:
> .section ".note.netbsd.ident", "a"
> .long 2f-1f
> .long 4f-3f
> .long 1
> 1: .asciz "NetBSD"
> 2: .p2align 2
> 3: .long 199905
> 4: .p2align 2

Or, as I suggested, let cc handle all this for you. You need "main" as
entry point, and get a bit more additional stuff linked in, but you
avoid creating the note section manually.

For your amusement, here is an example for another arch.

Martin

! test.s - sparc64 "hello world" in assembler
! as -o test.o test.s
! cc -static -o test test.o

.text
.global	main
main:
	save %sp, -192, %sp	! set up stack frame (we do function calls)

	set str, %o0
	call printf		! we are linked static, so this is easy
	 nop

	ret			! return 0 exit status
	 restore %g0, 0, %o0


.section ".rodata"
str:
	.ascii "Hello, world!\n"