2000-09-29 13:46:07 +00:00
|
|
|
/* $FreeBSD$ */
|
|
|
|
/* From: NetBSD: asm.h,v 1.18 1997/11/03 04:22:06 ross Exp */
|
|
|
|
|
2005-01-31 08:16:45 +00:00
|
|
|
/*-
|
2000-09-29 13:46:07 +00:00
|
|
|
* Copyright (c) 1991,1990,1989,1994,1995,1996 Carnegie Mellon University
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and its
|
|
|
|
* documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
|
|
|
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie Mellon
|
|
|
|
* the rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assembly coding style
|
|
|
|
*
|
|
|
|
* This file contains macros and register defines to
|
|
|
|
* aid in writing more readable assembly code.
|
|
|
|
* Some rules to make assembly code understandable by
|
|
|
|
* a debugger are also noted.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Macro to make a local label name.
|
|
|
|
*/
|
|
|
|
#define LLABEL(name,num) L ## name ## num
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MCOUNT
|
|
|
|
*/
|
2010-07-01 00:30:35 +00:00
|
|
|
#if defined(PROF) || (defined(_KERNEL) && defined(GPROF))
|
2004-08-25 07:42:34 +00:00
|
|
|
#define MCOUNT \
|
|
|
|
alloc out0 = ar.pfs, 8, 0, 4, 0; \
|
|
|
|
mov out1 = r1; \
|
|
|
|
mov out2 = b0;; \
|
|
|
|
mov out3 = r0; \
|
|
|
|
br.call.sptk b0 = _mcount;;
|
2000-09-29 13:46:07 +00:00
|
|
|
#else
|
2004-08-25 07:42:34 +00:00
|
|
|
#define MCOUNT /* nothing */
|
2000-09-29 13:46:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2000-10-04 17:53:03 +00:00
|
|
|
* ENTRY
|
2000-09-29 13:46:07 +00:00
|
|
|
* Declare a global leaf function.
|
|
|
|
* A leaf function does not call other functions.
|
|
|
|
*/
|
2000-10-04 17:53:03 +00:00
|
|
|
#define ENTRY(_name_, _n_args_) \
|
2000-09-29 13:46:07 +00:00
|
|
|
.global _name_; \
|
2009-10-21 18:09:48 +00:00
|
|
|
.align 32; \
|
2000-09-29 13:46:07 +00:00
|
|
|
.proc _name_; \
|
|
|
|
_name_:; \
|
2004-08-25 07:42:34 +00:00
|
|
|
.regstk _n_args_, 0, 0, 0; \
|
2000-09-29 13:46:07 +00:00
|
|
|
MCOUNT
|
|
|
|
|
2000-10-04 17:53:03 +00:00
|
|
|
#define ENTRY_NOPROFILE(_name_, _n_args_) \
|
2000-09-29 13:46:07 +00:00
|
|
|
.global _name_; \
|
2009-10-21 18:09:48 +00:00
|
|
|
.align 32; \
|
2000-09-29 13:46:07 +00:00
|
|
|
.proc _name_; \
|
|
|
|
_name_:; \
|
|
|
|
.regstk _n_args_, 0, 0, 0
|
|
|
|
|
|
|
|
/*
|
2000-10-04 17:53:03 +00:00
|
|
|
* STATIC_ENTRY
|
2000-09-29 13:46:07 +00:00
|
|
|
* Declare a local leaf function.
|
|
|
|
*/
|
2000-10-04 17:53:03 +00:00
|
|
|
#define STATIC_ENTRY(_name_, _n_args_) \
|
2009-10-21 18:09:48 +00:00
|
|
|
.align 32; \
|
2000-09-29 13:46:07 +00:00
|
|
|
.proc _name_; \
|
|
|
|
_name_:; \
|
|
|
|
.regstk _n_args_, 0, 0, 0 \
|
|
|
|
MCOUNT
|
|
|
|
/*
|
2000-10-04 17:53:03 +00:00
|
|
|
* XENTRY
|
2000-09-29 13:46:07 +00:00
|
|
|
* Global alias for a leaf function, or alternate entry point
|
|
|
|
*/
|
2000-10-04 17:53:03 +00:00
|
|
|
#define XENTRY(_name_) \
|
2000-09-29 13:46:07 +00:00
|
|
|
.globl _name_; \
|
|
|
|
_name_:
|
|
|
|
|
|
|
|
/*
|
2000-10-04 17:53:03 +00:00
|
|
|
* STATIC_XENTRY
|
2000-09-29 13:46:07 +00:00
|
|
|
* Local alias for a leaf function, or alternate entry point
|
|
|
|
*/
|
2000-10-04 17:53:03 +00:00
|
|
|
#define STATIC_XENTRY(_name_) \
|
2000-09-29 13:46:07 +00:00
|
|
|
_name_:
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* END
|
|
|
|
* Function delimiter
|
|
|
|
*/
|
|
|
|
#define END(_name_) \
|
|
|
|
.endp _name_
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* EXPORT
|
|
|
|
* Export a symbol
|
|
|
|
*/
|
|
|
|
#define EXPORT(_name_) \
|
|
|
|
.global _name_; \
|
|
|
|
_name_:
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IMPORT
|
|
|
|
* Make an external name visible, typecheck the size
|
|
|
|
*/
|
|
|
|
#define IMPORT(_name_, _size_) \
|
|
|
|
/* .extern _name_,_size_ */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ABS
|
|
|
|
* Define an absolute symbol
|
|
|
|
*/
|
|
|
|
#define ABS(_name_, _value_) \
|
|
|
|
.globl _name_; \
|
|
|
|
_name_ = _value_
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BSS
|
|
|
|
* Allocate un-initialized space for a global symbol
|
|
|
|
*/
|
|
|
|
#define BSS(_name_,_numbytes_) \
|
|
|
|
.comm _name_,_numbytes_
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MSG
|
|
|
|
* Allocate space for a message (a read-only ascii string)
|
|
|
|
*/
|
|
|
|
#define ASCIZ .asciz
|
2000-10-04 17:53:03 +00:00
|
|
|
#define MSG(msg,reg,label) \
|
|
|
|
addl reg,@ltoff(label),gp;; \
|
|
|
|
ld8 reg=[reg];; \
|
|
|
|
.data; \
|
|
|
|
label: ASCIZ msg; \
|
2000-09-29 13:46:07 +00:00
|
|
|
.text;
|
|
|
|
|
2003-05-16 21:26:42 +00:00
|
|
|
|
2000-09-29 13:46:07 +00:00
|
|
|
/*
|
|
|
|
* System call glue.
|
|
|
|
*/
|
2003-05-16 21:26:42 +00:00
|
|
|
#define SYSCALLNUM(name) SYS_ ## name
|
|
|
|
|
|
|
|
#define CALLSYS_NOERROR(name) \
|
2009-10-21 18:09:48 +00:00
|
|
|
.prologue ; \
|
|
|
|
.unwabi @svr4, 'S' ; \
|
|
|
|
.save rp, r0 ; \
|
|
|
|
.body ; \
|
2003-05-16 21:26:42 +00:00
|
|
|
{ .mmi ; \
|
|
|
|
alloc r9 = ar.pfs, 0, 0, 8, 0 ; \
|
|
|
|
mov r31 = ar.k5 ; \
|
|
|
|
mov r10 = b0 ;; } \
|
|
|
|
{ .mib ; \
|
|
|
|
mov r8 = SYSCALLNUM(name) ; \
|
|
|
|
mov b7 = r31 ; \
|
|
|
|
br.call.sptk b0 = b7 ;; }
|
2000-09-29 13:46:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* WEAK_ALIAS: create a weak alias (ELF only).
|
|
|
|
*/
|
|
|
|
#define WEAK_ALIAS(alias,sym) \
|
|
|
|
.weak alias; \
|
|
|
|
alias = sym
|
|
|
|
|
|
|
|
/*
|
2002-09-17 01:49:00 +00:00
|
|
|
* ID tag macros
|
2000-09-29 13:46:07 +00:00
|
|
|
*/
|
2002-03-23 02:01:27 +00:00
|
|
|
#if !defined(lint) && !defined(STRIP_FBSDID)
|
|
|
|
#define __FBSDID(s) .ident s
|
|
|
|
#else
|
|
|
|
#define __FBSDID(s) /* nothing */
|
|
|
|
#endif /* not lint and not STRIP_FBSDID */
|