Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: src/trusted/service_runtime/arch/mips/nacl_text_pad_test.S

Issue 10919162: [MIPS] Implementation of sel_ldr for MIPS architecture. (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Rebase (Saturday morning). Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file.
5 */
6
7 #include "native_client/src/trusted/service_runtime/include/bits/nacl_syscalls.h "
8 #include "native_client/src/trusted/service_runtime/nacl_config.h"
9
10 #define STORE_MASK $t7
11 #define JUMP_MASK $t6
12 #define NACL_HALT 0x00000008 /*opcode for "jr $zero", Mips nacl halt*/
13
14 /*
15 * Code to test various address layout boundary conditions.
16 * This is a translation from the x86-{32,64} code, and is
17 * not intended to be super efficent, just good enough to
18 * print out the values that are designed, while maintaining
19 * strict control over the address space layout.
20 */
21
22 .text
23 .set noreorder
24 start_of_text:
25
26 /*
27 * write_num_16. Write an unsigned value in hex.
28 * a0 is descriptor number, a1 is unsigned value to write.
29 */
30 .p2align 4
31 write_num_16:
32 addu $sp, $sp, -40
33 and $sp, $sp, STORE_MASK
34 sw $ra, 36($sp)
35 addu $a3, $sp, 32
36
37 move $a2, $0
38 do_digit_16:
39 addu $a3, $a3, -1
40 addu $a2, $a2, 1
41 and $t0, $a1, 0xf
42
43 addu $t0, $t0, '0'
44 addiu $t1, $t0, -57 /* 57 is ASCI value for '9'. */
45 blez $t1, do_digit_not_upper
46 nop /* instructions in delay slot are
47 * deliberately indented */
48
49 addu $t0, $t0, ('a'-'0'-10)
50 do_digit_not_upper:
51 and $a3, $a3, STORE_MASK
52 sb $t0, 0($a3)
53 srl $a1, $a1, 4
54
55 bne $a1, $0, do_digit_16
56 nop
57 move $a1, $a3
58 lui $t9, %hi(NACL_SYSCALL_ADDR(NACL_sys_write))
59
60 addiu $t9, $t9, %lo(NACL_SYSCALL_ADDR(NACL_sys_write))
61 and $t9, $t9, JUMP_MASK
62 jalr $t9
63 nop
64
65 lw $ra, 36($sp)
66 addu $sp, $sp, 40
67 and $sp, $sp, STORE_MASK
68 nop
69
70 and $ra,$ra,JUMP_MASK
71 jr $ra
72 nop
73 nop
74
75 .p2align 4
76 /*
77 * a0 is descriptor number, a1 is character to write
78 */
79 write_char:
80 addu $sp, $sp, -40
81 and $sp, $sp, STORE_MASK
82 sw $ra, 36($sp)
83 nop
84
85 and $sp, $sp, STORE_MASK
86 sb $a1, 16($sp)
87 addu $a1, $sp, 16
88 addu $a2, $zero, 1
89
90 lui $t9, %hi(NACL_SYSCALL_ADDR(NACL_sys_write))
91 addiu $t9, $t9, %lo(NACL_SYSCALL_ADDR(NACL_sys_write))
92 nop
93 nop
94
95 nop
96 and $t9, $t9, JUMP_MASK
97 jalr $t9
98 nop
99
100 lw $ra, 36($sp)
101 addu $sp, $sp, 40
102 and $sp, $sp, STORE_MASK
103 nop
104
105 and $ra, $ra, JUMP_MASK
106 jr $ra
107 nop
108 nop
109
110 .p2align 4
111 .globl _start
112 _start:
113 /* basic I/O test */
114 addu $sp, $sp, -16
115 and $sp, $sp, STORE_MASK
116 addu $a0, $zero, 1
117 lui $a1, 0xdead
118
119 nop
120 ori $a1, $a1, 0xbeef /* branch delay slot */
121 jal write_num_16
122 nop
123
124 addu $a0, $zero, 1
125 addu $a1, $zero, '\n'
126 jal write_char
127 nop
128
129 lui $a1, %hi(end_of_text)
130 addiu $a1, $a1, %lo(end_of_text)
131 jal write_num_16
132 addu $a0, $zero, 1
133
134 addu $a0, $zero, 1
135 addu $a1, $zero, '\n'
136 jal write_char
137 nop
138
139 addu $a0, $zero, 0
140 lui $t9, %hi(NACL_SYSCALL_ADDR(NACL_sys_sysbrk))
141 addiu $t9, $t9, %lo(NACL_SYSCALL_ADDR(NACL_sys_sysbrk))
142 nop
143
144 nop
145 and $t9, $t9, JUMP_MASK
146 jalr $t9
147 nop
148
149 move $s0, $v0 /* save a copy of break addr */
150 move $a1, $v0
151 jal write_num_16
152 addu $a0, $zero, 1
153
154 addu $a0, $zero, 1
155 addu $a1, $zero, '\n'
156 jal write_char
157 nop
158
159 addu $t5, $zero, 0 /* t5 holds eventual exit status */
160 lui $a1, %hi(EXPECTED_BREAK)
161 addiu $a1, $a1, %lo(EXPECTED_BREAK)
162 addu $a0, $zero, 1
163
164 sub $t0, $a1, $s0
165 movn $t5, $a0, $t0
166 jal write_num_16
167 nop
168
169 addu $a0, $zero, 1
170 addu $a1, $zero, '\n'
171 jal write_char
172 nop
173
174 #if EXPECTED_RODATA != 0
175 addu $a2, $zero, 12
176 lui $a1, %hi(ro_str)
177 addiu $a1, $a1, %lo(ro_str)
178 addu $a0, $zero, 1
179
180 lui $t9, %hi(NACL_SYSCALL_ADDR(NACL_sys_write))
181 addiu $t9, $t9, %lo(NACL_SYSCALL_ADDR(NACL_sys_write))
182 nop
183 nop
184
185 nop
186 and $t9, $t9, JUMP_MASK
187 jalr $t9
188 nop
189
190 lui $a1, %hi(ro_str)
191 addiu $a1, $a1, %lo(ro_str)
192 addu $a0, $zero, 1
193 nop
194
195 nop
196 nop
197 jal write_num_16
198 nop
199
200 addu $a0, $zero, 1
201 addu $a1, $zero, '\n'
202 jal write_char
203 nop
204
205 lui $a1, %hi(EXPECTED_RODATA)
206 addiu $a1, $a1, %lo(EXPECTED_RODATA)
207 lui $a2, %hi(ro_str)
208 addiu $a2, $a2, %lo(ro_str)
209
210 addu $a0, $zero, 1
211 sub $t0, $a1, $a2
212 movn $s0, $a0, $t0
213 nop
214
215 nop
216 nop
217 jal write_num_16
218 nop
219
220 addu $a0, $zero, 1
221 addu $a1, $zero, '\n'
222 jal write_char
223 nop
224 #endif
225
226 lui $t9, %hi(NACL_SYSCALL_ADDR(NACL_sys_exit))
227 addiu $t9, $t9, %lo(NACL_SYSCALL_ADDR(NACL_sys_exit))
228 addu $a0, $zero, $s0
229 nop
230
231 nop
232 and $t9, $t9, JUMP_MASK
233 jalr $t9
234 nop
235
236 #if defined(PNACL_AS)
237 /* NOTE: unlike x86 the alignment directive on Mips takes
238 the logarithm of the alignment */
239 #define POW2_BIGGER_THAN_DOT 14
240 .align32 POW2_BIGGER_THAN_DOT, NACL_HALT
241 .fill (TEXT_EXTEND - (1 << POW2_BIGGER_THAN_DOT))/4, 4, NACL_HALT
242 #else
243 .fill (TEXT_EXTEND - (. - start_of_text))/4, 4, NACL_HALT
244 #endif
245
246 end_of_text:
247
248 #if EXPECTED_RODATA != 0
249 .section .rodata
250 ro_str: .ascii "Hello world\n"
251 #endif
252
OLDNEW
« no previous file with comments | « src/trusted/service_runtime/arch/mips/nacl_syscall.S ('k') | src/trusted/service_runtime/arch/mips/nacl_tls.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698