revert between 56095 -> 55830 in arch
[AROS.git] / arch / .unmaintained / ppc-native / macros.s
blobc0d1e111a457faa925d4bb8d57163cedf412ff00
1 # remap PPC registers to meaningful names
2 .set r1 ,sp
3 # the "a6" register
4 .set r2, base
5 # int return value register
6 .set r3, ret
7 # function arguments
8 .set r3, arg0
9 .set r4, arg1
10 .set r5, arg2
11 .set r6, arg3
12 .set r7, arg4
13 .set r8, arg5
14 .set r9, arg6
15 .set r10,arg7
16 # "scratch" register
17 .set r30,scr
19 # jsrlvo macro(offset,base)
20 .macro jsrlvo
21 push scr
22 lwz scr,_LVO\1+4(\2)
23 mtlr scr
24 pop scr
25 blrl
26 .endm
28 # very long jump macro
29 .macro ljmp
30 push scr
31 addis scr,0,\1@h
32 ori scr,scr,\1@l
33 mtlr scr
34 pop scr
35 blr
36 .endm
38 # stack macros
39 .macro pop
40 lwz \1,0(sp)
41 add sp,sp,4
42 .endm
44 .macro push
45 stwu \1,-4(sp)
46 .endm
48 # subroutine macros
49 .macro subr
50 push scr
51 mflr scr
52 push scr
53 .endm
55 .macro rts
56 pop scr
57 mtlr scr
58 pop scr
59 blr
60 .endm
62 # return from supervisor. _Super_ret_addr will point to a global address
63 # in the area of exception handler.
64 .macro rfs
65 # recall return address
66 pop scr
67 # push it to srr0, so we can rfi
68 mtsrr0 scr
69 # recall scr, which is put on the stack in the beginning of Supervisor()
70 isync
71 pop scr
72 sync
73 # return to user context
74 rfi
75 .endm
77 # btst.x macros
78 .macro btstb
79 push scr
80 lbz scr,0(\2)
81 rlwinm. r0,scr,31-\1,0,0
82 pop scr
83 .endm
85 .macro btstw
86 push scr
87 lhz scr,0(\2)
88 rlwinm. r0,scr,31-\1,0,0
89 pop scr
90 .endm
92 .macro btstl
93 push scr
94 lwz scr,(\2)
95 rlwinm. r0,scr,31-\1,0,0
96 pop scr
97 .endm
99 # context save/restore macros
100 .macro pusha
101 push r0
102 push r1
103 push r2
104 push r3
105 push r4
106 push r5
107 push r6
108 push r7
109 push r8
110 push r9
111 push r10
112 push r11
113 push r12
114 push r13
115 push r14
116 push r15
117 push r16
118 push r17
119 push r18
120 push r19
121 push r20
122 push r21
123 push r22
124 push r23
125 push r24
126 push r25
127 push r26
128 push r27
129 push r28
130 push r29
131 push r30
132 push r31
134 mflr r0
135 push r0
136 mfcr r0
137 push r0
138 .endm
140 .macro popa
141 pop r0
142 mtcr r0
143 pop r0
144 mtlr r0
145 pop r31
146 pop r30
147 pop r29
148 pop r28
149 pop r27
150 pop r26
151 pop r25
152 pop r24
153 pop r23
154 pop r22
155 pop r21
156 pop r20
157 pop r19
158 pop r18
159 pop r17
160 pop r16
161 pop r15
162 pop r14
163 pop r13
164 pop r12
165 pop r11
166 pop r10
167 pop r9
168 pop r8
169 pop r7
170 pop r6
171 pop r5
172 pop r4
173 pop r3
174 pop r2
175 pop r1
176 pop r0
177 .endm