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 38/* 39 * Macro to make a local label name. 40 */ 41#define LLABEL(name,num) L ## name ## num 42 43/* 44 * MCOUNT 45 */ 46 47#if !defined(GPROF) && !defined(PROF) 48#define MCOUNT /* nothing */ 49#else 50#define MCOUNT \ 51 br.call.sptk.many b7=_mcount 52#endif 53 54/* 55 * ENTRY 56 * Declare a global leaf function. 57 * A leaf function does not call other functions. 58 */ 59#define ENTRY(_name_, _n_args_) \ 60 .global _name_; \ 61 .align 16; \ 62 .proc _name_; \ 63_name_:; \ 64 .regstk _n_args_, 0, 0, 0 \ 65 MCOUNT 66 67#define ENTRY_NOPROFILE(_name_, _n_args_) \ 68 .global _name_; \ 69 .align 16; \ 70 .proc _name_; \ 71_name_:; \ 72 .regstk _n_args_, 0, 0, 0 73 74/* 75 * STATIC_ENTRY 76 * Declare a local leaf function. 77 */ 78#define STATIC_ENTRY(_name_, _n_args_) \ 79 .align 16; \ 80 .proc _name_; \ 81_name_:; \ 82 .regstk _n_args_, 0, 0, 0 \ 83 MCOUNT 84/* 85 * XENTRY 86 * Global alias for a leaf function, or alternate entry point 87 */ 88#define XENTRY(_name_) \ 89 .globl _name_; \ 90_name_: 91 92/* 93 * STATIC_XENTRY 94 * Local alias for a leaf function, or alternate entry point 95 */ 96#define STATIC_XENTRY(_name_) \ 97_name_: 98 99 100/* 101 * END 102 * Function delimiter 103 */ 104#define END(_name_) \ 105 .endp _name_ 106 107 108/* 109 * EXPORT 110 * Export a symbol 111 */ 112#define EXPORT(_name_) \ 113 .global _name_; \ 114_name_: 115 116 117/* 118 * IMPORT 119 * Make an external name visible, typecheck the size 120 */ 121#define IMPORT(_name_, _size_) \ 122 /* .extern _name_,_size_ */ 123 124 125/* 126 * ABS 127 * Define an absolute symbol 128 */ 129#define ABS(_name_, _value_) \ 130 .globl _name_; \ 131_name_ = _value_ 132 133 134/* 135 * BSS 136 * Allocate un-initialized space for a global symbol 137 */ 138#define BSS(_name_,_numbytes_) \ 139 .comm _name_,_numbytes_ 140 141 142/* 143 * MSG 144 * Allocate space for a message (a read-only ascii string) 145 */ 146#define ASCIZ .asciz 147#define MSG(msg,reg,label) \ 148 addl reg,@ltoff(label),gp;; \ 149 ld8 reg=[reg];; \ 150 .data; \ 151label: ASCIZ msg; \ 152 .text; 153
| 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 38/* 39 * Macro to make a local label name. 40 */ 41#define LLABEL(name,num) L ## name ## num 42 43/* 44 * MCOUNT 45 */ 46 47#if !defined(GPROF) && !defined(PROF) 48#define MCOUNT /* nothing */ 49#else 50#define MCOUNT \ 51 br.call.sptk.many b7=_mcount 52#endif 53 54/* 55 * ENTRY 56 * Declare a global leaf function. 57 * A leaf function does not call other functions. 58 */ 59#define ENTRY(_name_, _n_args_) \ 60 .global _name_; \ 61 .align 16; \ 62 .proc _name_; \ 63_name_:; \ 64 .regstk _n_args_, 0, 0, 0 \ 65 MCOUNT 66 67#define ENTRY_NOPROFILE(_name_, _n_args_) \ 68 .global _name_; \ 69 .align 16; \ 70 .proc _name_; \ 71_name_:; \ 72 .regstk _n_args_, 0, 0, 0 73 74/* 75 * STATIC_ENTRY 76 * Declare a local leaf function. 77 */ 78#define STATIC_ENTRY(_name_, _n_args_) \ 79 .align 16; \ 80 .proc _name_; \ 81_name_:; \ 82 .regstk _n_args_, 0, 0, 0 \ 83 MCOUNT 84/* 85 * XENTRY 86 * Global alias for a leaf function, or alternate entry point 87 */ 88#define XENTRY(_name_) \ 89 .globl _name_; \ 90_name_: 91 92/* 93 * STATIC_XENTRY 94 * Local alias for a leaf function, or alternate entry point 95 */ 96#define STATIC_XENTRY(_name_) \ 97_name_: 98 99 100/* 101 * END 102 * Function delimiter 103 */ 104#define END(_name_) \ 105 .endp _name_ 106 107 108/* 109 * EXPORT 110 * Export a symbol 111 */ 112#define EXPORT(_name_) \ 113 .global _name_; \ 114_name_: 115 116 117/* 118 * IMPORT 119 * Make an external name visible, typecheck the size 120 */ 121#define IMPORT(_name_, _size_) \ 122 /* .extern _name_,_size_ */ 123 124 125/* 126 * ABS 127 * Define an absolute symbol 128 */ 129#define ABS(_name_, _value_) \ 130 .globl _name_; \ 131_name_ = _value_ 132 133 134/* 135 * BSS 136 * Allocate un-initialized space for a global symbol 137 */ 138#define BSS(_name_,_numbytes_) \ 139 .comm _name_,_numbytes_ 140 141 142/* 143 * MSG 144 * Allocate space for a message (a read-only ascii string) 145 */ 146#define ASCIZ .asciz 147#define MSG(msg,reg,label) \ 148 addl reg,@ltoff(label),gp;; \ 149 ld8 reg=[reg];; \ 150 .data; \ 151label: ASCIZ msg; \ 152 .text; 153
|