asm.h revision 1.26
11.26Smatt/*	$NetBSD: asm.h,v 1.26 2012/06/01 06:26:38 matt Exp $ */
21.4Sragge/*
31.4Sragge * Copyright (c) 1982, 1993
41.4Sragge *	The Regents of the University of California.  All rights reserved.
51.1Sragge *
61.1Sragge * Redistribution and use in source and binary forms, with or without
71.1Sragge * modification, are permitted provided that the following conditions
81.1Sragge * are met:
91.1Sragge * 1. Redistributions of source code must retain the above copyright
101.1Sragge *    notice, this list of conditions and the following disclaimer.
111.1Sragge * 2. Redistributions in binary form must reproduce the above copyright
121.1Sragge *    notice, this list of conditions and the following disclaimer in the
131.1Sragge *    documentation and/or other materials provided with the distribution.
141.16Sagc * 3. Neither the name of the University nor the names of its contributors
151.1Sragge *    may be used to endorse or promote products derived from this software
161.1Sragge *    without specific prior written permission.
171.1Sragge *
181.1Sragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
191.1Sragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
201.1Sragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
211.1Sragge * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
221.1Sragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
231.1Sragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
241.1Sragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
251.1Sragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
261.1Sragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
271.1Sragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
281.1Sragge * SUCH DAMAGE.
291.1Sragge *
301.4Sragge *	@(#)DEFS.h	8.1 (Berkeley) 6/4/93
311.1Sragge */
321.1Sragge
331.11Smatt#ifndef _VAX_ASM_H_
341.11Smatt#define _VAX_ASM_H_
351.1Sragge
361.4Sragge#define R0	0x001
371.4Sragge#define R1	0x002
381.4Sragge#define R2	0x004
391.4Sragge#define R3	0x008
401.4Sragge#define R4	0x010
411.4Sragge#define R5	0x020
421.4Sragge#define R6	0x040
431.11Smatt#define R7 	0x080
441.11Smatt#define R8	0x100
451.11Smatt#define R9	0x200
461.11Smatt#define R10	0x400
471.11Smatt#define R11	0x800
481.11Smatt
491.20Smatt#define _C_LABEL(x)	x
501.11Smatt
511.11Smatt#define	_ASM_LABEL(x)	x
521.1Sragge
531.3Sragge#ifdef __STDC__
541.11Smatt# define __CONCAT(x,y)	x ## y
551.11Smatt# define __STRING(x)	#x
561.1Sragge#else
571.11Smatt# define __CONCAT(x,y)	x/**/y
581.11Smatt# define __STRING(x)	"x"
591.1Sragge#endif
601.11Smatt
611.11Smatt/* let kernels and others override entrypoint alignment */
621.11Smatt#ifndef _ALIGN_TEXT
631.23Smatt# define _ALIGN_TEXT .p2align 2
641.11Smatt#endif
651.11Smatt
661.11Smatt#define	_ENTRY(x, regs) \
671.11Smatt	.text; _ALIGN_TEXT; .globl x; .type x@function; x: .word regs
681.11Smatt
691.5Sjtc#ifdef GPROF
701.20Smatt# define _PROF_PROLOGUE	\
711.15Sthorpej	.data; 1:; .long 0; .text; moval 1b,%r0; jsb _ASM_LABEL(__mcount)
721.4Sragge#else
731.11Smatt# define _PROF_PROLOGUE
741.10Skleink#endif
751.11Smatt
761.11Smatt#define ENTRY(x, regs)		_ENTRY(_C_LABEL(x), regs); _PROF_PROLOGUE
771.11Smatt#define NENTRY(x, regs)		_ENTRY(_C_LABEL(x), regs)
781.11Smatt#define ASENTRY(x, regs)	_ENTRY(_ASM_LABEL(x), regs); _PROF_PROLOGUE
791.23Smatt#define END(x)			.size _C_LABEL(x),.-_C_LABEL(x)
801.11Smatt
811.14Smatt#define ALTENTRY(x)		.globl _C_LABEL(x); _C_LABEL(x):
821.19Smatt#define RCSID(name)		.pushsection ".ident"; .asciz name; .popsection
831.19Smatt
841.10Skleink
851.10Skleink#define	WEAK_ALIAS(alias,sym)						\
861.10Skleink	.weak alias;							\
871.10Skleink	alias = sym
881.20Smatt
891.18Schristos/*
901.18Schristos * STRONG_ALIAS: create a strong alias.
911.18Schristos */
921.18Schristos#define STRONG_ALIAS(alias,sym)						\
931.18Schristos	.globl alias;							\
941.18Schristos	alias = sym
951.7Sthorpej
961.7Sthorpej#ifdef __STDC__
971.7Sthorpej#define	WARN_REFERENCES(sym,msg)					\
981.22Sjoerg	.pushsection .gnu.warning. ## sym;				\
991.22Sjoerg	.ascii msg;							\
1001.22Sjoerg	.popsection
1011.7Sthorpej#else
1021.7Sthorpej#define	WARN_REFERENCES(sym,msg)					\
1031.22Sjoerg	.pushsection .gnu.warning./**/sym;				\
1041.22Sjoerg	.ascii msg;							\
1051.22Sjoerg	.popsection
1061.7Sthorpej#endif /* __STDC__ */
1071.1Sragge
1081.24Smatt.macro	polyf arg:req degree:req tbladdr:req
1091.24Smatt	movf	\arg, %r1
1101.24Smatt	movzwl	\degree, %r2
1111.24Smatt	movab	\tbladdr, %r3
1121.24Smatt
1131.26Smatt	movf	(%r3)+, %r0
1141.24Smatt1:
1151.24Smatt	mulf2	%r1, %r0		/* result *= arg */
1161.25Smatt	addf2	(%r3)+, %r0		/* result += c[n] */
1171.24Smatt	sobgtr	%r2, 1b
1181.24Smatt	clrf	%r1			/* r1 is 0 on finish */
1191.24Smatt.endm
1201.24Smatt
1211.24Smatt.macro	polyd arg:req degree:req tbladdr:req
1221.24Smatt	movd	\arg, %r4
1231.24Smatt	movzwl	\degree, %r2
1241.24Smatt	movab	\tbladdr, %r3
1251.24Smatt
1261.26Smatt	movd	(%r3)+,	%r0
1271.24Smatt1:
1281.24Smatt	muld2	%r4, %r0		/* result *= arg */
1291.25Smatt	addd2	(%r3)+, %r0		/* result += c[n] */
1301.24Smatt	sobgtr	%r2, 1b
1311.24Smatt	clrq	%r4			/* r4, r5 are 0 on finish */
1321.24Smatt.endm
1331.24Smatt
1341.11Smatt#endif /* !_VAX_ASM_H_ */
135