Subject: RE: Any assembler guides anywhere?
To: None <andrew@andycole.force9.co.uk>
From: Gilbert, Christopher <GilbeC@tetraworld.com>
List: port-arm32
Date: 11/19/1998 08:43:16
> From:	Peter Teichmann [SMTP:teich-p@Rcs1.urz.tu-dresden.de]
> 
> Andrew Cole wrote:
> 
> > Can anyone point me towards any guides about how to integrate ARM
> assembler
> > with C programs under NetBSD? I've learnt assembler from RISC OS and I
> > would be interested in using it to optimize routines in programs.
> 
> It seems to be the same like with RiscOS. At least some programs I wrote
> originally for RiscOS worked also under RiscBSD/X11, of course with some
> modifications and changes in the assembler syntax. But that was about a
> year
> ago and might have changed.
> 
 (apologies for the seemingly mad way this email is strung together but it's
as things come back from some months ago)

>From what I remember most things are the same, I think the general structure
is:

#include <machine/asm.h>

ENTRY(function)
	function  code

To exit the function you need to use either mov PC,R14 if you've not
branched or altered R14 or load it from somewhere.  Because the code will be
in 32 bit user mode there's no way to save and restore the status flags to
how they were before a function call.

There are some examples in src/lib/libc/arch/arm32/

I think that the general style is the same as for acorns system.

If you need to call a function from assembler you'll need to setup the stack
and registers (how this works someone who knows should explain) and do a
branch to '_functionname'  (The _ is added by the compiler if it's C or by
the ENTRY macro if it's asm.)  The ENTRY macro also sets up the function to
be global.

Labels are different in gas, they take the form:

label:
as apposed to the riscos style:
.label

Local labels should be preceded by an L eg:
.Llocallabel
This allows the tools to strip the local labels out

reserving space for variables is done with .word and .byte.  Alignment is
done with .align.

There's probably a lot of other differences, but I can't remember them, I
think there's a doc somewhere around that details this a bit more.  Try man
as (or gas) for the assembler directives.

Try looking at the existing .S files.

This has reminded me that I need to finish off doing some of those string
functions in ASM (And submit them)

Cheers,
Chris









The statements and opinions expressed here are my own and may not represent those of the company.

This e-mail is subject to copyright and the information in it is confidential. It is intended only for the named recipient. You are advised not to disclose the contents of this e-mail to another pers
on or take copies of it.