Home | History | Annotate | Line # | Download | only in include
asm.h revision 1.1
      1  1.1  cgd /*	$NetBSD: asm.h,v 1.1 1995/02/13 23:07:30 cgd Exp $	*/
      2  1.1  cgd 
      3  1.1  cgd /*
      4  1.1  cgd  * Copyright (c) 1991,1990,1989,1994,1995 Carnegie Mellon University
      5  1.1  cgd  * All Rights Reserved.
      6  1.1  cgd  *
      7  1.1  cgd  * Permission to use, copy, modify and distribute this software and its
      8  1.1  cgd  * documentation is hereby granted, provided that both the copyright
      9  1.1  cgd  * notice and this permission notice appear in all copies of the
     10  1.1  cgd  * software, derivative works or modified versions, and any portions
     11  1.1  cgd  * thereof, and that both notices appear in supporting documentation.
     12  1.1  cgd  *
     13  1.1  cgd  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     14  1.1  cgd  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
     15  1.1  cgd  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     16  1.1  cgd  *
     17  1.1  cgd  * Carnegie Mellon requests users of this software to return to
     18  1.1  cgd  *
     19  1.1  cgd  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     20  1.1  cgd  *  School of Computer Science
     21  1.1  cgd  *  Carnegie Mellon University
     22  1.1  cgd  *  Pittsburgh PA 15213-3890
     23  1.1  cgd  *
     24  1.1  cgd  * any improvements or extensions that they make and grant Carnegie Mellon
     25  1.1  cgd  * the rights to redistribute these changes.
     26  1.1  cgd  */
     27  1.1  cgd 
     28  1.1  cgd /*
     29  1.1  cgd  *	Assembly coding style
     30  1.1  cgd  *
     31  1.1  cgd  *	This file contains macros and register defines to
     32  1.1  cgd  *	aid in writing more readable assembly code.
     33  1.1  cgd  *	Some rules to make assembly code understandable by
     34  1.1  cgd  *	a debugger are also noted.
     35  1.1  cgd  *
     36  1.1  cgd  *	The document
     37  1.1  cgd  *
     38  1.1  cgd  *		"ALPHA Calling Standard", DEC 27-Apr-90
     39  1.1  cgd  *
     40  1.1  cgd  *	defines (a superset of) the rules and conventions
     41  1.1  cgd  *	we use.  While we make no promise of adhering to
     42  1.1  cgd  *	such standard and its evolution (esp where we
     43  1.1  cgd  *	can get faster code paths) it is certainly intended
     44  1.1  cgd  *	that we be interoperable with such standard.
     45  1.1  cgd  *
     46  1.1  cgd  *	In this sense, this file is a proper part of the
     47  1.1  cgd  *	definition of the (software) Alpha architecture.
     48  1.1  cgd  */
     49  1.1  cgd 
     50  1.1  cgd /*
     51  1.1  cgd  *	Symbolic register names and register saving rules
     52  1.1  cgd  *
     53  1.1  cgd  *	Legend:
     54  1.1  cgd  *		T	Saved by caller (Temporaries)
     55  1.1  cgd  *		S	Saved by callee (call-Safe registers)
     56  1.1  cgd  */
     57  1.1  cgd 
     58  1.1  cgd #define	v0	$0	/* (T)		return value		*/
     59  1.1  cgd #define t0	$1	/* (T)		temporary registers	*/
     60  1.1  cgd #define t1	$2
     61  1.1  cgd #define t2	$3
     62  1.1  cgd #define t3	$4
     63  1.1  cgd #define t4	$5
     64  1.1  cgd #define t5	$6
     65  1.1  cgd #define t6	$7
     66  1.1  cgd #define t7	$8
     67  1.1  cgd 
     68  1.1  cgd #define s0	$9	/* (S)		call-safe registers	*/
     69  1.1  cgd #define s1	$10
     70  1.1  cgd #define s2	$11
     71  1.1  cgd #define s3	$12
     72  1.1  cgd #define s4	$13
     73  1.1  cgd #define s5	$14
     74  1.1  cgd #define s6	$15
     75  1.1  cgd #define a0	$16	/* (T)		argument registers	*/
     76  1.1  cgd #define a1	$17
     77  1.1  cgd #define a2	$18
     78  1.1  cgd #define a3	$19
     79  1.1  cgd #define a4	$20
     80  1.1  cgd #define a5	$21
     81  1.1  cgd #define t8	$22	/* (T)		temporary registers	*/
     82  1.1  cgd #define t9	$23
     83  1.1  cgd #define t10	$24
     84  1.1  cgd #define t11	$25
     85  1.1  cgd #define ra	$26	/* (T)		return address		*/
     86  1.1  cgd #define t12	$27	/* (T)		another temporary	*/
     87  1.1  cgd #define at_reg	$28	/* (T)		assembler scratch	*/
     88  1.1  cgd #define	gp	$29	/* (T)		(local) data pointer	*/
     89  1.1  cgd #define sp	$30	/* (S)		stack pointer		*/
     90  1.1  cgd #define zero	$31	/* 		wired zero		*/
     91  1.1  cgd 
     92  1.1  cgd /* Floating point registers  (XXXX VERIFY THIS) */
     93  1.1  cgd #define	fv0	$f0	/* (T)		return value (real)	*/
     94  1.1  cgd #define	fv1	$f1	/* (T)		return value (imaginary)*/
     95  1.1  cgd #define	ft0	fv1
     96  1.1  cgd #define	fs0	$f2	/* (S)		call-safe registers	*/
     97  1.1  cgd #define	fs1	$f3
     98  1.1  cgd #define	fs2	$f4
     99  1.1  cgd #define	fs3	$f5
    100  1.1  cgd #define	fs4	$f6
    101  1.1  cgd #define	fs5	$f7
    102  1.1  cgd #define	fs6	$f8
    103  1.1  cgd #define	fs7	$f9
    104  1.1  cgd #define	ft1	$f10	/* (T)		temporary registers	*/
    105  1.1  cgd #define	ft2	$f11
    106  1.1  cgd #define	ft3	$f12
    107  1.1  cgd #define	ft4	$f13
    108  1.1  cgd #define	ft5	$f14
    109  1.1  cgd #define	ft6	$f15
    110  1.1  cgd #define	fa0	$f16	/* (T)		argument registers	*/
    111  1.1  cgd #define	fa1	$f17
    112  1.1  cgd #define	fa2	$f18
    113  1.1  cgd #define	fa3	$f19
    114  1.1  cgd #define	fa4	$f20
    115  1.1  cgd #define	fa5	$f21
    116  1.1  cgd #define	ft7	$f22	/* (T)		more temporaries	*/
    117  1.1  cgd #define	ft8	$f23
    118  1.1  cgd #define	ft9	$f24
    119  1.1  cgd #define	ft10	$f25
    120  1.1  cgd #define	ft11	$f26
    121  1.1  cgd #define	ft12	$f27
    122  1.1  cgd #define	ft13	$f28
    123  1.1  cgd #define	ft14	$f29
    124  1.1  cgd #define	ft15	$f30
    125  1.1  cgd #define	fzero	$f31	/*		wired zero		*/
    126  1.1  cgd 
    127  1.1  cgd 
    128  1.1  cgd /* Other DEC standard names */
    129  1.1  cgd #define ai	$25	/* (T)		argument information	*/
    130  1.1  cgd #define pv	$27	/* (T)		procedure value		*/
    131  1.1  cgd 
    132  1.1  cgd /*
    133  1.1  cgd  *
    134  1.1  cgd  * Debuggers need symbol table information to be able to properly
    135  1.1  cgd  * decode a stack trace.  The minimum that should be provided is:
    136  1.1  cgd  *
    137  1.1  cgd  * 	name:
    138  1.1  cgd  *		.proc	name,numargs
    139  1.1  cgd  *
    140  1.1  cgd  * where "name" 	is the function's name;
    141  1.1  cgd  *	 "numargs"	how many arguments it expects. For varargs
    142  1.1  cgd  *			procedures this should be a negative number,
    143  1.1  cgd  *			indicating the minimum required number of
    144  1.1  cgd  *			arguments (which is at least 1);
    145  1.1  cgd  *
    146  1.1  cgd  * NESTED functions (functions that call other functions) should define
    147  1.1  cgd  * how they handle their stack frame in a .frame directive:
    148  1.1  cgd  *
    149  1.1  cgd  *		.frame	framesize, pc_reg, i_mask, f_mask
    150  1.1  cgd  *
    151  1.1  cgd  * where "framesize"	is the size of the frame for this function, in bytes.
    152  1.1  cgd  *			That is:
    153  1.1  cgd  *				new_sp + framesize == old_sp
    154  1.1  cgd  *			Framesizes should be rounded to a cacheline size.
    155  1.1  cgd  *			Note that old_sp plays the role of a conventional
    156  1.1  cgd  *			"frame pointer";
    157  1.1  cgd  *	 "pc_reg"	is either a register which preserves the caller's PC
    158  1.1  cgd  *			or 'std', if std the saved PC should be stored at
    159  1.1  cgd  *				old_sp-8
    160  1.1  cgd  * 	 "i_mask"	is a bitmask that indicates which of the integer
    161  1.1  cgd  *			registers are saved. See the M_xx defines at the
    162  1.1  cgd  *			end for the encoding of this 32bit value.
    163  1.1  cgd  *	 "f_mask"	is the same, for floating point registers.
    164  1.1  cgd  *
    165  1.1  cgd  * Note that registers should be saved starting at "old_sp-8", where the
    166  1.1  cgd  * return address should be stored. Other registers follow at -16-24-32..
    167  1.1  cgd  * starting from register 0 (if saved) and up. Then float registers (ifany)
    168  1.1  cgd  * are saved.
    169  1.1  cgd  *
    170  1.1  cgd  * If you need to alias a leaf function, or to provide multiple entry points
    171  1.1  cgd  * use the LEAF() macro for the main entry point and XLEAF() for the other
    172  1.1  cgd  * additional/alternate entry points.
    173  1.1  cgd  * "XLEAF"s must be nested within a "LEAF" and a ".end".
    174  1.1  cgd  * Similar rules for nested routines, e.g. use NESTED/XNESTED
    175  1.1  cgd  * Symbols that should not be exported can be declared with the STATIC_xxx
    176  1.1  cgd  * macros.
    177  1.1  cgd  *
    178  1.1  cgd  * All functions must be terminated by the END macro
    179  1.1  cgd  *
    180  1.1  cgd  * It is conceivable, although currently at the limits of compiler
    181  1.1  cgd  * technology, that while performing inter-procedural optimizations
    182  1.1  cgd  * the compiler/linker be able to avoid unnecessary register spills
    183  1.1  cgd  * if told about the register usage of LEAF procedures (and by transitive
    184  1.1  cgd  * closure of NESTED procedures as well).  Assembly code can help
    185  1.1  cgd  * this process using the .reguse directive:
    186  1.1  cgd  *
    187  1.1  cgd  *		.reguse	i_mask, f_mask
    188  1.1  cgd  *
    189  1.1  cgd  * where the register masks are built as above or-ing M_xx defines.
    190  1.1  cgd  *
    191  1.1  cgd  *
    192  1.1  cgd  * All symbols are internal unless EXPORTed.  Symbols that are IMPORTed
    193  1.1  cgd  * must be appropriately described to the debugger.
    194  1.1  cgd  *
    195  1.1  cgd  */
    196  1.1  cgd 
    197  1.1  cgd /*
    198  1.1  cgd  * LEAF
    199  1.1  cgd  *	Declare a global leaf function.
    200  1.1  cgd  *	A leaf function does not call other functions AND does not
    201  1.1  cgd  *	use any register that is callee-saved AND does not modify
    202  1.1  cgd  *	the stack pointer.
    203  1.1  cgd  */
    204  1.1  cgd #define	LEAF(_name_,_n_args_)					\
    205  1.1  cgd 	.globl	_name_;						\
    206  1.1  cgd 	.ent	_name_ 0;					\
    207  1.1  cgd _name_:;							\
    208  1.1  cgd 	.frame	sp,0,ra
    209  1.1  cgd /* should have been
    210  1.1  cgd 	.proc	_name_,_n_args_;				\
    211  1.1  cgd 	.frame	0,ra,0,0
    212  1.1  cgd */
    213  1.1  cgd 
    214  1.1  cgd /*
    215  1.1  cgd  * STATIC_LEAF
    216  1.1  cgd  *	Declare a local leaf function.
    217  1.1  cgd  */
    218  1.1  cgd #define STATIC_LEAF(_name_,_n_args_)				\
    219  1.1  cgd 	.ent	_name_ 0;					\
    220  1.1  cgd _name_:;							\
    221  1.1  cgd 	.frame	sp,0,ra
    222  1.1  cgd /* should have been
    223  1.1  cgd 	.proc	_name_,_n_args_;				\
    224  1.1  cgd 	.frame	0,ra,0,0
    225  1.1  cgd */
    226  1.1  cgd /*
    227  1.1  cgd  * XLEAF
    228  1.1  cgd  *	Global alias for a leaf function, or alternate entry point
    229  1.1  cgd  */
    230  1.1  cgd #define	XLEAF(_name_,_n_args_)					\
    231  1.1  cgd 	.globl	_name_;						\
    232  1.1  cgd 	.aent	_name_ 0;					\
    233  1.1  cgd _name_:
    234  1.1  cgd /* should have been
    235  1.1  cgd 	.aproc	_name_,_n_args_;
    236  1.1  cgd */
    237  1.1  cgd 
    238  1.1  cgd /*
    239  1.1  cgd  * STATIC_XLEAF
    240  1.1  cgd  *	Local alias for a leaf function, or alternate entry point
    241  1.1  cgd  */
    242  1.1  cgd #define	STATIC_XLEAF(_name_,_n_args_)				\
    243  1.1  cgd 	.aent	_name_ 0;					\
    244  1.1  cgd _name_:
    245  1.1  cgd /* should have been
    246  1.1  cgd 	.aproc	_name_,_n_args_;
    247  1.1  cgd */
    248  1.1  cgd 
    249  1.1  cgd /*
    250  1.1  cgd  * NESTED
    251  1.1  cgd  *	Declare a (global) nested function
    252  1.1  cgd  *	A nested function calls other functions and needs
    253  1.1  cgd  *	therefore stack space to save/restore registers.
    254  1.1  cgd  */
    255  1.1  cgd #define	NESTED(_name_, _n_args_, _framesize_, _pc_reg_, _i_mask_, _f_mask_ ) \
    256  1.1  cgd 	.globl	_name_;						\
    257  1.1  cgd 	.ent	_name_ 0;					\
    258  1.1  cgd _name_:;							\
    259  1.1  cgd 	.frame	sp,_framesize_,_pc_reg_;			\
    260  1.1  cgd 	.livereg _i_mask_,_f_mask_
    261  1.1  cgd /* should have been
    262  1.1  cgd 	.proc	_name_,_n_args_;				\
    263  1.1  cgd 	.frame	_framesize_, _pc_reg_, _i_mask_, _f_mask_
    264  1.1  cgd */
    265  1.1  cgd 
    266  1.1  cgd /*
    267  1.1  cgd  * STATIC_NESTED
    268  1.1  cgd  *	Declare a local nested function.
    269  1.1  cgd  */
    270  1.1  cgd #define	STATIC_NESTED(_name_, _n_args_, _framesize_, _pc_reg_, _i_mask_, _f_mask_ ) \
    271  1.1  cgd 	.ent	_name_ 0;					\
    272  1.1  cgd _name_:;							\
    273  1.1  cgd 	.frame	sp,_framesize_,_pc_reg_;			\
    274  1.1  cgd 	.livereg _i_mask_,_f_mask_
    275  1.1  cgd /* should have been
    276  1.1  cgd 	.proc	_name_,_n_args_;				\
    277  1.1  cgd 	.frame	_framesize_, _pc_reg_, _i_mask_, _f_mask_
    278  1.1  cgd */
    279  1.1  cgd 
    280  1.1  cgd /*
    281  1.1  cgd  * XNESTED
    282  1.1  cgd  *	Same as XLEAF, for a nested function.
    283  1.1  cgd  */
    284  1.1  cgd #define	XNESTED(_name_,_n_args_)				\
    285  1.1  cgd 	.globl	_name_;						\
    286  1.1  cgd 	.aent	_name_ 0;					\
    287  1.1  cgd _name_:
    288  1.1  cgd /* should have been
    289  1.1  cgd 	.aproc	_name_,_n_args_;
    290  1.1  cgd */
    291  1.1  cgd 
    292  1.1  cgd 
    293  1.1  cgd /*
    294  1.1  cgd  * STATIC_XNESTED
    295  1.1  cgd  *	Same as STATIC_XLEAF, for a nested function.
    296  1.1  cgd  */
    297  1.1  cgd #define	STATIC_XNESTED(_name_,_n_args_)				\
    298  1.1  cgd 	.aent	_name_ 0;					\
    299  1.1  cgd _name_:
    300  1.1  cgd /* should have been
    301  1.1  cgd 	.aproc	_name_,_n_args_;
    302  1.1  cgd */
    303  1.1  cgd 
    304  1.1  cgd 
    305  1.1  cgd /*
    306  1.1  cgd  * END
    307  1.1  cgd  *	Function delimiter
    308  1.1  cgd  */
    309  1.1  cgd #define	END(_name_)						\
    310  1.1  cgd 	.end	_name_
    311  1.1  cgd 
    312  1.1  cgd 
    313  1.1  cgd /*
    314  1.1  cgd  * CALL
    315  1.1  cgd  *	Function invocation
    316  1.1  cgd  */
    317  1.1  cgd #define	CALL(_name_)						\
    318  1.1  cgd 	jsr	ra,_name_;					\
    319  1.1  cgd 	ldgp	gp,0(ra)
    320  1.1  cgd /* but this would cover longer jumps
    321  1.1  cgd 	br	ra,.+4;						\
    322  1.1  cgd 	bsr	ra,_name_
    323  1.1  cgd */
    324  1.1  cgd 
    325  1.1  cgd 
    326  1.1  cgd /*
    327  1.1  cgd  * RET
    328  1.1  cgd  *	Return from function
    329  1.1  cgd  */
    330  1.1  cgd #define	RET							\
    331  1.1  cgd 	ret	zero,(ra),1
    332  1.1  cgd 
    333  1.1  cgd 
    334  1.1  cgd /*
    335  1.1  cgd  * EXPORT
    336  1.1  cgd  *	Export a symbol
    337  1.1  cgd  */
    338  1.1  cgd #define	EXPORT(_name_)						\
    339  1.1  cgd 	.globl	_name_;						\
    340  1.1  cgd _name_:
    341  1.1  cgd 
    342  1.1  cgd 
    343  1.1  cgd /*
    344  1.1  cgd  * IMPORT
    345  1.1  cgd  *	Make an external name visible, typecheck the size
    346  1.1  cgd  */
    347  1.1  cgd #define	IMPORT(_name_, _size_)					\
    348  1.1  cgd 	.extern	_name_,_size_
    349  1.1  cgd 
    350  1.1  cgd 
    351  1.1  cgd /*
    352  1.1  cgd  * ABS
    353  1.1  cgd  *	Define an absolute symbol
    354  1.1  cgd  */
    355  1.1  cgd #define	ABS(_name_, _value_)					\
    356  1.1  cgd 	.globl	_name_;						\
    357  1.1  cgd _name_	=	_value_
    358  1.1  cgd 
    359  1.1  cgd 
    360  1.1  cgd /*
    361  1.1  cgd  * BSS
    362  1.1  cgd  *	Allocate un-initialized space for a global symbol
    363  1.1  cgd  */
    364  1.1  cgd #define	BSS(_name_,_numbytes_)					\
    365  1.1  cgd 	.comm	_name_,_numbytes_
    366  1.1  cgd 
    367  1.1  cgd /*
    368  1.1  cgd  * VECTOR
    369  1.1  cgd  *	Make an exception entry point look like a called function,
    370  1.1  cgd  *	to make it digestible to the debugger (KERNEL only)
    371  1.1  cgd  */
    372  1.1  cgd #define	VECTOR(_name_, _i_mask_)				\
    373  1.1  cgd 	.globl	_name_;						\
    374  1.1  cgd 	.ent	_name_ 0;					\
    375  1.1  cgd _name_:;							\
    376  1.1  cgd 	.mask	_i_mask_|IM_EXC,0;				\
    377  1.1  cgd 	.frame	sp,MSS_SIZE,ra;
    378  1.1  cgd /*	.livereg _i_mask_|IM_EXC,0
    379  1.1  cgd /* should have been
    380  1.1  cgd 	.proc	_name_,1;					\
    381  1.1  cgd 	.frame	MSS_SIZE,$31,_i_mask_,0;			\
    382  1.1  cgd */
    383  1.1  cgd 
    384  1.1  cgd /*
    385  1.1  cgd  * MSG
    386  1.1  cgd  *	Allocate space for a message (a read-only ascii string)
    387  1.1  cgd  */
    388  1.1  cgd #ifdef __ALPHA_AS__
    389  1.1  cgd #define	ASCIZ	.asciiz
    390  1.1  cgd #else
    391  1.1  cgd #define	ASCIZ	.asciz
    392  1.1  cgd #endif
    393  1.1  cgd #define	MSG(msg,reg)						\
    394  1.1  cgd 	lda reg, 9f;						\
    395  1.1  cgd 	.data;							\
    396  1.1  cgd 9:	ASCIZ msg;						\
    397  1.1  cgd 	.text;
    398  1.1  cgd 
    399  1.1  cgd /*
    400  1.1  cgd  * PRINTF
    401  1.1  cgd  *	Print a message
    402  1.1  cgd  */
    403  1.1  cgd #define	PRINTF(msg)						\
    404  1.1  cgd 	MSG(msg,a0);						\
    405  1.1  cgd 	CALL(printf)
    406  1.1  cgd 
    407  1.1  cgd /*
    408  1.1  cgd  * PANIC
    409  1.1  cgd  *	Fatal error (KERNEL)
    410  1.1  cgd  */
    411  1.1  cgd #define	PANIC(msg)						\
    412  1.1  cgd 	MSG(msg,a0);						\
    413  1.1  cgd 	CALL(panic)
    414  1.1  cgd 
    415  1.1  cgd /*
    416  1.1  cgd  * Register mask defines, used to define both save
    417  1.1  cgd  * and use register sets.
    418  1.1  cgd  *
    419  1.1  cgd  * NOTE: The bit order should HAVE BEEN maintained when saving
    420  1.1  cgd  *	 registers on the stack: sp goes at the highest
    421  1.1  cgd  *	 address, gp lower on the stack, etc etc
    422  1.1  cgd  *	 BUT NOONE CARES ABOUT DEBUGGERS AT MIPS
    423  1.1  cgd  */
    424  1.1  cgd 
    425  1.1  cgd #define	IM_EXC	0x80000000
    426  1.1  cgd #define	IM_SP	0x40000000
    427  1.1  cgd #define	IM_GP	0x20000000
    428  1.1  cgd #define	IM_AT	0x10000000
    429  1.1  cgd #define	IM_T12	0x08000000
    430  1.1  cgd #	define	IM_PV	IM_T4
    431  1.1  cgd #define	IM_RA	0x04000000
    432  1.1  cgd #define	IM_T11	0x02000000
    433  1.1  cgd #	define	IM_AI	IM_T3
    434  1.1  cgd #define	IM_T10	0x01000000
    435  1.1  cgd #define	IM_T9	0x00800000
    436  1.1  cgd #define	IM_T8	0x00400000
    437  1.1  cgd #define	IM_A5	0x00200000
    438  1.1  cgd #define	IM_A4	0x00100000
    439  1.1  cgd #define	IM_A3	0x00080000
    440  1.1  cgd #define	IM_A2	0x00040000
    441  1.1  cgd #define	IM_A1	0x00020000
    442  1.1  cgd #define	IM_A0	0x00010000
    443  1.1  cgd #define	IM_S6	0x00008000
    444  1.1  cgd #define	IM_S5	0x00004000
    445  1.1  cgd #define	IM_S4	0x00002000
    446  1.1  cgd #define	IM_S3	0x00001000
    447  1.1  cgd #define	IM_S2	0x00000800
    448  1.1  cgd #define	IM_S1	0x00000400
    449  1.1  cgd #define	IM_S0	0x00000200
    450  1.1  cgd #define	IM_T7	0x00000100
    451  1.1  cgd #define	IM_T6	0x00000080
    452  1.1  cgd #define	IM_T5	0x00000040
    453  1.1  cgd #define	IM_T4	0x00000020
    454  1.1  cgd #define	IM_T3	0x00000010
    455  1.1  cgd #define	IM_T2	0x00000008
    456  1.1  cgd #define	IM_T1	0x00000004
    457  1.1  cgd #define	IM_T0	0x00000002
    458  1.1  cgd #define	IM_V0	0x00000001
    459  1.1  cgd 
    460  1.1  cgd #define	FM_T15	0x40000000
    461  1.1  cgd #define	FM_T14	0x20000000
    462  1.1  cgd #define	FM_T13	0x10000000
    463  1.1  cgd #define	FM_T12	0x08000000
    464  1.1  cgd #define	FM_T11	0x04000000
    465  1.1  cgd #define	FM_T10	0x02000000
    466  1.1  cgd #define	FM_T9	0x01000000
    467  1.1  cgd #define	FM_T8	0x00800000
    468  1.1  cgd #define	FM_T7	0x00400000
    469  1.1  cgd #define	FM_A5	0x00200000
    470  1.1  cgd #define	FM_A4	0x00100000
    471  1.1  cgd #define	FM_A3	0x00080000
    472  1.1  cgd #define	FM_A2	0x00040000
    473  1.1  cgd #define	FM_A1	0x00020000
    474  1.1  cgd #define	FM_A0	0x00010000
    475  1.1  cgd #define	FM_T6	0x00008000
    476  1.1  cgd #define	FM_T5	0x00004000
    477  1.1  cgd #define	FM_T4	0x00002000
    478  1.1  cgd #define	FM_T3	0x00001000
    479  1.1  cgd #define	FM_T2	0x00000800
    480  1.1  cgd #define	FM_T1	0x00000400
    481  1.1  cgd #define	FM_S7	0x00000200
    482  1.1  cgd #define	FM_S6	0x00000100
    483  1.1  cgd #define	FM_S5	0x00000080
    484  1.1  cgd #define	FM_S4	0x00000040
    485  1.1  cgd #define	FM_S3	0x00000020
    486  1.1  cgd #define	FM_S2	0x00000010
    487  1.1  cgd #define	FM_S1	0x00000008
    488  1.1  cgd #define	FM_S0	0x00000004
    489  1.1  cgd #define	FM_T0	0x00000002
    490  1.1  cgd #define	FM_V1	FM_T0
    491  1.1  cgd #define	FM_V0	0x00000001
    492  1.1  cgd 
    493  1.1  cgd /*
    494  1.1  cgd  * PAL "function" codes (used as arguments to call_pal instructions).
    495  1.1  cgd  *
    496  1.1  cgd  * Those marked with "P" are privileged, and those marked with "U"
    497  1.1  cgd  * are unprivileged.
    498  1.1  cgd  */
    499  1.1  cgd 
    500  1.1  cgd /* Common PAL codes. */
    501  1.1  cgd #define	PAL_halt		0x0000			/* P */
    502  1.1  cgd #define	PAL_draina		0x0002			/* P */
    503  1.1  cgd #define	PAL_swppal		0x000a			/* P */
    504  1.1  cgd #define	PAL_bpt			0x0080			/* U */
    505  1.1  cgd #define	PAL_bugchk		0x0081			/* U */
    506  1.1  cgd #define	PAL_imb			0x0086			/* U */
    507  1.1  cgd #define	PAL_rdunique		0x009e			/* U */
    508  1.1  cgd #define	PAL_wrunique		0x009f			/* U */
    509  1.1  cgd #define	PAL_gentrap		0x00aa			/* U */
    510  1.1  cgd 
    511  1.1  cgd /* VMS PAL codes. */
    512  1.1  cgd #define	PAL_VMS_ldqp		0x0003			/* P */
    513  1.1  cgd #define	PAL_VMS_stqp		0x0004			/* P */
    514  1.1  cgd #define	PAL_VMS_mtpr_fen	0x000c			/* P */
    515  1.1  cgd #define	PAL_VMS_mtpr_ipir	0x000d			/* P */
    516  1.1  cgd #define	PAL_VMS_mfpr_ipl	0x000e			/* P */
    517  1.1  cgd #define	PAL_VMS_mtpr_ipl	0x000f			/* P */
    518  1.1  cgd #define	PAL_VMS_mfpr_mces	0x0010			/* P */
    519  1.1  cgd #define	PAL_VMS_mtpr_mces	0x0011			/* P */
    520  1.1  cgd #define	PAL_VMS_mfpr_prbr	0x0013			/* P */
    521  1.1  cgd #define	PAL_VMS_mtpr_prbr	0x0014			/* P */
    522  1.1  cgd #define	PAL_VMS_mfpr_ptbr	0x0015			/* P */
    523  1.1  cgd #define	PAL_VMS_mtpr_scbb	0x0017			/* P */
    524  1.1  cgd #define	PAL_VMS_mtpr_sirr	0x0018			/* P */
    525  1.1  cgd #define	PAL_VMS_mtpr_tbia	0x001b			/* P */
    526  1.1  cgd #define	PAL_VMS_mtpr_tbiap	0x001c			/* P */
    527  1.1  cgd #define	PAL_VMS_mtpr_tbis	0x001d			/* P */
    528  1.1  cgd #define	PAL_VMS_mfpr_usp	0x0022			/* P */
    529  1.1  cgd #define	PAL_VMS_mtpr_usp	0x0023			/* P */
    530  1.1  cgd #define	PAL_VMS_mfpr_vptb	0x0029			/* P */
    531  1.1  cgd #define	PAL_VMS_mfpr_whami	0x003f			/* P */
    532  1.1  cgd #define	PAL_VMS_rei		0x0092			/* U */
    533  1.1  cgd 
    534  1.1  cgd /* OSF/1 PAL codes. */
    535  1.1  cgd #define	PAL_OSF1_wrfen		0x002b			/* P */
    536  1.1  cgd #define	PAL_OSF1_wrvptptr	0x002d			/* P */
    537  1.1  cgd #define	PAL_OSF1_swpctx		0x0030			/* P */
    538  1.1  cgd #define	PAL_OSF1_wrval		0x0031			/* P */
    539  1.1  cgd #define	PAL_OSF1_rdval		0x0032			/* P */
    540  1.1  cgd #define	PAL_OSF1_tbi		0x0033			/* P */
    541  1.1  cgd #define	PAL_OSF1_wrent		0x0034			/* P */
    542  1.1  cgd #define	PAL_OSF1_swpipl		0x0035			/* P */
    543  1.1  cgd #define	PAL_OSF1_rdps		0x0036			/* P */
    544  1.1  cgd #define	PAL_OSF1_wrkgp		0x0037			/* P */
    545  1.1  cgd #define	PAL_OSF1_wrusp		0x0038			/* P */
    546  1.1  cgd #define	PAL_OSF1_rdusp		0x003a			/* P */
    547  1.1  cgd #define	PAL_OSF1_whami		0x003c			/* P */
    548  1.1  cgd #define	PAL_OSF1_retsys		0x003d			/* P */
    549  1.1  cgd #define	PAL_OSF1_rti		0x003f			/* P */
    550  1.1  cgd #define	PAL_OSF1_callsys	0x0083			/* U */
    551  1.1  cgd #define	PAL_OSF1_imb		0x0086			/* U */
    552  1.1  cgd 
    553  1.1  cgd /*
    554  1.1  cgd  * Defintions to make things portable between gcc and OSF/1 cc.
    555  1.1  cgd  */
    556  1.1  cgd #define	SETGP(pv)	ldgp	gp,0(pv)
    557  1.1  cgd 
    558  1.1  cgd #ifdef __ALPHA_AS__
    559  1.1  cgd #define	MF_FPCR(x)	mf_fpcr x,x,x
    560  1.1  cgd #define	MT_FPCR(x)	mt_fpcr x,x,x
    561  1.1  cgd #define	JMP(loc)	jmp	loc
    562  1.1  cgd #define	CONST(c,reg)	mov	c, reg
    563  1.1  cgd #else
    564  1.1  cgd #define	MF_FPCR(x)	mf_fpcr x
    565  1.1  cgd #define	MT_FPCR(x)	mt_fpcr x
    566  1.1  cgd #define	JMP(loc)	br	zero,loc
    567  1.1  cgd #define	CONST(c,reg)	ldiq	reg, c
    568  1.1  cgd #endif
    569  1.1  cgd 
    570