asm.h revision 66633
1/* $FreeBSD: head/sys/ia64/include/asm.h 66633 2000-10-04 17:53:03Z dfr $ */
2/* From: NetBSD: asm.h,v 1.18 1997/11/03 04:22:06 ross Exp */
3
4/*
5 * Copyright (c) 1991,1990,1989,1994,1995,1996 Carnegie Mellon University
6 * All Rights Reserved.
7 *
8 * Permission to use, copy, modify and distribute this software and its
9 * documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
21 *  School of Computer Science
22 *  Carnegie Mellon University
23 *  Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie Mellon
26 * the rights to redistribute these changes.
27 */
28
29/*
30 *	Assembly coding style
31 *
32 *	This file contains macros and register defines to
33 *	aid in writing more readable assembly code.
34 *	Some rules to make assembly code understandable by
35 *	a debugger are also noted.
36 *
37 *	The document
38 *
39 *		"ALPHA Calling Standard", DEC 27-Apr-90
40 *
41 *	defines (a superset of) the rules and conventions
42 *	we use.  While we make no promise of adhering to
43 *	such standard and its evolution (esp where we
44 *	can get faster code paths) it is certainly intended
45 *	that we be interoperable with such standard.
46 *
47 *	In this sense, this file is a proper part of the
48 *	definition of the (software) Alpha architecture.
49 */
50
51/*
52 * Macro to make a local label name.
53 */
54#define	LLABEL(name,num)	L ## name ## num
55
56/*
57 * MCOUNT
58 */
59
60#if !defined(GPROF) && !defined(PROF)
61#define MCOUNT	/* nothing */
62#else
63#define MCOUNT					\
64	.set noat;				\
65	jsr	at_reg,_mcount;			\
66	.set at
67#endif
68
69/*
70 * ENTRY
71 *	Declare a global leaf function.
72 *	A leaf function does not call other functions.
73 */
74#define	ENTRY(_name_, _n_args_)			\
75	.global	_name_;				\
76	.align	16;				\
77	.proc	_name_;				\
78_name_:;					\
79	.regstk	_n_args_, 0, 0, 0		\
80	MCOUNT
81
82#define	ENTRY_NOPROFILE(_name_, _n_args_)	\
83	.global	_name_;				\
84	.align	16;				\
85	.proc	_name_;				\
86_name_:;					\
87	.regstk	_n_args_, 0, 0, 0
88
89/*
90 * STATIC_ENTRY
91 *	Declare a local leaf function.
92 */
93#define STATIC_ENTRY(_name_, _n_args_)		\
94	.align	16;				\
95	.proc	_name_;				\
96_name_:;					\
97	.regstk	_n_args_, 0, 0, 0		\
98	MCOUNT
99/*
100 * XENTRY
101 *	Global alias for a leaf function, or alternate entry point
102 */
103#define	XENTRY(_name_)				\
104	.globl	_name_;				\
105_name_:
106
107/*
108 * STATIC_XENTRY
109 *	Local alias for a leaf function, or alternate entry point
110 */
111#define	STATIC_XENTRY(_name_)			\
112_name_:
113
114
115/*
116 * END
117 *	Function delimiter
118 */
119#define	END(_name_)						\
120	.endp	_name_
121
122
123/*
124 * EXPORT
125 *	Export a symbol
126 */
127#define	EXPORT(_name_)						\
128	.global	_name_;						\
129_name_:
130
131
132/*
133 * IMPORT
134 *	Make an external name visible, typecheck the size
135 */
136#define	IMPORT(_name_, _size_)					\
137	/* .extern	_name_,_size_ */
138
139
140/*
141 * ABS
142 *	Define an absolute symbol
143 */
144#define	ABS(_name_, _value_)					\
145	.globl	_name_;						\
146_name_	=	_value_
147
148
149/*
150 * BSS
151 *	Allocate un-initialized space for a global symbol
152 */
153#define	BSS(_name_,_numbytes_)					\
154	.comm	_name_,_numbytes_
155
156
157/*
158 * MSG
159 *	Allocate space for a message (a read-only ascii string)
160 */
161#define	ASCIZ	.asciz
162#define	MSG(msg,reg,label)			\
163	addl reg,@ltoff(label),gp;;		\
164	ld8 reg=[reg];;				\
165	.data;					\
166label:	ASCIZ msg;				\
167	.text;
168
169/*
170 * System call glue.
171 */
172#define	SYSCALLNUM(name)			\
173	SYS_ ## name
174
175#define	CALLSYS_NOERROR(name)			\
176	mov	r15=SYSCALLNUM(name);		\
177	break	0x100000 ;;
178
179/*
180 * WEAK_ALIAS: create a weak alias (ELF only).
181 */
182#ifdef __ELF__
183#define WEAK_ALIAS(alias,sym)					\
184	.weak alias;						\
185	alias = sym
186#endif
187
188/*
189 * Kernel RCS ID tag and copyright macros
190 */
191
192#ifdef _KERNEL
193
194#ifdef __ELF__
195#define	__KERNEL_SECTIONSTRING(_sec, _str)				\
196	.section _sec ; .asciz _str ; .text
197#else /* __ELF__ */
198#define	__KERNEL_SECTIONSTRING(_sec, _str)				\
199	.data ; .asciz _str ; .align 3 ; .text
200#endif /* __ELF__ */
201
202#define	__KERNEL_RCSID(_n, _s)		__KERNEL_SECTIONSTRING(.ident, _s)
203#define	__KERNEL_COPYRIGHT(_n, _s)	__KERNEL_SECTIONSTRING(.copyright, _s)
204
205#ifdef NO_KERNEL_RCSIDS
206#undef __KERNEL_RCSID
207#define	__KERNEL_RCSID(_n, _s)		/* nothing */
208#endif
209
210#endif /* _KERNEL */
211