11539Srgrimes/*-
21539Srgrimes * Copyright (c) 1990 The Regents of the University of California.
31539Srgrimes * All rights reserved.
41539Srgrimes *
51539Srgrimes * This code is derived from software contributed to Berkeley by
61539Srgrimes * William Jolitz.
71539Srgrimes *
81539Srgrimes * Redistribution and use in source and binary forms, with or without
91539Srgrimes * modification, are permitted provided that the following conditions
101539Srgrimes * are met:
111539Srgrimes * 1. Redistributions of source code must retain the above copyright
121539Srgrimes *    notice, this list of conditions and the following disclaimer.
131539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
141539Srgrimes *    notice, this list of conditions and the following disclaimer in the
151539Srgrimes *    documentation and/or other materials provided with the distribution.
161539Srgrimes * 4. Neither the name of the University nor the names of its contributors
171539Srgrimes *    may be used to endorse or promote products derived from this software
18203965Simp *    without specific prior written permission.
191539Srgrimes *
201539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
211539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
221539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
231539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
241539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
251539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
261539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
271539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
281539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
291539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
301539Srgrimes * SUCH DAMAGE.
311539Srgrimes *
321539Srgrimes *	from: @(#)DEFS.h	5.1 (Berkeley) 4/23/90
331539Srgrimes * $FreeBSD$
341539Srgrimes */
3585635Sdillon
3685635Sdillon#ifndef _MACHINE_ASM_H_
371539Srgrimes#define	_MACHINE_ASM_H_
381539Srgrimes
392163Spaul#include <sys/cdefs.h>
402163Spaul
411539Srgrimes#ifdef PIC
421539Srgrimes#define	PIC_PROLOGUE	\
431539Srgrimes	pushl	%ebx;	\
441539Srgrimes	call	1f;	\
451539Srgrimes1:			\
461539Srgrimes	popl	%ebx;	\
471539Srgrimes	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx
481539Srgrimes#define	PIC_EPILOGUE	\
491539Srgrimes	popl	%ebx
501539Srgrimes#define	PIC_PLT(x)	x@PLT
511539Srgrimes#define	PIC_GOT(x)	x@GOT(%ebx)
521539Srgrimes#define	PIC_GOTOFF(x)	x@GOTOFF(%ebx)
531539Srgrimes#else
541539Srgrimes#define	PIC_PROLOGUE
551539Srgrimes#define	PIC_EPILOGUE
561539Srgrimes#define	PIC_PLT(x)	x
571539Srgrimes#define	PIC_GOTOFF(x)	x
581539Srgrimes#endif
591539Srgrimes
601539Srgrimes/*
611539Srgrimes * CNAME and HIDENAME manage the relationship between symbol names in C
621539Srgrimes * and the equivalent assembly language names.  CNAME is given a name as
6398542Smckusick * it would be used in a C program.  It expands to the equivalent assembly
6498542Smckusick * language name.  HIDENAME is given an assembly-language name, and expands
6598542Smckusick * to a possibly-modified form that will be invisible to C programs.
661539Srgrimes */
671539Srgrimes#define CNAME(csym)		csym
681539Srgrimes#define HIDENAME(asmsym)	.asmsym
691539Srgrimes
701539Srgrimes/* XXX should use .p2align 4,0x90 for -m486. */
7140668Sdima#define _START_ENTRY	.text; .p2align 2,0x90
7298542Smckusick
7398542Smckusick#define _ENTRY(x)	_START_ENTRY; \
7440668Sdima			.globl CNAME(x); .type CNAME(x),@function; CNAME(x):
7598542Smckusick#define	END(x)		.size x, . - x
761539Srgrimes
7740668Sdima#ifdef PROF
7840668Sdima#define	ALTENTRY(x)	_ENTRY(x); \
7998542Smckusick			pushl %ebp; movl %esp,%ebp; \
8098542Smckusick			call PIC_PLT(HIDENAME(mcount)); \
8198542Smckusick			popl %ebp; \
8298542Smckusick			jmp 9f
8398542Smckusick#define	ENTRY(x)	_ENTRY(x); \
8498542Smckusick			pushl %ebp; movl %esp,%ebp; \
8598542Smckusick			call PIC_PLT(HIDENAME(mcount)); \
8698542Smckusick			popl %ebp; \
8798542Smckusick			9:
8898542Smckusick#else
8998542Smckusick#define	ALTENTRY(x)	_ENTRY(x)
9098542Smckusick#define	ENTRY(x)	_ENTRY(x)
9198542Smckusick#endif
92100207Smckusick
93100207Smckusick/*
9498542Smckusick * WEAK_ALIAS: create a weak alias.
9598542Smckusick */
96167011Smckusick#define	WEAK_ALIAS(alias,sym)						\
97167011Smckusick	.weak alias;							\
9898542Smckusick	alias = sym
9998542Smckusick
10098542Smckusick/*
10198542Smckusick * STRONG_ALIAS: create a strong alias.
10298542Smckusick */
10398542Smckusick#define	STRONG_ALIAS(alias,sym)						\
10498542Smckusick	.globl alias;							\
10598542Smckusick	alias = sym
10640668Sdima
1071539Srgrimes#define RCSID(x)	.text; .asciz x
1081539Srgrimes
10940668Sdima#undef __FBSDID
1101539Srgrimes#if !defined(lint) && !defined(STRIP_FBSDID)
1111539Srgrimes#define __FBSDID(s)	.ident s
1121539Srgrimes#else
11340668Sdima#define __FBSDID(s)	/* nothing */
11498542Smckusick#endif /* not lint and not STRIP_FBSDID */
11598542Smckusick
11698542Smckusick#endif /* !_MACHINE_ASM_H_ */
11798542Smckusick