1 /* $NetBSD: asm.h,v 1.30 2025/01/06 10:46:44 martin Exp $ */ 2 /* 3 * Copyright (c) 1982, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Neither the name of the University nor the names of its contributors 15 * may be used to endorse or promote products derived from this software 16 * without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * @(#)DEFS.h 8.1 (Berkeley) 6/4/93 31 */ 32 33 #ifndef _VAX_ASM_H_ 34 #define _VAX_ASM_H_ 35 36 #define R0 0x001 37 #define R1 0x002 38 #define R2 0x004 39 #define R3 0x008 40 #define R4 0x010 41 #define R5 0x020 42 #define R6 0x040 43 #define R7 0x080 44 #define R8 0x100 45 #define R9 0x200 46 #define R10 0x400 47 #define R11 0x800 48 49 #define _C_LABEL(x) x 50 51 #define _ASM_LABEL(x) x 52 53 #ifdef __STDC__ 54 # define __CONCAT(x,y) x ## y 55 # define __STRING(x) #x 56 #else 57 # define __CONCAT(x,y) x/**/y 58 # define __STRING(x) "x" 59 #endif 60 61 /* let kernels and others override entrypoint alignment */ 62 #ifndef _ALIGN_TEXT 63 # define _ALIGN_TEXT .p2align 2 64 #endif 65 66 #define _ENTRY(x, regs) \ 67 .text; _ALIGN_TEXT; .globl x; .type x@function; x: .word regs 68 69 #ifdef GPROF 70 # define _PROF_PROLOGUE \ 71 .data; 1:; .long 0; .text; moval 1b,%r0; jsb _ASM_LABEL(__mcount) 72 #else 73 # define _PROF_PROLOGUE 74 #endif 75 76 #define ENTRY(x, regs) _ENTRY(_C_LABEL(x), regs); _PROF_PROLOGUE 77 #define NENTRY(x, regs) _ENTRY(_C_LABEL(x), regs) 78 #define ASENTRY(x, regs) _ENTRY(_ASM_LABEL(x), regs); _PROF_PROLOGUE 79 #define END(x) .size _C_LABEL(x),.-_C_LABEL(x) 80 81 #define ALTENTRY(x) .globl _C_LABEL(x); _C_LABEL(x): 82 #ifdef _NETBSD_REVISIONID 83 #define RCSID(x) .pushsection ".ident","MS",@progbits,1; \ 84 .asciz x; \ 85 .ascii "$"; .ascii "NetBSD: "; .ascii __FILE__; \ 86 .ascii " "; .ascii _NETBSD_REVISIONID; \ 87 .asciz " $"; \ 88 .popsection 89 #else 90 #define RCSID(x) .pushsection ".ident","MS",@progbits,1; \ 91 .asciz x; \ 92 .popsection 93 #endif 94 95 #ifdef NO_KERNEL_RCSIDS 96 #define __KERNEL_RCSID(_n, _s) /* nothing */ 97 #else 98 #define __KERNEL_RCSID(_n, _s) RCSID(_s) 99 #endif 100 101 #define WEAK_ALIAS(alias,sym) \ 102 .weak alias; \ 103 alias = sym 104 105 /* 106 * STRONG_ALIAS: create a strong alias. 107 */ 108 #define STRONG_ALIAS(alias,sym) \ 109 .globl alias; \ 110 alias = sym 111 112 #ifdef __STDC__ 113 #define WARN_REFERENCES(sym,msg) \ 114 .pushsection .gnu.warning. ## sym; \ 115 .ascii msg; \ 116 .popsection 117 #else 118 #define WARN_REFERENCES(sym,msg) \ 119 .pushsection .gnu.warning./**/sym; \ 120 .ascii msg; \ 121 .popsection 122 #endif /* __STDC__ */ 123 124 .macro polyf arg:req degree:req tbladdr:req 125 movf \arg, %r1 126 movzwl \degree, %r2 127 movab \tbladdr, %r3 128 129 movf (%r3)+, %r0 130 1: 131 mulf2 %r1, %r0 /* result *= arg */ 132 addf2 (%r3)+, %r0 /* result += c[n] */ 133 sobgtr %r2, 1b 134 clrf %r1 /* r1 is 0 on finish */ 135 .endm 136 137 .macro polyd arg:req degree:req tbladdr:req 138 movd \arg, %r4 139 movzwl \degree, %r2 140 movab \tbladdr, %r3 141 142 movd (%r3)+, %r0 143 1: 144 muld2 %r4, %r0 /* result *= arg */ 145 addd2 (%r3)+, %r0 /* result += c[n] */ 146 sobgtr %r2, 1b 147 clrq %r4 /* r4, r5 are 0 on finish */ 148 .endm 149 150 #endif /* !_VAX_ASM_H_ */ 151