source: trunk/libs/newlib/src/libgloss/m68k/asm.h @ 661

Last change on this file since 661 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.8 KB
Line 
1/* asm.h -- macros for m68k asm
2 *
3 * Copyright (c) 1995, 1996 Cygnus Support
4 *
5 * The authors hereby grant permission to use, copy, modify, distribute,
6 * and license this software and its documentation for any purpose, provided
7 * that existing copyright notices are retained in all copies and that this
8 * notice is included verbatim in any distributions. No written agreement,
9 * license, or royalty fee is required for any of the authorized uses.
10 * Modifications to this software may be copyrighted by their authors
11 * and need not follow the licensing terms described here, provided that
12 * the new terms are clearly indicated on the first page of each file where
13 * they apply.
14 */
15
16#if 0
17/*
18 * XXX __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ do not work on gcc 2.7.0-3
19 * XXX The following ifdef magic fixes the problem but results in a warning
20 * XXX when compiling assembly code.
21 */
22#ifndef __USER_LABEL_PREFIX__
23/* #define __USER_LABEL_PREFIX__ ""     /* no underscore for coff */
24#define __USER_LABEL_PREFIX__ _         /* leading underscore for aout */
25#endif
26
27#ifndef __REGISTER_PREFIX__
28#define __REGISTER_PREFIX__             /* never has anything prefixed */
29#endif
30#endif
31
32/*
33 * some assemblers choke on '#' as an immediate value. As gcc can also
34 * use '&', use that in those cases.
35 */
36#ifndef __IMMEDIATE_PREFIX__
37#define __IMMEDIATE_PREFIX__ #
38#endif
39
40/* ANSI concatenation macros.  */
41#define CONCAT1(a, b) CONCAT2(a, b)
42#define CONCAT2(a, b) a ## b
43
44/* use the right prefix for global labels.  */
45#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__,x)
46
47/* use the right prefix for registers.  */
48#define REG(x) CONCAT1 (__REGISTER_PREFIX__,x)
49
50/* use the right prefix for immediate values.  */
51#define IMM(x) CONCAT1 (__IMMEDIATE_PREFIX__,x)
52
53/* use the right prefix for register names */
54#define d0 REG (d0)
55#define d1 REG (d1)
56#define d2 REG (d2)
57#define d3 REG (d3)
58#define d4 REG (d4)
59#define d5 REG (d5)
60#define d6 REG (d6)
61#define d7 REG (d7)
62#define a0 REG (a0)
63#define a1 REG (a1)
64#define a2 REG (a2)
65#define a3 REG (a3)
66#define a4 REG (a4)
67#define a5 REG (a5)
68#define a6 REG (a6)
69#define a7 REG (a7)
70#define fp REG (fp)
71#define fp0 REG (fp0)
72#define fp1 REG (fp1)
73#define fp2 REG (fp2)
74#define fp3 REG (fp3)
75#define fp4 REG (fp4)
76#define fp5 REG (fp5)
77#define fp6 REG (fp6)
78#define fp7 REG (fp7)
79#define sp REG (sp)
80#define usp REG (usp)
81#define vbr REG (vbr)
82#define mbb REG (mbb)
83#define sr REG (sr)
84#define fpcr REG (fpcr)
85#define fpsr REG (fpsr)
86#define fpi REG (fpi)
87
88/* Provide a few macros to allow for PIC code support.
89 * With PIC, data is stored A5 relative so we've got to take a bit of special
90 * care to ensure that all loads of global data is via A5.  PIC also requires
91 * jumps and subroutine calls to be PC relative rather than absolute.  We cheat
92 * a little on this and in the PIC case, we use short offset branches and
93 * hope that the final object code is within range (which it should be).
94 */
95#ifndef __PIC__
96
97        /* Non PIC (absolute/relocatable) versions */
98
99        .macro PICCALL addr
100        jbsr    \addr
101        .endm
102
103        .macro PICJUMP addr
104        jmp     \addr
105        .endm
106
107        .macro PICLEA sym, reg
108        lea     \sym, \reg
109        .endm
110
111        .macro PICPEA sym, areg
112        pea     \sym
113        .endm
114
115#else /* __PIC__ */
116
117        /* Common for -mid-shared-libary and -msep-data */
118
119        .macro PICCALL addr
120        bsr     \addr
121        .endm
122
123        .macro PICJUMP addr
124        bra     \addr
125        .endm
126
127# if defined(__ID_SHARED_LIBRARY__)
128
129        /* -mid-shared-library versions  */
130
131        .macro PICLEA sym, reg
132        movel   a5@(_current_shared_library_a5_offset_), \reg
133        movel   \sym@GOT(\reg), \reg
134        .endm
135
136        .macro PICPEA sym, areg
137        movel   a5@(_current_shared_library_a5_offset_), \areg
138        movel   \sym@GOT(\areg), sp@-
139        .endm
140
141# else /* !__ID_SHARED_LIBRARY__ */
142
143        /* Versions for -msep-data */
144
145        .macro PICLEA sym, reg
146        movel   \sym@GOT(a5), \reg
147        .endm
148
149        .macro PICPEA sym, areg
150        movel   \sym@GOT(a5), sp@-
151        .endm
152
153# endif /* !__ID_SHARED_LIBRARY__ */
154#endif /* __PIC__ */
155
Note: See TracBrowser for help on using the repository browser.