comparison uprogs/stressfs.asm @ 0:c450faca55f4

Init
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Sun, 22 Oct 2017 18:25:39 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c450faca55f4
1
2 _stressfs: file format elf32-littlearm
3
4
5 Disassembly of section .text:
6
7 00000000 <main>:
8 #include "fs.h"
9 #include "fcntl.h"
10
11 int
12 main(int argc, char *argv[])
13 {
14 0: e92d4830 push {r4, r5, fp, lr}
15 4: e28db00c add fp, sp, #12
16 int fd, i;
17 char path[] = "stressfs0";
18 8: e59f20ec ldr r2, [pc, #236] ; fc <main+0xfc>
19 #include "fs.h"
20 #include "fcntl.h"
21
22 int
23 main(int argc, char *argv[])
24 {
25 c: e24dde21 sub sp, sp, #528 ; 0x210
26 int fd, i;
27 char path[] = "stressfs0";
28 10: e24b3018 sub r3, fp, #24
29 14: e8920007 ldm r2, {r0, r1, r2}
30 char data[512];
31
32 printf(1, "stressfs starting\n");
33 memset(data, 'a', sizeof(data));
34
35 for(i = 0; i < 4; i++)
36 18: e3a04000 mov r4, #0
37
38 int
39 main(int argc, char *argv[])
40 {
41 int fd, i;
42 char path[] = "stressfs0";
43 1c: e8a30003 stmia r3!, {r0, r1}
44 char data[512];
45
46 printf(1, "stressfs starting\n");
47 20: e3a00001 mov r0, #1
48 24: e59f10d4 ldr r1, [pc, #212] ; 100 <main+0x100>
49
50 int
51 main(int argc, char *argv[])
52 {
53 int fd, i;
54 char path[] = "stressfs0";
55 28: e1c320b0 strh r2, [r3]
56 char data[512];
57
58 printf(1, "stressfs starting\n");
59 2c: eb000232 bl 8fc <printf>
60 memset(data, 'a', sizeof(data));
61 30: e24b0f86 sub r0, fp, #536 ; 0x218
62 34: e3a01061 mov r1, #97 ; 0x61
63 38: e3a02c02 mov r2, #512 ; 0x200
64 3c: eb000060 bl 1c4 <memset>
65
66 for(i = 0; i < 4; i++)
67 if(fork() > 0)
68 40: eb0000cd bl 37c <fork>
69 44: e3500000 cmp r0, #0
70 48: ca000029 bgt f4 <main+0xf4>
71 char data[512];
72
73 printf(1, "stressfs starting\n");
74 memset(data, 'a', sizeof(data));
75
76 for(i = 0; i < 4; i++)
77 4c: e2844001 add r4, r4, #1
78 50: e3540004 cmp r4, #4
79 54: 1afffff9 bne 40 <main+0x40>
80 58: e1a05004 mov r5, r4
81 if(fork() > 0)
82 break;
83
84 printf(1, "write %d\n", i);
85 5c: e1a02004 mov r2, r4
86 60: e3a00001 mov r0, #1
87 64: e59f1098 ldr r1, [pc, #152] ; 104 <main+0x104>
88 68: eb000223 bl 8fc <printf>
89
90 path[8] += i;
91 6c: e55b3010 ldrb r3, [fp, #-16]
92 fd = open(path, O_CREATE | O_RDWR);
93 70: e24b0018 sub r0, fp, #24
94 74: e59f108c ldr r1, [pc, #140] ; 108 <main+0x108>
95 if(fork() > 0)
96 break;
97
98 printf(1, "write %d\n", i);
99
100 path[8] += i;
101 78: e0855003 add r5, r5, r3
102 7c: e54b5010 strb r5, [fp, #-16]
103 fd = open(path, O_CREATE | O_RDWR);
104 80: eb000132 bl 550 <open>
105 84: e3a04014 mov r4, #20
106 88: e1a05000 mov r5, r0
107 for(i = 0; i < 20; i++)
108 // printf(fd, "%d\n", i);
109 write(fd, data, sizeof(data));
110 8c: e1a00005 mov r0, r5
111 90: e24b1f86 sub r1, fp, #536 ; 0x218
112 94: e3a02c02 mov r2, #512 ; 0x200
113 98: eb0000f8 bl 480 <write>
114
115 printf(1, "write %d\n", i);
116
117 path[8] += i;
118 fd = open(path, O_CREATE | O_RDWR);
119 for(i = 0; i < 20; i++)
120 9c: e2544001 subs r4, r4, #1
121 a0: 1afffff9 bne 8c <main+0x8c>
122 // printf(fd, "%d\n", i);
123 write(fd, data, sizeof(data));
124 close(fd);
125 a4: e1a00005 mov r0, r5
126 a8: eb000101 bl 4b4 <close>
127
128 printf(1, "read\n");
129 ac: e3a00001 mov r0, #1
130 b0: e59f1054 ldr r1, [pc, #84] ; 10c <main+0x10c>
131 b4: eb000210 bl 8fc <printf>
132
133 fd = open(path, O_RDONLY);
134 b8: e1a01004 mov r1, r4
135 bc: e24b0018 sub r0, fp, #24
136 c0: eb000122 bl 550 <open>
137 c4: e3a04014 mov r4, #20
138 c8: e1a05000 mov r5, r0
139 for (i = 0; i < 20; i++)
140 read(fd, data, sizeof(data));
141 cc: e1a00005 mov r0, r5
142 d0: e24b1f86 sub r1, fp, #536 ; 0x218
143 d4: e3a02c02 mov r2, #512 ; 0x200
144 d8: eb0000db bl 44c <read>
145 close(fd);
146
147 printf(1, "read\n");
148
149 fd = open(path, O_RDONLY);
150 for (i = 0; i < 20; i++)
151 dc: e2544001 subs r4, r4, #1
152 e0: 1afffff9 bne cc <main+0xcc>
153 read(fd, data, sizeof(data));
154 close(fd);
155 e4: e1a00005 mov r0, r5
156 e8: eb0000f1 bl 4b4 <close>
157
158 wait();
159 ec: eb0000bc bl 3e4 <wait>
160
161 exit();
162 f0: eb0000ae bl 3b0 <exit>
163
164 printf(1, "stressfs starting\n");
165 memset(data, 'a', sizeof(data));
166
167 for(i = 0; i < 4; i++)
168 if(fork() > 0)
169 f4: e6ef5074 uxtb r5, r4
170 f8: eaffffd7 b 5c <main+0x5c>
171 fc: 00000c0c .word 0x00000c0c
172 100: 00000be4 .word 0x00000be4
173 104: 00000bf8 .word 0x00000bf8
174 108: 00000202 .word 0x00000202
175 10c: 00000c04 .word 0x00000c04
176
177 00000110 <strcpy>:
178 #include "user.h"
179 #include "arm.h"
180
181 char*
182 strcpy(char *s, char *t)
183 {
184 110: e52db004 push {fp} ; (str fp, [sp, #-4]!)
185 char *os;
186
187 os = s;
188 while((*s++ = *t++) != 0)
189 114: e1a02000 mov r2, r0
190 #include "user.h"
191 #include "arm.h"
192
193 char*
194 strcpy(char *s, char *t)
195 {
196 118: e28db000 add fp, sp, #0
197 char *os;
198
199 os = s;
200 while((*s++ = *t++) != 0)
201 11c: e4d13001 ldrb r3, [r1], #1
202 120: e3530000 cmp r3, #0
203 124: e4c23001 strb r3, [r2], #1
204 128: 1afffffb bne 11c <strcpy+0xc>
205 ;
206 return os;
207 }
208 12c: e28bd000 add sp, fp, #0
209 130: e8bd0800 pop {fp}
210 134: e12fff1e bx lr
211
212 00000138 <strcmp>:
213
214 int
215 strcmp(const char *p, const char *q)
216 {
217 138: e52db004 push {fp} ; (str fp, [sp, #-4]!)
218 13c: e28db000 add fp, sp, #0
219 while(*p && *p == *q)
220 140: e5d03000 ldrb r3, [r0]
221 144: e5d12000 ldrb r2, [r1]
222 148: e3530000 cmp r3, #0
223 14c: 1a000004 bne 164 <strcmp+0x2c>
224 150: ea000005 b 16c <strcmp+0x34>
225 154: e5f03001 ldrb r3, [r0, #1]!
226 158: e3530000 cmp r3, #0
227 15c: 0a000006 beq 17c <strcmp+0x44>
228 160: e5f12001 ldrb r2, [r1, #1]!
229 164: e1530002 cmp r3, r2
230 168: 0afffff9 beq 154 <strcmp+0x1c>
231 p++, q++;
232 return (uchar)*p - (uchar)*q;
233 }
234 16c: e0620003 rsb r0, r2, r3
235 170: e28bd000 add sp, fp, #0
236 174: e8bd0800 pop {fp}
237 178: e12fff1e bx lr
238 }
239
240 int
241 strcmp(const char *p, const char *q)
242 {
243 while(*p && *p == *q)
244 17c: e5d12001 ldrb r2, [r1, #1]
245 180: eafffff9 b 16c <strcmp+0x34>
246
247 00000184 <strlen>:
248 return (uchar)*p - (uchar)*q;
249 }
250
251 uint
252 strlen(char *s)
253 {
254 184: e52db004 push {fp} ; (str fp, [sp, #-4]!)
255 188: e28db000 add fp, sp, #0
256 int n;
257
258 for(n = 0; s[n]; n++)
259 18c: e5d03000 ldrb r3, [r0]
260 190: e3530000 cmp r3, #0
261 194: 01a00003 moveq r0, r3
262 198: 0a000006 beq 1b8 <strlen+0x34>
263 19c: e1a02000 mov r2, r0
264 1a0: e3a03000 mov r3, #0
265 1a4: e5f21001 ldrb r1, [r2, #1]!
266 1a8: e2833001 add r3, r3, #1
267 1ac: e1a00003 mov r0, r3
268 1b0: e3510000 cmp r1, #0
269 1b4: 1afffffa bne 1a4 <strlen+0x20>
270 ;
271 return n;
272 }
273 1b8: e28bd000 add sp, fp, #0
274 1bc: e8bd0800 pop {fp}
275 1c0: e12fff1e bx lr
276
277 000001c4 <memset>:
278 memset(void *dst, int c, uint n)
279 {
280 char *p=dst;
281 u32 rc=n;
282
283 while (rc-- > 0) *p++ = c;
284 1c4: e3520000 cmp r2, #0
285 return n;
286 }
287
288 void*
289 memset(void *dst, int c, uint n)
290 {
291 1c8: e52db004 push {fp} ; (str fp, [sp, #-4]!)
292 1cc: e28db000 add fp, sp, #0
293 char *p=dst;
294 u32 rc=n;
295
296 while (rc-- > 0) *p++ = c;
297 1d0: 0a000006 beq 1f0 <memset+0x2c>
298 1d4: e6ef1071 uxtb r1, r1
299 1d8: e1a03002 mov r3, r2
300 }
301
302 void*
303 memset(void *dst, int c, uint n)
304 {
305 char *p=dst;
306 1dc: e1a0c000 mov ip, r0
307 u32 rc=n;
308
309 while (rc-- > 0) *p++ = c;
310 1e0: e2533001 subs r3, r3, #1
311 1e4: e4cc1001 strb r1, [ip], #1
312 1e8: 1afffffc bne 1e0 <memset+0x1c>
313 1ec: e0800002 add r0, r0, r2
314 return (void *)p;
315 }
316 1f0: e28bd000 add sp, fp, #0
317 1f4: e8bd0800 pop {fp}
318 1f8: e12fff1e bx lr
319
320 000001fc <strchr>:
321
322 char*
323 strchr(const char *s, char c)
324 {
325 1fc: e52db004 push {fp} ; (str fp, [sp, #-4]!)
326 200: e28db000 add fp, sp, #0
327 for(; *s; s++)
328 204: e5d03000 ldrb r3, [r0]
329 208: e3530000 cmp r3, #0
330 20c: 1a000004 bne 224 <strchr+0x28>
331 210: ea000008 b 238 <strchr+0x3c>
332 214: e5d03001 ldrb r3, [r0, #1]
333 218: e2800001 add r0, r0, #1
334 21c: e3530000 cmp r3, #0
335 220: 0a000004 beq 238 <strchr+0x3c>
336 if(*s == c)
337 224: e1530001 cmp r3, r1
338 228: 1afffff9 bne 214 <strchr+0x18>
339 return (char*)s;
340 return 0;
341 }
342 22c: e28bd000 add sp, fp, #0
343 230: e8bd0800 pop {fp}
344 234: e12fff1e bx lr
345 strchr(const char *s, char c)
346 {
347 for(; *s; s++)
348 if(*s == c)
349 return (char*)s;
350 return 0;
351 238: e1a00003 mov r0, r3
352 23c: eafffffa b 22c <strchr+0x30>
353
354 00000240 <gets>:
355 }
356
357 char*
358 gets(char *buf, int max)
359 {
360 240: e92d49f0 push {r4, r5, r6, r7, r8, fp, lr}
361 244: e28db018 add fp, sp, #24
362 248: e24dd00c sub sp, sp, #12
363 24c: e1a08000 mov r8, r0
364 250: e1a07001 mov r7, r1
365 int i, cc;
366 char c;
367
368 for(i=0; i+1 < max; ){
369 254: e1a06000 mov r6, r0
370 258: e3a05000 mov r5, #0
371 25c: ea000008 b 284 <gets+0x44>
372 cc = read(0, &c, 1);
373 260: eb000079 bl 44c <read>
374 if(cc < 1)
375 264: e3500000 cmp r0, #0
376 268: da00000b ble 29c <gets+0x5c>
377 break;
378 buf[i++] = c;
379 26c: e55b301d ldrb r3, [fp, #-29]
380 if(c == '\n' || c == '\r')
381 270: e1a05004 mov r5, r4
382 274: e353000a cmp r3, #10
383 278: 1353000d cmpne r3, #13
384
385 for(i=0; i+1 < max; ){
386 cc = read(0, &c, 1);
387 if(cc < 1)
388 break;
389 buf[i++] = c;
390 27c: e4c63001 strb r3, [r6], #1
391 if(c == '\n' || c == '\r')
392 280: 0a00000a beq 2b0 <gets+0x70>
393 {
394 int i, cc;
395 char c;
396
397 for(i=0; i+1 < max; ){
398 cc = read(0, &c, 1);
399 284: e3a02001 mov r2, #1
400 gets(char *buf, int max)
401 {
402 int i, cc;
403 char c;
404
405 for(i=0; i+1 < max; ){
406 288: e0854002 add r4, r5, r2
407 28c: e1540007 cmp r4, r7
408 cc = read(0, &c, 1);
409 290: e3a00000 mov r0, #0
410 294: e24b101d sub r1, fp, #29
411 gets(char *buf, int max)
412 {
413 int i, cc;
414 char c;
415
416 for(i=0; i+1 < max; ){
417 298: bafffff0 blt 260 <gets+0x20>
418 break;
419 buf[i++] = c;
420 if(c == '\n' || c == '\r')
421 break;
422 }
423 buf[i] = '\0';
424 29c: e3a03000 mov r3, #0
425 2a0: e7c83005 strb r3, [r8, r5]
426 return buf;
427 }
428 2a4: e1a00008 mov r0, r8
429 2a8: e24bd018 sub sp, fp, #24
430 2ac: e8bd89f0 pop {r4, r5, r6, r7, r8, fp, pc}
431 gets(char *buf, int max)
432 {
433 int i, cc;
434 char c;
435
436 for(i=0; i+1 < max; ){
437 2b0: e1a05004 mov r5, r4
438 2b4: eafffff8 b 29c <gets+0x5c>
439
440 000002b8 <stat>:
441 return buf;
442 }
443
444 int
445 stat(char *n, struct stat *st)
446 {
447 2b8: e92d4830 push {r4, r5, fp, lr}
448 2bc: e1a05001 mov r5, r1
449 2c0: e28db00c add fp, sp, #12
450 int fd;
451 int r;
452
453 fd = open(n, O_RDONLY);
454 2c4: e3a01000 mov r1, #0
455 2c8: eb0000a0 bl 550 <open>
456 if(fd < 0)
457 2cc: e2504000 subs r4, r0, #0
458 return -1;
459 2d0: b3e05000 mvnlt r5, #0
460 {
461 int fd;
462 int r;
463
464 fd = open(n, O_RDONLY);
465 if(fd < 0)
466 2d4: ba000004 blt 2ec <stat+0x34>
467 return -1;
468 r = fstat(fd, st);
469 2d8: e1a01005 mov r1, r5
470 2dc: eb0000c2 bl 5ec <fstat>
471 2e0: e1a05000 mov r5, r0
472 close(fd);
473 2e4: e1a00004 mov r0, r4
474 2e8: eb000071 bl 4b4 <close>
475 return r;
476 }
477 2ec: e1a00005 mov r0, r5
478 2f0: e8bd8830 pop {r4, r5, fp, pc}
479
480 000002f4 <atoi>:
481
482 int
483 atoi(const char *s)
484 {
485 2f4: e52db004 push {fp} ; (str fp, [sp, #-4]!)
486 2f8: e28db000 add fp, sp, #0
487 int n;
488
489 n = 0;
490 while('0' <= *s && *s <= '9')
491 2fc: e5d03000 ldrb r3, [r0]
492 300: e2432030 sub r2, r3, #48 ; 0x30
493 304: e6ef2072 uxtb r2, r2
494 308: e3520009 cmp r2, #9
495 int
496 atoi(const char *s)
497 {
498 int n;
499
500 n = 0;
501 30c: 83a00000 movhi r0, #0
502 while('0' <= *s && *s <= '9')
503 310: 8a000009 bhi 33c <atoi+0x48>
504 314: e1a02000 mov r2, r0
505 int
506 atoi(const char *s)
507 {
508 int n;
509
510 n = 0;
511 318: e3a00000 mov r0, #0
512 while('0' <= *s && *s <= '9')
513 n = n*10 + *s++ - '0';
514 31c: e0800100 add r0, r0, r0, lsl #2
515 320: e0830080 add r0, r3, r0, lsl #1
516 atoi(const char *s)
517 {
518 int n;
519
520 n = 0;
521 while('0' <= *s && *s <= '9')
522 324: e5f23001 ldrb r3, [r2, #1]!
523 n = n*10 + *s++ - '0';
524 328: e2400030 sub r0, r0, #48 ; 0x30
525 atoi(const char *s)
526 {
527 int n;
528
529 n = 0;
530 while('0' <= *s && *s <= '9')
531 32c: e2431030 sub r1, r3, #48 ; 0x30
532 330: e6ef1071 uxtb r1, r1
533 334: e3510009 cmp r1, #9
534 338: 9afffff7 bls 31c <atoi+0x28>
535 n = n*10 + *s++ - '0';
536 return n;
537 }
538 33c: e28bd000 add sp, fp, #0
539 340: e8bd0800 pop {fp}
540 344: e12fff1e bx lr
541
542 00000348 <memmove>:
543 {
544 char *dst, *src;
545
546 dst = vdst;
547 src = vsrc;
548 while(n-- > 0)
549 348: e3520000 cmp r2, #0
550 return n;
551 }
552
553 void*
554 memmove(void *vdst, void *vsrc, int n)
555 {
556 34c: e52db004 push {fp} ; (str fp, [sp, #-4]!)
557 350: e28db000 add fp, sp, #0
558 char *dst, *src;
559
560 dst = vdst;
561 src = vsrc;
562 while(n-- > 0)
563 354: da000005 ble 370 <memmove+0x28>
564 n = n*10 + *s++ - '0';
565 return n;
566 }
567
568 void*
569 memmove(void *vdst, void *vsrc, int n)
570 358: e0802002 add r2, r0, r2
571 {
572 char *dst, *src;
573
574 dst = vdst;
575 35c: e1a03000 mov r3, r0
576 src = vsrc;
577 while(n-- > 0)
578 *dst++ = *src++;
579 360: e4d1c001 ldrb ip, [r1], #1
580 364: e4c3c001 strb ip, [r3], #1
581 {
582 char *dst, *src;
583
584 dst = vdst;
585 src = vsrc;
586 while(n-- > 0)
587 368: e1530002 cmp r3, r2
588 36c: 1afffffb bne 360 <memmove+0x18>
589 *dst++ = *src++;
590 return vdst;
591 }
592 370: e28bd000 add sp, fp, #0
593 374: e8bd0800 pop {fp}
594 378: e12fff1e bx lr
595
596 0000037c <fork>:
597 37c: e92d4000 push {lr}
598 380: e92d0008 push {r3}
599 384: e92d0004 push {r2}
600 388: e92d0002 push {r1}
601 38c: e92d0001 push {r0}
602 390: e3a00001 mov r0, #1
603 394: ef000040 svc 0x00000040
604 398: e8bd0002 pop {r1}
605 39c: e8bd0002 pop {r1}
606 3a0: e8bd0004 pop {r2}
607 3a4: e8bd0008 pop {r3}
608 3a8: e8bd4000 pop {lr}
609 3ac: e12fff1e bx lr
610
611 000003b0 <exit>:
612 3b0: e92d4000 push {lr}
613 3b4: e92d0008 push {r3}
614 3b8: e92d0004 push {r2}
615 3bc: e92d0002 push {r1}
616 3c0: e92d0001 push {r0}
617 3c4: e3a00002 mov r0, #2
618 3c8: ef000040 svc 0x00000040
619 3cc: e8bd0002 pop {r1}
620 3d0: e8bd0002 pop {r1}
621 3d4: e8bd0004 pop {r2}
622 3d8: e8bd0008 pop {r3}
623 3dc: e8bd4000 pop {lr}
624 3e0: e12fff1e bx lr
625
626 000003e4 <wait>:
627 3e4: e92d4000 push {lr}
628 3e8: e92d0008 push {r3}
629 3ec: e92d0004 push {r2}
630 3f0: e92d0002 push {r1}
631 3f4: e92d0001 push {r0}
632 3f8: e3a00003 mov r0, #3
633 3fc: ef000040 svc 0x00000040
634 400: e8bd0002 pop {r1}
635 404: e8bd0002 pop {r1}
636 408: e8bd0004 pop {r2}
637 40c: e8bd0008 pop {r3}
638 410: e8bd4000 pop {lr}
639 414: e12fff1e bx lr
640
641 00000418 <pipe>:
642 418: e92d4000 push {lr}
643 41c: e92d0008 push {r3}
644 420: e92d0004 push {r2}
645 424: e92d0002 push {r1}
646 428: e92d0001 push {r0}
647 42c: e3a00004 mov r0, #4
648 430: ef000040 svc 0x00000040
649 434: e8bd0002 pop {r1}
650 438: e8bd0002 pop {r1}
651 43c: e8bd0004 pop {r2}
652 440: e8bd0008 pop {r3}
653 444: e8bd4000 pop {lr}
654 448: e12fff1e bx lr
655
656 0000044c <read>:
657 44c: e92d4000 push {lr}
658 450: e92d0008 push {r3}
659 454: e92d0004 push {r2}
660 458: e92d0002 push {r1}
661 45c: e92d0001 push {r0}
662 460: e3a00005 mov r0, #5
663 464: ef000040 svc 0x00000040
664 468: e8bd0002 pop {r1}
665 46c: e8bd0002 pop {r1}
666 470: e8bd0004 pop {r2}
667 474: e8bd0008 pop {r3}
668 478: e8bd4000 pop {lr}
669 47c: e12fff1e bx lr
670
671 00000480 <write>:
672 480: e92d4000 push {lr}
673 484: e92d0008 push {r3}
674 488: e92d0004 push {r2}
675 48c: e92d0002 push {r1}
676 490: e92d0001 push {r0}
677 494: e3a00010 mov r0, #16
678 498: ef000040 svc 0x00000040
679 49c: e8bd0002 pop {r1}
680 4a0: e8bd0002 pop {r1}
681 4a4: e8bd0004 pop {r2}
682 4a8: e8bd0008 pop {r3}
683 4ac: e8bd4000 pop {lr}
684 4b0: e12fff1e bx lr
685
686 000004b4 <close>:
687 4b4: e92d4000 push {lr}
688 4b8: e92d0008 push {r3}
689 4bc: e92d0004 push {r2}
690 4c0: e92d0002 push {r1}
691 4c4: e92d0001 push {r0}
692 4c8: e3a00015 mov r0, #21
693 4cc: ef000040 svc 0x00000040
694 4d0: e8bd0002 pop {r1}
695 4d4: e8bd0002 pop {r1}
696 4d8: e8bd0004 pop {r2}
697 4dc: e8bd0008 pop {r3}
698 4e0: e8bd4000 pop {lr}
699 4e4: e12fff1e bx lr
700
701 000004e8 <kill>:
702 4e8: e92d4000 push {lr}
703 4ec: e92d0008 push {r3}
704 4f0: e92d0004 push {r2}
705 4f4: e92d0002 push {r1}
706 4f8: e92d0001 push {r0}
707 4fc: e3a00006 mov r0, #6
708 500: ef000040 svc 0x00000040
709 504: e8bd0002 pop {r1}
710 508: e8bd0002 pop {r1}
711 50c: e8bd0004 pop {r2}
712 510: e8bd0008 pop {r3}
713 514: e8bd4000 pop {lr}
714 518: e12fff1e bx lr
715
716 0000051c <exec>:
717 51c: e92d4000 push {lr}
718 520: e92d0008 push {r3}
719 524: e92d0004 push {r2}
720 528: e92d0002 push {r1}
721 52c: e92d0001 push {r0}
722 530: e3a00007 mov r0, #7
723 534: ef000040 svc 0x00000040
724 538: e8bd0002 pop {r1}
725 53c: e8bd0002 pop {r1}
726 540: e8bd0004 pop {r2}
727 544: e8bd0008 pop {r3}
728 548: e8bd4000 pop {lr}
729 54c: e12fff1e bx lr
730
731 00000550 <open>:
732 550: e92d4000 push {lr}
733 554: e92d0008 push {r3}
734 558: e92d0004 push {r2}
735 55c: e92d0002 push {r1}
736 560: e92d0001 push {r0}
737 564: e3a0000f mov r0, #15
738 568: ef000040 svc 0x00000040
739 56c: e8bd0002 pop {r1}
740 570: e8bd0002 pop {r1}
741 574: e8bd0004 pop {r2}
742 578: e8bd0008 pop {r3}
743 57c: e8bd4000 pop {lr}
744 580: e12fff1e bx lr
745
746 00000584 <mknod>:
747 584: e92d4000 push {lr}
748 588: e92d0008 push {r3}
749 58c: e92d0004 push {r2}
750 590: e92d0002 push {r1}
751 594: e92d0001 push {r0}
752 598: e3a00011 mov r0, #17
753 59c: ef000040 svc 0x00000040
754 5a0: e8bd0002 pop {r1}
755 5a4: e8bd0002 pop {r1}
756 5a8: e8bd0004 pop {r2}
757 5ac: e8bd0008 pop {r3}
758 5b0: e8bd4000 pop {lr}
759 5b4: e12fff1e bx lr
760
761 000005b8 <unlink>:
762 5b8: e92d4000 push {lr}
763 5bc: e92d0008 push {r3}
764 5c0: e92d0004 push {r2}
765 5c4: e92d0002 push {r1}
766 5c8: e92d0001 push {r0}
767 5cc: e3a00012 mov r0, #18
768 5d0: ef000040 svc 0x00000040
769 5d4: e8bd0002 pop {r1}
770 5d8: e8bd0002 pop {r1}
771 5dc: e8bd0004 pop {r2}
772 5e0: e8bd0008 pop {r3}
773 5e4: e8bd4000 pop {lr}
774 5e8: e12fff1e bx lr
775
776 000005ec <fstat>:
777 5ec: e92d4000 push {lr}
778 5f0: e92d0008 push {r3}
779 5f4: e92d0004 push {r2}
780 5f8: e92d0002 push {r1}
781 5fc: e92d0001 push {r0}
782 600: e3a00008 mov r0, #8
783 604: ef000040 svc 0x00000040
784 608: e8bd0002 pop {r1}
785 60c: e8bd0002 pop {r1}
786 610: e8bd0004 pop {r2}
787 614: e8bd0008 pop {r3}
788 618: e8bd4000 pop {lr}
789 61c: e12fff1e bx lr
790
791 00000620 <link>:
792 620: e92d4000 push {lr}
793 624: e92d0008 push {r3}
794 628: e92d0004 push {r2}
795 62c: e92d0002 push {r1}
796 630: e92d0001 push {r0}
797 634: e3a00013 mov r0, #19
798 638: ef000040 svc 0x00000040
799 63c: e8bd0002 pop {r1}
800 640: e8bd0002 pop {r1}
801 644: e8bd0004 pop {r2}
802 648: e8bd0008 pop {r3}
803 64c: e8bd4000 pop {lr}
804 650: e12fff1e bx lr
805
806 00000654 <mkdir>:
807 654: e92d4000 push {lr}
808 658: e92d0008 push {r3}
809 65c: e92d0004 push {r2}
810 660: e92d0002 push {r1}
811 664: e92d0001 push {r0}
812 668: e3a00014 mov r0, #20
813 66c: ef000040 svc 0x00000040
814 670: e8bd0002 pop {r1}
815 674: e8bd0002 pop {r1}
816 678: e8bd0004 pop {r2}
817 67c: e8bd0008 pop {r3}
818 680: e8bd4000 pop {lr}
819 684: e12fff1e bx lr
820
821 00000688 <chdir>:
822 688: e92d4000 push {lr}
823 68c: e92d0008 push {r3}
824 690: e92d0004 push {r2}
825 694: e92d0002 push {r1}
826 698: e92d0001 push {r0}
827 69c: e3a00009 mov r0, #9
828 6a0: ef000040 svc 0x00000040
829 6a4: e8bd0002 pop {r1}
830 6a8: e8bd0002 pop {r1}
831 6ac: e8bd0004 pop {r2}
832 6b0: e8bd0008 pop {r3}
833 6b4: e8bd4000 pop {lr}
834 6b8: e12fff1e bx lr
835
836 000006bc <dup>:
837 6bc: e92d4000 push {lr}
838 6c0: e92d0008 push {r3}
839 6c4: e92d0004 push {r2}
840 6c8: e92d0002 push {r1}
841 6cc: e92d0001 push {r0}
842 6d0: e3a0000a mov r0, #10
843 6d4: ef000040 svc 0x00000040
844 6d8: e8bd0002 pop {r1}
845 6dc: e8bd0002 pop {r1}
846 6e0: e8bd0004 pop {r2}
847 6e4: e8bd0008 pop {r3}
848 6e8: e8bd4000 pop {lr}
849 6ec: e12fff1e bx lr
850
851 000006f0 <getpid>:
852 6f0: e92d4000 push {lr}
853 6f4: e92d0008 push {r3}
854 6f8: e92d0004 push {r2}
855 6fc: e92d0002 push {r1}
856 700: e92d0001 push {r0}
857 704: e3a0000b mov r0, #11
858 708: ef000040 svc 0x00000040
859 70c: e8bd0002 pop {r1}
860 710: e8bd0002 pop {r1}
861 714: e8bd0004 pop {r2}
862 718: e8bd0008 pop {r3}
863 71c: e8bd4000 pop {lr}
864 720: e12fff1e bx lr
865
866 00000724 <sbrk>:
867 724: e92d4000 push {lr}
868 728: e92d0008 push {r3}
869 72c: e92d0004 push {r2}
870 730: e92d0002 push {r1}
871 734: e92d0001 push {r0}
872 738: e3a0000c mov r0, #12
873 73c: ef000040 svc 0x00000040
874 740: e8bd0002 pop {r1}
875 744: e8bd0002 pop {r1}
876 748: e8bd0004 pop {r2}
877 74c: e8bd0008 pop {r3}
878 750: e8bd4000 pop {lr}
879 754: e12fff1e bx lr
880
881 00000758 <sleep>:
882 758: e92d4000 push {lr}
883 75c: e92d0008 push {r3}
884 760: e92d0004 push {r2}
885 764: e92d0002 push {r1}
886 768: e92d0001 push {r0}
887 76c: e3a0000d mov r0, #13
888 770: ef000040 svc 0x00000040
889 774: e8bd0002 pop {r1}
890 778: e8bd0002 pop {r1}
891 77c: e8bd0004 pop {r2}
892 780: e8bd0008 pop {r3}
893 784: e8bd4000 pop {lr}
894 788: e12fff1e bx lr
895
896 0000078c <uptime>:
897 78c: e92d4000 push {lr}
898 790: e92d0008 push {r3}
899 794: e92d0004 push {r2}
900 798: e92d0002 push {r1}
901 79c: e92d0001 push {r0}
902 7a0: e3a0000e mov r0, #14
903 7a4: ef000040 svc 0x00000040
904 7a8: e8bd0002 pop {r1}
905 7ac: e8bd0002 pop {r1}
906 7b0: e8bd0004 pop {r2}
907 7b4: e8bd0008 pop {r3}
908 7b8: e8bd4000 pop {lr}
909 7bc: e12fff1e bx lr
910
911 000007c0 <putc>:
912 #include "stat.h"
913 #include "user.h"
914
915 static void
916 putc(int fd, char c)
917 {
918 7c0: e92d4800 push {fp, lr}
919 7c4: e28db004 add fp, sp, #4
920 7c8: e24b3004 sub r3, fp, #4
921 7cc: e24dd008 sub sp, sp, #8
922 write(fd, &c, 1);
923 7d0: e3a02001 mov r2, #1
924 #include "stat.h"
925 #include "user.h"
926
927 static void
928 putc(int fd, char c)
929 {
930 7d4: e5631001 strb r1, [r3, #-1]!
931 write(fd, &c, 1);
932 7d8: e1a01003 mov r1, r3
933 7dc: ebffff27 bl 480 <write>
934 }
935 7e0: e24bd004 sub sp, fp, #4
936 7e4: e8bd8800 pop {fp, pc}
937
938 000007e8 <printint>:
939 return q;
940 }
941
942 static void
943 printint(int fd, int xx, int base, int sgn)
944 {
945 7e8: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr}
946 7ec: e1a04000 mov r4, r0
947 char buf[16];
948 int i, neg;
949 uint x, y, b;
950
951 neg = 0;
952 if(sgn && xx < 0){
953 7f0: e1a00fa1 lsr r0, r1, #31
954 7f4: e3530000 cmp r3, #0
955 7f8: 03a03000 moveq r3, #0
956 7fc: 12003001 andne r3, r0, #1
957 return q;
958 }
959
960 static void
961 printint(int fd, int xx, int base, int sgn)
962 {
963 800: e28db020 add fp, sp, #32
964 char buf[16];
965 int i, neg;
966 uint x, y, b;
967
968 neg = 0;
969 if(sgn && xx < 0){
970 804: e3530000 cmp r3, #0
971 return q;
972 }
973
974 static void
975 printint(int fd, int xx, int base, int sgn)
976 {
977 808: e24dd014 sub sp, sp, #20
978 80c: e59f909c ldr r9, [pc, #156] ; 8b0 <printint+0xc8>
979 uint x, y, b;
980
981 neg = 0;
982 if(sgn && xx < 0){
983 neg = 1;
984 x = -xx;
985 810: 12611000 rsbne r1, r1, #0
986 int i, neg;
987 uint x, y, b;
988
989 neg = 0;
990 if(sgn && xx < 0){
991 neg = 1;
992 814: 13a03001 movne r3, #1
993 } else {
994 x = xx;
995 }
996
997 b = base;
998 i = 0;
999 818: e3a0a000 mov sl, #0
1000 81c: e24b6034 sub r6, fp, #52 ; 0x34
1001 for(i=31;i>=0;i--){
1002 r = r << 1;
1003 r = r | ((n >> i) & 1);
1004 if(r >= d) {
1005 r = r - d;
1006 q = q | (1 << i);
1007 820: e3a08001 mov r8, #1
1008 write(fd, &c, 1);
1009 }
1010
1011 u32 div(u32 n, u32 d) // long division
1012 {
1013 u32 q=0, r=0;
1014 824: e3a07000 mov r7, #0
1015 int i;
1016
1017 for(i=31;i>=0;i--){
1018 828: e3a0001f mov r0, #31
1019 write(fd, &c, 1);
1020 }
1021
1022 u32 div(u32 n, u32 d) // long division
1023 {
1024 u32 q=0, r=0;
1025 82c: e1a0c007 mov ip, r7
1026 int i;
1027
1028 for(i=31;i>=0;i--){
1029 r = r << 1;
1030 r = r | ((n >> i) & 1);
1031 830: e1a0e031 lsr lr, r1, r0
1032 834: e20ee001 and lr, lr, #1
1033 838: e18ec08c orr ip, lr, ip, lsl #1
1034 if(r >= d) {
1035 83c: e152000c cmp r2, ip
1036 r = r - d;
1037 q = q | (1 << i);
1038 840: 91877018 orrls r7, r7, r8, lsl r0
1039
1040 for(i=31;i>=0;i--){
1041 r = r << 1;
1042 r = r | ((n >> i) & 1);
1043 if(r >= d) {
1044 r = r - d;
1045 844: 9062c00c rsbls ip, r2, ip
1046 u32 div(u32 n, u32 d) // long division
1047 {
1048 u32 q=0, r=0;
1049 int i;
1050
1051 for(i=31;i>=0;i--){
1052 848: e2500001 subs r0, r0, #1
1053 84c: 2afffff7 bcs 830 <printint+0x48>
1054
1055 b = base;
1056 i = 0;
1057 do{
1058 y = div(x, b);
1059 buf[i++] = digits[x - y * b];
1060 850: e0000792 mul r0, r2, r7
1061 }while((x = y) != 0);
1062 854: e3570000 cmp r7, #0
1063
1064 b = base;
1065 i = 0;
1066 do{
1067 y = div(x, b);
1068 buf[i++] = digits[x - y * b];
1069 858: e0601001 rsb r1, r0, r1
1070 85c: e28a5001 add r5, sl, #1
1071 860: e7d91001 ldrb r1, [r9, r1]
1072 864: e7c6100a strb r1, [r6, sl]
1073 }while((x = y) != 0);
1074 868: 11a01007 movne r1, r7
1075
1076 b = base;
1077 i = 0;
1078 do{
1079 y = div(x, b);
1080 buf[i++] = digits[x - y * b];
1081 86c: 11a0a005 movne sl, r5
1082 870: 1affffeb bne 824 <printint+0x3c>
1083 }while((x = y) != 0);
1084 if(neg)
1085 874: e3530000 cmp r3, #0
1086 buf[i++] = '-';
1087 878: 124b2024 subne r2, fp, #36 ; 0x24
1088 87c: 10823005 addne r3, r2, r5
1089 880: 128a5002 addne r5, sl, #2
1090
1091 while(--i >= 0)
1092 884: e2455001 sub r5, r5, #1
1093 do{
1094 y = div(x, b);
1095 buf[i++] = digits[x - y * b];
1096 }while((x = y) != 0);
1097 if(neg)
1098 buf[i++] = '-';
1099 888: 13a0202d movne r2, #45 ; 0x2d
1100 88c: 15432010 strbne r2, [r3, #-16]
1101
1102 while(--i >= 0)
1103 putc(fd, buf[i]);
1104 890: e7d61005 ldrb r1, [r6, r5]
1105 894: e1a00004 mov r0, r4
1106 buf[i++] = digits[x - y * b];
1107 }while((x = y) != 0);
1108 if(neg)
1109 buf[i++] = '-';
1110
1111 while(--i >= 0)
1112 898: e2455001 sub r5, r5, #1
1113 putc(fd, buf[i]);
1114 89c: ebffffc7 bl 7c0 <putc>
1115 buf[i++] = digits[x - y * b];
1116 }while((x = y) != 0);
1117 if(neg)
1118 buf[i++] = '-';
1119
1120 while(--i >= 0)
1121 8a0: e3750001 cmn r5, #1
1122 8a4: 1afffff9 bne 890 <printint+0xa8>
1123 putc(fd, buf[i]);
1124 }
1125 8a8: e24bd020 sub sp, fp, #32
1126 8ac: e8bd8ff0 pop {r4, r5, r6, r7, r8, r9, sl, fp, pc}
1127 8b0: 00000c18 .word 0x00000c18
1128
1129 000008b4 <div>:
1130 write(fd, &c, 1);
1131 }
1132
1133 u32 div(u32 n, u32 d) // long division
1134 {
1135 u32 q=0, r=0;
1136 8b4: e3a03000 mov r3, #0
1137 {
1138 write(fd, &c, 1);
1139 }
1140
1141 u32 div(u32 n, u32 d) // long division
1142 {
1143 8b8: e92d0830 push {r4, r5, fp}
1144 8bc: e1a02000 mov r2, r0
1145 8c0: e28db008 add fp, sp, #8
1146 u32 q=0, r=0;
1147 int i;
1148
1149 for(i=31;i>=0;i--){
1150 8c4: e3a0c01f mov ip, #31
1151 write(fd, &c, 1);
1152 }
1153
1154 u32 div(u32 n, u32 d) // long division
1155 {
1156 u32 q=0, r=0;
1157 8c8: e1a00003 mov r0, r3
1158 for(i=31;i>=0;i--){
1159 r = r << 1;
1160 r = r | ((n >> i) & 1);
1161 if(r >= d) {
1162 r = r - d;
1163 q = q | (1 << i);
1164 8cc: e3a05001 mov r5, #1
1165 u32 q=0, r=0;
1166 int i;
1167
1168 for(i=31;i>=0;i--){
1169 r = r << 1;
1170 r = r | ((n >> i) & 1);
1171 8d0: e1a04c32 lsr r4, r2, ip
1172 8d4: e2044001 and r4, r4, #1
1173 8d8: e1843083 orr r3, r4, r3, lsl #1
1174 if(r >= d) {
1175 8dc: e1530001 cmp r3, r1
1176 r = r - d;
1177 q = q | (1 << i);
1178 8e0: 21800c15 orrcs r0, r0, r5, lsl ip
1179
1180 for(i=31;i>=0;i--){
1181 r = r << 1;
1182 r = r | ((n >> i) & 1);
1183 if(r >= d) {
1184 r = r - d;
1185 8e4: 20613003 rsbcs r3, r1, r3
1186 u32 div(u32 n, u32 d) // long division
1187 {
1188 u32 q=0, r=0;
1189 int i;
1190
1191 for(i=31;i>=0;i--){
1192 8e8: e25cc001 subs ip, ip, #1
1193 8ec: 2afffff7 bcs 8d0 <div+0x1c>
1194 r = r - d;
1195 q = q | (1 << i);
1196 }
1197 }
1198 return q;
1199 }
1200 8f0: e24bd008 sub sp, fp, #8
1201 8f4: e8bd0830 pop {r4, r5, fp}
1202 8f8: e12fff1e bx lr
1203
1204 000008fc <printf>:
1205 }
1206
1207 // Print to the given fd. Only understands %d, %x, %p, %s.
1208 void
1209 printf(int fd, char *fmt, ...)
1210 {
1211 8fc: e92d000e push {r1, r2, r3}
1212 900: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr}
1213 904: e28db020 add fp, sp, #32
1214 908: e1a05000 mov r5, r0
1215 int c, i, state;
1216 uint *ap;
1217
1218 state = 0;
1219 ap = (uint*)(void*)&fmt + 1;
1220 for(i = 0; fmt[i]; i++){
1221 90c: e59b4004 ldr r4, [fp, #4]
1222 910: e5d48000 ldrb r8, [r4]
1223 914: e3580000 cmp r8, #0
1224 918: 0a000027 beq 9bc <printf+0xc0>
1225 ap++;
1226 } else if(c == 's'){
1227 s = (char*)*ap;
1228 ap++;
1229 if(s == 0)
1230 s = "(null)";
1231 91c: e59f712c ldr r7, [pc, #300] ; a50 <printf+0x154>
1232 char *s;
1233 int c, i, state;
1234 uint *ap;
1235
1236 state = 0;
1237 ap = (uint*)(void*)&fmt + 1;
1238 920: e28b6008 add r6, fp, #8
1239 {
1240 char *s;
1241 int c, i, state;
1242 uint *ap;
1243
1244 state = 0;
1245 924: e3a0a000 mov sl, #0
1246 928: ea000008 b 950 <printf+0x54>
1247 ap = (uint*)(void*)&fmt + 1;
1248 for(i = 0; fmt[i]; i++){
1249 c = fmt[i] & 0xff;
1250 if(state == 0){
1251 if(c == '%'){
1252 92c: e3580025 cmp r8, #37 ; 0x25
1253 state = '%';
1254 930: 01a0a008 moveq sl, r8
1255 state = 0;
1256 ap = (uint*)(void*)&fmt + 1;
1257 for(i = 0; fmt[i]; i++){
1258 c = fmt[i] & 0xff;
1259 if(state == 0){
1260 if(c == '%'){
1261 934: 0a000002 beq 944 <printf+0x48>
1262 state = '%';
1263 } else {
1264 putc(fd, c);
1265 938: e1a00005 mov r0, r5
1266 93c: e1a01008 mov r1, r8
1267 940: ebffff9e bl 7c0 <putc>
1268 int c, i, state;
1269 uint *ap;
1270
1271 state = 0;
1272 ap = (uint*)(void*)&fmt + 1;
1273 for(i = 0; fmt[i]; i++){
1274 944: e5f48001 ldrb r8, [r4, #1]!
1275 948: e3580000 cmp r8, #0
1276 94c: 0a00001a beq 9bc <printf+0xc0>
1277 c = fmt[i] & 0xff;
1278 if(state == 0){
1279 950: e35a0000 cmp sl, #0
1280 954: 0afffff4 beq 92c <printf+0x30>
1281 if(c == '%'){
1282 state = '%';
1283 } else {
1284 putc(fd, c);
1285 }
1286 } else if(state == '%'){
1287 958: e35a0025 cmp sl, #37 ; 0x25
1288 95c: 1afffff8 bne 944 <printf+0x48>
1289 if(c == 'd'){
1290 960: e3580064 cmp r8, #100 ; 0x64
1291 964: 0a00002c beq a1c <printf+0x120>
1292 printint(fd, *ap, 10, 1);
1293 ap++;
1294 } else if(c == 'x' || c == 'p'){
1295 968: e3580078 cmp r8, #120 ; 0x78
1296 96c: 13580070 cmpne r8, #112 ; 0x70
1297 970: 13a09000 movne r9, #0
1298 974: 03a09001 moveq r9, #1
1299 978: 0a000013 beq 9cc <printf+0xd0>
1300 printint(fd, *ap, 16, 0);
1301 ap++;
1302 } else if(c == 's'){
1303 97c: e3580073 cmp r8, #115 ; 0x73
1304 980: 0a000018 beq 9e8 <printf+0xec>
1305 s = "(null)";
1306 while(*s != 0){
1307 putc(fd, *s);
1308 s++;
1309 }
1310 } else if(c == 'c'){
1311 984: e3580063 cmp r8, #99 ; 0x63
1312 988: 0a00002a beq a38 <printf+0x13c>
1313 putc(fd, *ap);
1314 ap++;
1315 } else if(c == '%'){
1316 98c: e3580025 cmp r8, #37 ; 0x25
1317 putc(fd, c);
1318 990: e1a0100a mov r1, sl
1319 994: e1a00005 mov r0, r5
1320 s++;
1321 }
1322 } else if(c == 'c'){
1323 putc(fd, *ap);
1324 ap++;
1325 } else if(c == '%'){
1326 998: 0a000002 beq 9a8 <printf+0xac>
1327 putc(fd, c);
1328 } else {
1329 // Unknown % sequence. Print it to draw attention.
1330 putc(fd, '%');
1331 99c: ebffff87 bl 7c0 <putc>
1332 putc(fd, c);
1333 9a0: e1a00005 mov r0, r5
1334 9a4: e1a01008 mov r1, r8
1335 9a8: ebffff84 bl 7c0 <putc>
1336 int c, i, state;
1337 uint *ap;
1338
1339 state = 0;
1340 ap = (uint*)(void*)&fmt + 1;
1341 for(i = 0; fmt[i]; i++){
1342 9ac: e5f48001 ldrb r8, [r4, #1]!
1343 } else {
1344 // Unknown % sequence. Print it to draw attention.
1345 putc(fd, '%');
1346 putc(fd, c);
1347 }
1348 state = 0;
1349 9b0: e1a0a009 mov sl, r9
1350 int c, i, state;
1351 uint *ap;
1352
1353 state = 0;
1354 ap = (uint*)(void*)&fmt + 1;
1355 for(i = 0; fmt[i]; i++){
1356 9b4: e3580000 cmp r8, #0
1357 9b8: 1affffe4 bne 950 <printf+0x54>
1358 putc(fd, c);
1359 }
1360 state = 0;
1361 }
1362 }
1363 }
1364 9bc: e24bd020 sub sp, fp, #32
1365 9c0: e8bd4ff0 pop {r4, r5, r6, r7, r8, r9, sl, fp, lr}
1366 9c4: e28dd00c add sp, sp, #12
1367 9c8: e12fff1e bx lr
1368 } else if(state == '%'){
1369 if(c == 'd'){
1370 printint(fd, *ap, 10, 1);
1371 ap++;
1372 } else if(c == 'x' || c == 'p'){
1373 printint(fd, *ap, 16, 0);
1374 9cc: e1a00005 mov r0, r5
1375 9d0: e4961004 ldr r1, [r6], #4
1376 9d4: e3a02010 mov r2, #16
1377 9d8: e3a03000 mov r3, #0
1378 9dc: ebffff81 bl 7e8 <printint>
1379 } else {
1380 // Unknown % sequence. Print it to draw attention.
1381 putc(fd, '%');
1382 putc(fd, c);
1383 }
1384 state = 0;
1385 9e0: e3a0a000 mov sl, #0
1386 9e4: eaffffd6 b 944 <printf+0x48>
1387 ap++;
1388 } else if(c == 'x' || c == 'p'){
1389 printint(fd, *ap, 16, 0);
1390 ap++;
1391 } else if(c == 's'){
1392 s = (char*)*ap;
1393 9e8: e4968004 ldr r8, [r6], #4
1394 ap++;
1395 if(s == 0)
1396 s = "(null)";
1397 9ec: e3580000 cmp r8, #0
1398 9f0: 01a08007 moveq r8, r7
1399 while(*s != 0){
1400 9f4: e5d81000 ldrb r1, [r8]
1401 9f8: e3510000 cmp r1, #0
1402 9fc: 0a000004 beq a14 <printf+0x118>
1403 putc(fd, *s);
1404 a00: e1a00005 mov r0, r5
1405 a04: ebffff6d bl 7c0 <putc>
1406 } else if(c == 's'){
1407 s = (char*)*ap;
1408 ap++;
1409 if(s == 0)
1410 s = "(null)";
1411 while(*s != 0){
1412 a08: e5f81001 ldrb r1, [r8, #1]!
1413 a0c: e3510000 cmp r1, #0
1414 a10: 1afffffa bne a00 <printf+0x104>
1415 } else {
1416 // Unknown % sequence. Print it to draw attention.
1417 putc(fd, '%');
1418 putc(fd, c);
1419 }
1420 state = 0;
1421 a14: e1a0a001 mov sl, r1
1422 a18: eaffffc9 b 944 <printf+0x48>
1423 } else {
1424 putc(fd, c);
1425 }
1426 } else if(state == '%'){
1427 if(c == 'd'){
1428 printint(fd, *ap, 10, 1);
1429 a1c: e1a00005 mov r0, r5
1430 a20: e4961004 ldr r1, [r6], #4
1431 a24: e3a0200a mov r2, #10
1432 a28: e3a03001 mov r3, #1
1433 a2c: ebffff6d bl 7e8 <printint>
1434 } else {
1435 // Unknown % sequence. Print it to draw attention.
1436 putc(fd, '%');
1437 putc(fd, c);
1438 }
1439 state = 0;
1440 a30: e3a0a000 mov sl, #0
1441 a34: eaffffc2 b 944 <printf+0x48>
1442 while(*s != 0){
1443 putc(fd, *s);
1444 s++;
1445 }
1446 } else if(c == 'c'){
1447 putc(fd, *ap);
1448 a38: e4961004 ldr r1, [r6], #4
1449 a3c: e1a00005 mov r0, r5
1450 } else {
1451 // Unknown % sequence. Print it to draw attention.
1452 putc(fd, '%');
1453 putc(fd, c);
1454 }
1455 state = 0;
1456 a40: e1a0a009 mov sl, r9
1457 while(*s != 0){
1458 putc(fd, *s);
1459 s++;
1460 }
1461 } else if(c == 'c'){
1462 putc(fd, *ap);
1463 a44: e6ef1071 uxtb r1, r1
1464 a48: ebffff5c bl 7c0 <putc>
1465 a4c: eaffffbc b 944 <printf+0x48>
1466 a50: 00000c2c .word 0x00000c2c
1467
1468 00000a54 <free>:
1469 free(void *ap)
1470 {
1471 Header *bp, *p;
1472
1473 bp = (Header*)ap - 1;
1474 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1475 a54: e59f3098 ldr r3, [pc, #152] ; af4 <free+0xa0>
1476 static Header base;
1477 static Header *freep;
1478
1479 void
1480 free(void *ap)
1481 {
1482 a58: e92d0830 push {r4, r5, fp}
1483 Header *bp, *p;
1484
1485 bp = (Header*)ap - 1;
1486 a5c: e240c008 sub ip, r0, #8
1487 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1488 a60: e5932000 ldr r2, [r3]
1489 static Header base;
1490 static Header *freep;
1491
1492 void
1493 free(void *ap)
1494 {
1495 a64: e28db008 add fp, sp, #8
1496 Header *bp, *p;
1497
1498 bp = (Header*)ap - 1;
1499 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1500 a68: e152000c cmp r2, ip
1501 a6c: e5921000 ldr r1, [r2]
1502 a70: 2a000001 bcs a7c <free+0x28>
1503 a74: e15c0001 cmp ip, r1
1504 a78: 3a000007 bcc a9c <free+0x48>
1505 if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1506 a7c: e1520001 cmp r2, r1
1507 a80: 3a000003 bcc a94 <free+0x40>
1508 a84: e152000c cmp r2, ip
1509 a88: 3a000003 bcc a9c <free+0x48>
1510 a8c: e15c0001 cmp ip, r1
1511 a90: 3a000001 bcc a9c <free+0x48>
1512 static Header base;
1513 static Header *freep;
1514
1515 void
1516 free(void *ap)
1517 {
1518 a94: e1a02001 mov r2, r1
1519 a98: eafffff2 b a68 <free+0x14>
1520
1521 bp = (Header*)ap - 1;
1522 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1523 if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1524 break;
1525 if(bp + bp->s.size == p->s.ptr){
1526 a9c: e5104004 ldr r4, [r0, #-4]
1527 if(p + p->s.size == bp){
1528 p->s.size += bp->s.size;
1529 p->s.ptr = bp->s.ptr;
1530 } else
1531 p->s.ptr = bp;
1532 freep = p;
1533 aa0: e5832000 str r2, [r3]
1534
1535 bp = (Header*)ap - 1;
1536 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1537 if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1538 break;
1539 if(bp + bp->s.size == p->s.ptr){
1540 aa4: e08c5184 add r5, ip, r4, lsl #3
1541 aa8: e1550001 cmp r5, r1
1542 bp->s.size += p->s.ptr->s.size;
1543 aac: 05911004 ldreq r1, [r1, #4]
1544 ab0: 00814004 addeq r4, r1, r4
1545 ab4: 05004004 streq r4, [r0, #-4]
1546 bp->s.ptr = p->s.ptr->s.ptr;
1547 ab8: 05921000 ldreq r1, [r2]
1548 abc: 05911000 ldreq r1, [r1]
1549 } else
1550 bp->s.ptr = p->s.ptr;
1551 ac0: e5001008 str r1, [r0, #-8]
1552 if(p + p->s.size == bp){
1553 ac4: e5921004 ldr r1, [r2, #4]
1554 ac8: e0824181 add r4, r2, r1, lsl #3
1555 acc: e15c0004 cmp ip, r4
1556 p->s.size += bp->s.size;
1557 p->s.ptr = bp->s.ptr;
1558 } else
1559 p->s.ptr = bp;
1560 ad0: 1582c000 strne ip, [r2]
1561 bp->s.size += p->s.ptr->s.size;
1562 bp->s.ptr = p->s.ptr->s.ptr;
1563 } else
1564 bp->s.ptr = p->s.ptr;
1565 if(p + p->s.size == bp){
1566 p->s.size += bp->s.size;
1567 ad4: 0510c004 ldreq ip, [r0, #-4]
1568 ad8: 008c1001 addeq r1, ip, r1
1569 adc: 05821004 streq r1, [r2, #4]
1570 p->s.ptr = bp->s.ptr;
1571 ae0: 05101008 ldreq r1, [r0, #-8]
1572 ae4: 05821000 streq r1, [r2]
1573 } else
1574 p->s.ptr = bp;
1575 freep = p;
1576 }
1577 ae8: e24bd008 sub sp, fp, #8
1578 aec: e8bd0830 pop {r4, r5, fp}
1579 af0: e12fff1e bx lr
1580 af4: 00000c34 .word 0x00000c34
1581
1582 00000af8 <malloc>:
1583 return freep;
1584 }
1585
1586 void*
1587 malloc(uint nbytes)
1588 {
1589 af8: e92d49f8 push {r3, r4, r5, r6, r7, r8, fp, lr}
1590 Header *p, *prevp;
1591 uint nunits;
1592
1593 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1594 afc: e2804007 add r4, r0, #7
1595 if((prevp = freep) == 0){
1596 b00: e59f50d4 ldr r5, [pc, #212] ; bdc <malloc+0xe4>
1597 malloc(uint nbytes)
1598 {
1599 Header *p, *prevp;
1600 uint nunits;
1601
1602 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1603 b04: e1a041a4 lsr r4, r4, #3
1604 return freep;
1605 }
1606
1607 void*
1608 malloc(uint nbytes)
1609 {
1610 b08: e28db01c add fp, sp, #28
1611 Header *p, *prevp;
1612 uint nunits;
1613
1614 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1615 if((prevp = freep) == 0){
1616 b0c: e5953000 ldr r3, [r5]
1617 malloc(uint nbytes)
1618 {
1619 Header *p, *prevp;
1620 uint nunits;
1621
1622 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1623 b10: e2844001 add r4, r4, #1
1624 if((prevp = freep) == 0){
1625 b14: e3530000 cmp r3, #0
1626 b18: 0a00002b beq bcc <malloc+0xd4>
1627 b1c: e5930000 ldr r0, [r3]
1628 b20: e5902004 ldr r2, [r0, #4]
1629 base.s.ptr = freep = prevp = &base;
1630 base.s.size = 0;
1631 }
1632 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1633 if(p->s.size >= nunits){
1634 b24: e1520004 cmp r2, r4
1635 b28: 2a00001b bcs b9c <malloc+0xa4>
1636 morecore(uint nu)
1637 {
1638 char *p;
1639 Header *hp;
1640
1641 if(nu < 4096)
1642 b2c: e59f80ac ldr r8, [pc, #172] ; be0 <malloc+0xe8>
1643 p->s.size -= nunits;
1644 p += p->s.size;
1645 p->s.size = nunits;
1646 }
1647 freep = prevp;
1648 return (void*)(p + 1);
1649 b30: e1a07184 lsl r7, r4, #3
1650 b34: ea000003 b b48 <malloc+0x50>
1651 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1652 if((prevp = freep) == 0){
1653 base.s.ptr = freep = prevp = &base;
1654 base.s.size = 0;
1655 }
1656 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1657 b38: e5930000 ldr r0, [r3]
1658 if(p->s.size >= nunits){
1659 b3c: e5902004 ldr r2, [r0, #4]
1660 b40: e1540002 cmp r4, r2
1661 b44: 9a000014 bls b9c <malloc+0xa4>
1662 p->s.size = nunits;
1663 }
1664 freep = prevp;
1665 return (void*)(p + 1);
1666 }
1667 if(p == freep)
1668 b48: e5952000 ldr r2, [r5]
1669 b4c: e1a03000 mov r3, r0
1670 b50: e1500002 cmp r0, r2
1671 b54: 1afffff7 bne b38 <malloc+0x40>
1672 morecore(uint nu)
1673 {
1674 char *p;
1675 Header *hp;
1676
1677 if(nu < 4096)
1678 b58: e1540008 cmp r4, r8
1679 nu = 4096;
1680 p = sbrk(nu * sizeof(Header));
1681 b5c: 81a00007 movhi r0, r7
1682 b60: 93a00902 movls r0, #32768 ; 0x8000
1683 morecore(uint nu)
1684 {
1685 char *p;
1686 Header *hp;
1687
1688 if(nu < 4096)
1689 b64: 81a06004 movhi r6, r4
1690 b68: 93a06a01 movls r6, #4096 ; 0x1000
1691 nu = 4096;
1692 p = sbrk(nu * sizeof(Header));
1693 b6c: ebfffeec bl 724 <sbrk>
1694 b70: e1a03000 mov r3, r0
1695 if(p == (char*)-1)
1696 b74: e3730001 cmn r3, #1
1697 return 0;
1698 hp = (Header*)p;
1699 hp->s.size = nu;
1700 free((void*)(hp + 1));
1701 b78: e2800008 add r0, r0, #8
1702 Header *hp;
1703
1704 if(nu < 4096)
1705 nu = 4096;
1706 p = sbrk(nu * sizeof(Header));
1707 if(p == (char*)-1)
1708 b7c: 0a000010 beq bc4 <malloc+0xcc>
1709 return 0;
1710 hp = (Header*)p;
1711 hp->s.size = nu;
1712 b80: e5836004 str r6, [r3, #4]
1713 free((void*)(hp + 1));
1714 b84: ebffffb2 bl a54 <free>
1715 return freep;
1716 b88: e5953000 ldr r3, [r5]
1717 }
1718 freep = prevp;
1719 return (void*)(p + 1);
1720 }
1721 if(p == freep)
1722 if((p = morecore(nunits)) == 0)
1723 b8c: e3530000 cmp r3, #0
1724 b90: 1affffe8 bne b38 <malloc+0x40>
1725 return 0;
1726 b94: e1a00003 mov r0, r3
1727 }
1728 }
1729 b98: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
1730 base.s.ptr = freep = prevp = &base;
1731 base.s.size = 0;
1732 }
1733 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1734 if(p->s.size >= nunits){
1735 if(p->s.size == nunits)
1736 b9c: e1540002 cmp r4, r2
1737 prevp->s.ptr = p->s.ptr;
1738 else {
1739 p->s.size -= nunits;
1740 ba0: 10642002 rsbne r2, r4, r2
1741 ba4: 15802004 strne r2, [r0, #4]
1742 base.s.size = 0;
1743 }
1744 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1745 if(p->s.size >= nunits){
1746 if(p->s.size == nunits)
1747 prevp->s.ptr = p->s.ptr;
1748 ba8: 05902000 ldreq r2, [r0]
1749 else {
1750 p->s.size -= nunits;
1751 p += p->s.size;
1752 bac: 10800182 addne r0, r0, r2, lsl #3
1753 base.s.size = 0;
1754 }
1755 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1756 if(p->s.size >= nunits){
1757 if(p->s.size == nunits)
1758 prevp->s.ptr = p->s.ptr;
1759 bb0: 05832000 streq r2, [r3]
1760 else {
1761 p->s.size -= nunits;
1762 p += p->s.size;
1763 p->s.size = nunits;
1764 bb4: 15804004 strne r4, [r0, #4]
1765 }
1766 freep = prevp;
1767 bb8: e5853000 str r3, [r5]
1768 return (void*)(p + 1);
1769 bbc: e2800008 add r0, r0, #8
1770 bc0: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
1771 }
1772 if(p == freep)
1773 if((p = morecore(nunits)) == 0)
1774 return 0;
1775 bc4: e3a00000 mov r0, #0
1776 bc8: e8bd89f8 pop {r3, r4, r5, r6, r7, r8, fp, pc}
1777 Header *p, *prevp;
1778 uint nunits;
1779
1780 nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1781 if((prevp = freep) == 0){
1782 base.s.ptr = freep = prevp = &base;
1783 bcc: e2850004 add r0, r5, #4
1784 bd0: e5850000 str r0, [r5]
1785 base.s.size = 0;
1786 bd4: e9850009 stmib r5, {r0, r3}
1787 bd8: eaffffd3 b b2c <malloc+0x34>
1788 bdc: 00000c34 .word 0x00000c34
1789 be0: 00000fff .word 0x00000fff