asm.h revision 1.29
11.29Smartin/*	$NetBSD: asm.h,v 1.29 2025/01/04 19:02:51 martin 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.29Smartin#ifdef _NETBSD_REVISIONID
831.29Smartin#define RCSID(x)	.pushsection ".ident","MS",@progbits,1;		\
841.29Smartin			.asciz "$" "NetBSD: " __FILE__ 			\
851.29Smartin			    " " _NETBSD_REVISIONID " $";		\
861.29Smartin			.popsection
871.29Smartin#else
881.28Sjoerg#define RCSID(x)	.pushsection ".ident","MS",@progbits,1;		\
891.28Sjoerg			.asciz x;					\
901.28Sjoerg			.popsection
911.29Smartin#endif
921.19Smatt
931.27Sragge#ifdef NO_KERNEL_RCSIDS
941.27Sragge#define __KERNEL_RCSID(_n, _s)  /* nothing */
951.27Sragge#else
961.27Sragge#define __KERNEL_RCSID(_n, _s)  RCSID(_s)
971.27Sragge#endif
981.10Skleink
991.10Skleink#define	WEAK_ALIAS(alias,sym)						\
1001.10Skleink	.weak alias;							\
1011.10Skleink	alias = sym
1021.20Smatt
1031.18Schristos/*
1041.18Schristos * STRONG_ALIAS: create a strong alias.
1051.18Schristos */
1061.18Schristos#define STRONG_ALIAS(alias,sym)						\
1071.18Schristos	.globl alias;							\
1081.18Schristos	alias = sym
1091.7Sthorpej
1101.7Sthorpej#ifdef __STDC__
1111.7Sthorpej#define	WARN_REFERENCES(sym,msg)					\
1121.22Sjoerg	.pushsection .gnu.warning. ## sym;				\
1131.22Sjoerg	.ascii msg;							\
1141.22Sjoerg	.popsection
1151.7Sthorpej#else
1161.7Sthorpej#define	WARN_REFERENCES(sym,msg)					\
1171.22Sjoerg	.pushsection .gnu.warning./**/sym;				\
1181.22Sjoerg	.ascii msg;							\
1191.22Sjoerg	.popsection
1201.7Sthorpej#endif /* __STDC__ */
1211.1Sragge
1221.24Smatt.macro	polyf arg:req degree:req tbladdr:req
1231.24Smatt	movf	\arg, %r1
1241.24Smatt	movzwl	\degree, %r2
1251.24Smatt	movab	\tbladdr, %r3
1261.24Smatt
1271.26Smatt	movf	(%r3)+, %r0
1281.24Smatt1:
1291.24Smatt	mulf2	%r1, %r0		/* result *= arg */
1301.25Smatt	addf2	(%r3)+, %r0		/* result += c[n] */
1311.24Smatt	sobgtr	%r2, 1b
1321.24Smatt	clrf	%r1			/* r1 is 0 on finish */
1331.24Smatt.endm
1341.24Smatt
1351.24Smatt.macro	polyd arg:req degree:req tbladdr:req
1361.24Smatt	movd	\arg, %r4
1371.24Smatt	movzwl	\degree, %r2
1381.24Smatt	movab	\tbladdr, %r3
1391.24Smatt
1401.26Smatt	movd	(%r3)+,	%r0
1411.24Smatt1:
1421.24Smatt	muld2	%r4, %r0		/* result *= arg */
1431.25Smatt	addd2	(%r3)+, %r0		/* result += c[n] */
1441.24Smatt	sobgtr	%r2, 1b
1451.24Smatt	clrq	%r4			/* r4, r5 are 0 on finish */
1461.24Smatt.endm
1471.24Smatt
1481.11Smatt#endif /* !_VAX_ASM_H_ */
149