Subject: Re: my first mac68k asm program...
To: None <port-mac68k@netbsd.org>
From: Christian Groessler <cpg@aladdin.de>
List: port-mac68k
Date: 06/21/2002 00:16:02
Marco van de Voort wrote:

> Whoops saw that you were playing ELF.
> 
> Try to add this to your source (this is i386, maybe needs fix for
> endianness, but can't access a m68k from here; am at work)
> 
> # This section is needed for NetBSD to recognize a NetBSD binary as such.
> # otherwise it will be startup in Linux emulation mode.
> 
> .section ".note.netbsd.ident","a"
> .p2align 2
> 
> .long 7
> .long 4
> # ELF NOTE TYPE NETBSD TAG
> .long 1
> .ascii "NetBSD\0\0"
> .long 199905

Thanks! This was the problem. The following program works:

-------
SYS_exit	=	1
SYS_write	=	4

	.section ".note.netbsd.ident","a"
	.align 2

	.long 7
	.long 4
	| ELF NOTE TYPE NETBSD TAG
	.long 1
	.ascii "NetBSD\0\0"
	.long 199905

	.section	.rodata
message:
	.ascii "Hello World from the Assembler Universe\12"
mlen	=	. - message

	.text
	.align 2

.globl _start
_start:

	pea	mlen
	pea	message
	pea	1
	clrl	%sp@-			| dummy value
	movl	#SYS_write,%d0
	trap	#0
	addl	#16,%sp			| clean up stack
	movl	#SYS_exit,%d0
	trap	#0
-------

But now I encounter another problem: gdb breakpoints don't work:

-------
mac68k:~/work$ gdb ahello
GNU gdb 5.0nb1
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "m68k--netbsdelf"...(no debugging symbols found)...
(gdb) break _start
Breakpoint 1 at 0x20ac
(gdb) r
Starting program: /usr/chris/work/ahello 
Hello World from the Assembler Universe

Program exited with code 044.
(gdb) 
-------

any hints on this one?

regards,
chris