Initial import from FreeBSD RELENG_4:
[games.git] / sys / i386 / boot / biosboot / asm.h
1 /*
2  * Mach Operating System
3  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify and distribute this software and its
7  * documentation is hereby granted, provided that both the copyright
8  * notice and this permission notice appear in all copies of the
9  * software, derivative works or modified versions, and any portions
10  * thereof, and that both notices appear in supporting documentation.
11  *
12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15  *
16  * Carnegie Mellon requests users of this software to return to
17  *
18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19  *  School of Computer Science
20  *  Carnegie Mellon University
21  *  Pittsburgh PA 15213-3890
22  *
23  * any improvements or extensions that they make and grant Carnegie Mellon
24  * the rights to redistribute these changes.
25  *
26  *      from: Mach, Revision 2.7  92/02/29  15:33:41  rpd
27  * $FreeBSD: src/sys/i386/boot/biosboot/asm.h,v 1.9 1999/08/28 00:43:11 peter Exp $
28  */
29
30 #define S_ARG0   4(%esp)
31 #define S_ARG1   8(%esp)
32 #define S_ARG2  12(%esp)
33 #define S_ARG3  16(%esp)
34
35 #define FRAME   pushl %ebp; movl %esp, %ebp
36 #define EMARF   leave
37
38 #define B_ARG0   8(%ebp)
39 #define B_ARG1  12(%ebp)
40 #define B_ARG2  16(%ebp)
41 #define B_ARG3  20(%ebp)
42
43 #ifdef  wheeze
44
45 #define ALIGN 4
46 #define EXT(x) x
47 #define LEXT(x) x:
48 #define LCL(x) ./**/x
49
50 #define LB(x,n) ./**/x
51 #define LBb(x,n) ./**/x
52 #define LBf(x,n) ./**/x
53
54 #define SVC lcall $7,$0
55
56 #define String .string
57 #define Value  .value
58 #define Times(a,b) [a\*b]
59 #define Divide(a,b) [a\\b]
60
61 #define INB     inb     (%dx)
62 #define OUTB    outb    (%dx)
63 #define INL     inl     (%dx)
64 #define OUTL    outl    (%dx)
65
66 #else   wheeze
67 #define ALIGN
68 #define LCL(x)  x
69
70 #define LB(x,n) n
71 #ifdef  __STDC__
72 #define EXT(x) _ ## x
73 #define LEXT(x) _ ## x ## :
74
75 #define LBb(x,n) n ## b
76 #define LBf(x,n) n ## f
77 #else __STDC__
78 #define EXT(x) _/**/x
79 #define LEXT(x) _/**/x/**/:
80 #define LBb(x,n) n/**/b
81 #define LBf(x,n) n/**/f
82 #endif __STDC__
83 #define SVC .byte 0x9a; .long 0; .word 0x7
84
85 #define String  .ascii
86 #define Value   .word
87 #define Times(a,b) (a*b)
88 #define Divide(a,b) (a/b)
89
90 #define INB     inb     %dx, %al
91 #define OUTB    outb    %al, %dx
92 #define INL     inl     %dx, %eax
93 #define OUTL    outl    %eax, %dx
94
95 #endif  wheeze
96
97 #define addr32  .byte 0x67
98 #define data32  .byte 0x66
99
100 #ifdef GPROF
101 #ifdef  __STDC__
102
103 #define MCOUNT          .data; LB(x, 9); .long 0; .text; lea LBb(x, 9),%edx; call mcount
104 #define ENTRY(x)        .globl EXT(x); .align ALIGN; LEXT(x) ; \
105                         pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp;
106 #define ENTRY2(x,y)     .globl EXT(x); .globl EXT(y); \
107                         .align ALIGN; LEXT(x) LEXT(y) ; \
108                         pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp;
109 #define ASENTRY(x)      .globl x; .align ALIGN; x ## : ; \
110                         pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp;
111
112 #else   __STDC__
113
114 #define MCOUNT          .data; LB(x, 9): .long 0; .text; lea LBb(x, 9),%edx; call mcount
115 #define ENTRY(x)        .globl EXT(x); .align ALIGN; LEXT(x) ; \
116                         pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp;
117 #define ENTRY2(x,y)     .globl EXT(x); .globl EXT(y); \
118                         .align ALIGN; LEXT(x) LEXT(y)
119 #define ASENTRY(x)      .globl x; .align ALIGN; x: ; \
120                         pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp;
121
122 #endif  __STDC__
123 #else   GPROF
124 #ifdef  __STDC__
125
126 #define MCOUNT
127 #define ENTRY(x)        .globl EXT(x); .align ALIGN; LEXT(x)
128 #define ENTRY2(x,y)     .globl EXT(x); .globl EXT(y); \
129                         .align ALIGN; LEXT(x) LEXT(y)
130 #define ASENTRY(x)      .globl x; .align ALIGN; x ## :
131
132 #else   __STDC__
133
134 #define MCOUNT
135 #define ENTRY(x)        .globl EXT(x); .align ALIGN; LEXT(x)
136 #define ENTRY2(x,y)     .globl EXT(x); .globl EXT(y); \
137                         .align ALIGN; LEXT(x) LEXT(y)
138 #define ASENTRY(x)      .globl x; .align ALIGN; x:
139
140 #endif  __STDC__
141 #endif  GPROF
142
143 #define Entry(x)        .globl EXT(x); .align ALIGN; LEXT(x)
144 #define DATA(x)         .globl EXT(x); .align ALIGN; LEXT(x)